Neural Network#
- class equisolve.nn.Linear(in_tensor: <torch.ScriptClass object at 0x7f9b886a9070>, out_tensor: <torch.ScriptClass object at 0x7f9b886a9070>, bias: bool | <torch.ScriptClass object at 0x7f9b886a9070> = True)[source]#
- Parameters:
in_tensor – A tensor map that will be accepted in the
forward()function. It is used to determine the keys input shape, device and dtype of the input to create linear modules for tensor maps.out_tensor – A tensor map that is used to determine the properties labels and shape of the output tensor map. Because a linear module can change the number of properties, the labels of the properties cannot be persevered.
bias – See
torch.nn.Linearfor bool as input. For each TensorMap key the bias can be also individually tuend by using a TensorMap with one value for the bool.
- forward(tensor: <torch.ScriptClass object at 0x7f9b886a9070>) <torch.ScriptClass object at 0x7f9b886a9070>[source]#
Takes a tensor map and applies the modules on each key it.
- Parameters:
tensor – input tensor map
- classmethod from_module(in_keys: <torch.ScriptClass object at 0x7f9b88ed0f30>, in_features: int, out_features: int, bias: bool = True, device: ~torch.device | None = None, dtype: ~torch.dtype | None = None, many_to_one: bool = True, out_tensor: <torch.ScriptClass object at 0x7f9b886a9070> | None = None)[source]#
- Parameters:
in_keys – The keys that are assumed to be in the input tensor map in the
forward()function.in_features – See
torch.nn.Linearout_features – See
torch.nn.Linearbias – See
torch.nn.Lineardevice – See
torch.nn.Lineardtype – See
torch.nn.Linearmany_to_one – Specifies if a separate module for each block is used. If True the module is deepcopied for each key in the
in_keys.out_tensor – A tensor map that is used to determine the properties labels of the output. Because an arbitrary module can change the number of properties, the labels of the properties cannot be persevered. By default the output properties are relabeled using Labels.range.
- classmethod from_weights(weights: <torch.ScriptClass object at 0x7f9b886a9070>, bias: <torch.ScriptClass object at 0x7f9b886a9070> | None = None)[source]#
- Parameters:
weights – The weight tensor map from which we create the linear modules.
bias – The weight tensor map from which we create the linear layers.
- class equisolve.nn.ModuleTensorMap(module_map: ~torch.nn.modules.container.ModuleDict, out_tensor: <torch.ScriptClass object at 0x7f9b886a9070> | None = None)[source]#
A wrapper around a
torch.nn.ModuleDictto apply each module to the corresponding tensor block in the map using the dict key.- Parameters:
module_map – A dictionary of modules with tensor map keys as dict keys each module is applied on a block
out_tensor – A tensor map that is used to determine the properties labels of the output. Because an arbitrary module can change the number of properties, the labels of the properties cannot be persevered. By default the output properties are relabeled using Labels.range.
- forward(tensor: <torch.ScriptClass object at 0x7f9b886a9070>) <torch.ScriptClass object at 0x7f9b886a9070>[source]#
Takes a tensor map and applies the modules on each key it.
- Parameters:
tensor – input tensor map
- classmethod from_module(in_keys: <torch.ScriptClass object at 0x7f9b88ed0f30>, module: ~torch.nn.modules.module.Module, many_to_one: bool = True, out_tensor: <torch.ScriptClass object at 0x7f9b886a9070> | None = None)[source]#
A wrapper around one
torch.nn.Moduleapplying the same type of module on each tensor block.- Parameters:
in_keys – The keys that are assumed to be in the input tensor map in the
forward()function.module – The module that is applied on each block.
many_to_one – Specifies if a separate module for each block is used. If True the module is deep copied for each key in the
in_keys.out_tensor – A tensor map that is used to determine the properties labels of the output. Because an arbitrary module can change the number of properties, the labels of the properties cannot be persevered. By default the output properties are relabeled using Labels.range.
- property module_map#
The
torch.nn.ModuleDictthat maps hashed module keys to a module (seeModuleTensorMap.module_key())
- property out_tensor: <torch.ScriptClass object at 0x7f9b886a9070> | None#
The tensor map that is used to determine properties labels of the output of forward function.