bartorch.nlop.NonlinearOperator#
- class bartorch.nlop.NonlinearOperator#
A map between shapes, with a derivative and its adjoint.
derivative()andadjoint()are taken at the point of the lastforward()call, which is how BART’s solvers use them. The backward pass ofF(x)isadjointat that point, so evaluating the operator elsewhere between a forward and a backward pass gives a wrong gradient.An operator may take more than one input and return more than one output;
ishapesandoshapesare the shape of each, andishapeandoshapeare the whole of it when there is one of each. The algebra inbartorch.nlopis what builds the many-argument ones:combine(),chain(),link(),dup().A subclass is defined either by
_create(), which builds one of BART’s operators, or in Python byforward(),derivative()andadjoint().- ishapes, oshapes
The shape of each input and of each output, C order.
- Type:
tuple of tuple of int
- ishape, oshape
Domain and codomain, for an operator with one input and one output.
- Type:
tuple of int
- __init__()#
Methods
__init__()adjoint(dy)DF(x)^H dyat the last evaluated point, for one input and one output.chain(other, *[, output, input])Output
outputofselfinto inputinputofother.combine(other)selfandotherside by side, sharing nothing.del_out([output])Drop an output, and everything computed only for it.
derivative(dx)DF(x) dxat the last evaluated point, for one input and one output.dup([a, b])Make two inputs of the same shape one input, kept at
a.flatten([inputs_only])Every input as one flat vector, and every output as another.
forward(*xs)F(x), which also fixes where every derivative is taken.jacobian([output, input])DF/dx_inputof one output, as aLinearOperator.linearize(*xs)The derivative at
x, as aLinearOperator.link([output, input])Tie an output back into an input; both arguments go away.
permute_inputs(perm)Reorder the inputs: the new input
iis the oldperm[i].permute_outputs(perm)Reorder the outputs: the new output
ois the oldperm[o].pin(input, value)Fix one input to
value; the input goes away.reshape_input(input, shape)This operator with one input's shape written differently.
reshape_output(output, shape)This operator with one output's shape written differently.
shift_input(new, old)Move one input to another position, the rest closing up behind it.
shift_output(new, old)Move one output to another position, the rest closing up behind it.
stack_inputs(a, b, axis)Make two inputs one, concatenated along a C-order
axis.stack_outputs(a, b, axis)Make two outputs one, concatenated along a C-order
axis.Attributes
deviceishapeThe domain, for an operator with one input.
ishapesThe shape of each argument, outputs and inputs kept apart.
oshapeThe codomain, for an operator with one output.
oshapes