nngeometry/object/vector.py
def from_model_grad(model):
        """
        Creates a PVector using the current values of the `.grad`
        fields of parameters of the given model
        """
        dict_repr = dict()
        layer_collection = LayerCollection.from_model(model)
        l_to_m, _ = layer_collection.get_layerid_module_maps(model)
        for layer_id, layer in layer_collection.layers.items():
            mod = l_to_m[layer_id]
            if layer.bias is not None:
                dict_repr[layer_id] = (mod.weight.grad, mod.bias.grad)
            else:
                dict_repr[layer_id] = (mod.weight.grad,)
        return PVector(layer_collection, dict_repr=dict_repr)

        Creates a PVector using the current values of the `.grad`
        fields of parameters of the given model
        
Creates a PVector using the current values of the `.grad`
fields of parameters of the given model
Creates a PVector using the current values of the ` . grad ` fields of parameters of the given model
def from_model_grad(model):
        dict_repr = dict()
        layer_collection = LayerCollection.from_model(model)
        l_to_m, _ = layer_collection.get_layerid_module_maps(model)
        for layer_id, layer in layer_collection.layers.items():
            mod = l_to_m[layer_id]
            if layer.bias is not None:
                dict_repr[layer_id] = (mod.weight.grad, mod.bias.grad)
            else:
                dict_repr[layer_id] = (mod.weight.grad,)
        return PVector(layer_collection, dict_repr=dict_repr)
def from_model_grad ( model ) : dict_repr = dict ( ) layer_collection = LayerCollection . from_model ( model ) l_to_m , _ = layer_collection . get_layerid_module_maps ( model ) for layer_id , layer in layer_collection . layers . items ( ) : mod = l_to_m [ layer_id ] if layer . bias is not None : dict_repr [ layer_id ] = ( mod . weight . grad , mod . bias . grad ) else : dict_repr [ layer_id ] = ( mod . weight . grad , ) return PVector ( layer_collection , dict_repr = dict_repr )
Creates a PVector using the current values of the `.grad`
fields of parameters of the given model
Creates a PVector using the current values of the ` . grad ` fields of parameters of the given model
"""
        Creates a PVector using the current values of the `.grad`
        fields of parameters of the given model
        """
model