nnopinf.operators.CompositeOperator#
- class nnopinf.operators.CompositeOperator(state_operators, name='CompositeOperator')[source]#
Bases:
Module\(f: (f_1,\ldots,f_K) \mapsto \sum_{i=1}^K f_k\)
Constructs an operator composed of other NN-OpInf operators
- Parameters:
state_operators (list of nnopinf.operators.Operator) – List of individual operators
name (string) – Operator name. Used when saving to file
Examples
>>> import nnopinf >>> import nnopinf.operators >>> x_input = nnopinf.Variable(size=3,name="x") >>> mu_input = nnopinf.Variable(size=2,name="mu") >>> MatrixMlp = nnopinf.operators.MatrixOperator(n_outputs=5,acts_on=x_input,depends_on=(x_input,mu_input,),n_hidden_layers=2,n_neurons_per_layer=2) >>> MatrixMlp2 = nnopinf.operators.MatrixOperator(n_outputs=5,acts_on=x_input,depends_on=(x_input,mu_input,),n_hidden_layers=2,n_neurons_per_layer=2) >>> CompositeMlp = nnopinf.operators.CompositeOperator([MatrixMlp,MatrixMlp2])
- forward(inputs, return_jacobian=False)[source]#
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.