nngeometry/layercollection.py
def from_model(model, ignore_unsupported_layers=False):
        """
        Constructs a new LayerCollection object by using all parameters
        of the model passed as argument.

        :param model: The PyTorch model
        :type model: `nn.Module`
        :param ignore_unsupported_layers: If false, will raise an error
        when model contains layers that are not supported yet. If true, will
        silently ignore the layer
        :type ignore_unsupported_layers: bool
        """
        lc = LayerCollection()
        for layer, mod in model.named_modules():
            mod_class = mod.__class__.__name__
            if mod_class in ['Linear', 'Conv2d', 'BatchNorm1d',
                             'BatchNorm2d', 'GroupNorm']:
                lc.add_layer('%s.%s' % (layer, str(mod)),
                             LayerCollection._module_to_layer(mod))
            elif not ignore_unsupported_layers:
                if len(list(mod.children())) == 0 and len(list(mod.parameters())) > 0:
                    raise Exception('I do not know what to do with layer ' + str(mod))

        return lc

        Constructs a new LayerCollection object by using all parameters
        of the model passed as argument.

        :param model: The PyTorch model
        :type model: `nn.Module`
        :param ignore_unsupported_layers: If false, will raise an error
        when model contains layers that are not supported yet. If true, will
        silently ignore the layer
        :type ignore_unsupported_layers: bool
        
Constructs a new LayerCollection object by using all parameters
of the model passed as argument.
Constructs a new LayerCollection object by using all parameters of the model passed as argument .
def from_model(model, ignore_unsupported_layers=False):
        lc = LayerCollection()
        for layer, mod in model.named_modules():
            mod_class = mod.__class__.__name__
            if mod_class in ['Linear', 'Conv2d', 'BatchNorm1d',
                             'BatchNorm2d', 'GroupNorm']:
                lc.add_layer('%s.%s' % (layer, str(mod)),
                             LayerCollection._module_to_layer(mod))
            elif not ignore_unsupported_layers:
                if len(list(mod.children())) == 0 and len(list(mod.parameters())) > 0:
                    raise Exception('I do not know what to do with layer ' + str(mod))
        return lc
def from_model ( model , ignore_unsupported_layers = False ) : lc = LayerCollection ( ) for layer , mod in model . named_modules ( ) : mod_class = mod . __class__ . __name__ if mod_class in [ 'Linear' , 'Conv2d' , 'BatchNorm1d' , 'BatchNorm2d' , 'GroupNorm' ] : lc . add_layer ( '%s.%s' % ( layer , str ( mod ) ) , LayerCollection . _module_to_layer ( mod ) ) elif not ignore_unsupported_layers : if len ( list ( mod . children ( ) ) ) == 0 and len ( list ( mod . parameters ( ) ) ) > 0 : raise Exception ( 'I do not know what to do with layer ' + str ( mod ) ) return lc
Constructs a new LayerCollection object by using all parameters
of the model passed as argument.
Constructs a new LayerCollection object by using all parameters of the model passed as argument .
"""
        Constructs a new LayerCollection object by using all parameters
        of the model passed as argument.

        :param model: The PyTorch model
        :type model: `nn.Module`
        :param ignore_unsupported_layers: If false, will raise an error
        when model contains layers that are not supported yet. If true, will
        silently ignore the layer
        :type ignore_unsupported_layers: bool
        """
model
The PyTorch model
The PyTorch model
ignore_unsupported_layers
If false, will raise an error
when model contains layers that are not supported yet. If true, will
silently ignore the layer
If false will raise an error when model contains layers that are not supported yet . If true will silently ignore the layer