analogvnn.nn.module.Layer
#
Module Contents#
Classes#
Base class for analog neural network modules. |
- class analogvnn.nn.module.Layer.Layer[source]#
Bases:
torch.nn.Module
Base class for analog neural network modules.
- Variables:
_inputs (Union[None, ArgsKwargs]) – Inputs of the layer.
_outputs (Union[None, Tensor, Sequence[Tensor]]) – Outputs of the layer.
_backward_module (Optional[BackwardModule]) – Backward module of the layer.
_use_autograd_graph (bool) – If True, the autograd graph is used to calculate the gradients.
call_super_init (bool) – If True, the super class __init__ of nn.Module is called
https – //github.com/pytorch/pytorch/pull/91819
- property use_autograd_graph: bool[source]#
If True, the autograd graph is used to calculate the gradients.
- Returns:
use_autograd_graph.
- Return type:
- property inputs: analogvnn.graph.ArgsKwargs.ArgsKwargsOutput[source]#
Inputs of the layer.
- Returns:
inputs.
- Return type:
ArgsKwargsOutput
- property outputs: Union[None, torch.Tensor, Sequence[torch.Tensor]][source]#
Outputs of the layer.
- Returns:
outputs.
- Return type:
Union[None, Tensor, Sequence[Tensor]]
- property backward_function: Union[None, Callable, analogvnn.backward.BackwardModule.BackwardModule][source]#
Backward module of the layer.
- Returns:
backward_function.
- Return type:
Union[None, Callable, BackwardModule]
- _inputs: Union[None, analogvnn.graph.ArgsKwargs.ArgsKwargs][source]#
- _outputs: Union[None, torch.Tensor, Sequence[torch.Tensor]][source]#
- _backward_module: Optional[analogvnn.backward.BackwardModule.BackwardModule][source]#
- __call__(*inputs, **kwargs)[source]#
Calls the forward pass of neural network layer.
- Parameters:
*inputs – Inputs of the forward pass.
**kwargs – Keyword arguments of the forward pass.
- set_backward_function(backward_class: Union[Callable, analogvnn.backward.BackwardModule.BackwardModule, Type[analogvnn.backward.BackwardModule.BackwardModule]]) Layer [source]#
Sets the backward_function attribute.
- Parameters:
backward_class (Union[Callable, BackwardModule, Type[BackwardModule]]) – backward_function.
- Returns:
self.
- Return type:
- Raises:
TypeError – If backward_class is not a callable or BackwardModule.
- named_registered_children(memo: Optional[Set[torch.nn.Module]] = None) Iterator[Tuple[str, torch.nn.Module]] [source]#
Returns an iterator over immediate registered children modules.
- Parameters:
memo – a memo to store the set of modules already added to the result
- Yields:
(str, Module) – Tuple containing a name and child module
Note
Duplicate modules are returned only once. In the following example,
l
will be returned only once.
- registered_children() Iterator[torch.nn.Module] [source]#
Returns an iterator over immediate registered children modules.
- Yields:
nn.Module – a module in the network
Note
Duplicate modules are returned only once. In the following example,
l
will be returned only once.
- _forward_wrapper(function: Callable) Callable [source]#
Wrapper for the forward function.
- Parameters:
function (Callable) – Forward function.
- Returns:
Wrapped function.
- Return type:
Callable
- _call_impl_forward(*args: torch.Tensor, **kwargs: torch.Tensor) analogvnn.utils.common_types.TENSORS [source]#
Calls the forward pass of the layer.
- Parameters:
*args – Inputs of the forward pass.
**kwargs – Keyword arguments of the forward pass.
- Returns:
Outputs of the forward pass.
- Return type:
TENSORS