FrEIA
The framework module contains the logic used in building the graph and inferring the order that the nodes have to be executed in forward and backward direction.
FrEIA.framework.
ConditionNode
Bases: FrEIA.framework.graph_inn.Node
FrEIA.framework.graph_inn.Node
Special type of node that represents contitional input to the internal networks inside coupling layers.
__init__
Initialize self. See help(type(self)) for accurate signature.
__module__
build_module
Instantiates the module and determines the output dimension by calling InvertibleModule#output_dims.
GraphINN
Bases: FrEIA.modules.base.InvertibleModule
FrEIA.modules.base.InvertibleModule
This class represents the invertible net itself. It is a subclass of InvertibleModule and supports the same methods.
The forward method has an additional option ‘rev’, with which the net can be computed in reverse. Passing jac to the forward method additionally computes the log determinant of the (inverse) Jacobian of the forward (backward) pass.
Parameters: dims_in: list of tuples specifying the shape of the inputs to this
operator: dims_in = [shape_x_0, shape_x_1, …]
this operator.
forward
Forward or backward computation of the whole net.
get_module_by_name
Return module of the first node in the graph with the provided name.
get_node_by_name
Return the first node in the graph with the provided name.
log_jacobian_numerical
Approximate log Jacobian determinant via finite differences.
output_dims
training
InputNode
Special type of node that represents the input data of the whole net (or the output when running reverse)
Node
Bases: object
object
The Node class represents one transformation in the graph, with an arbitrary number of in- and outputs.
The user specifies the input, and the underlying module computes the number of outputs.
__dict__
__repr__
Return repr(self).
__str__
Return str(self).
__weakref__
list of weak references to the object (if defined)
parse_inputs
Converts specified inputs to a node to a canonical format. Inputs can be specified in three forms:
a single node, then this nodes first output is taken as input
a single tuple (node, idx), specifying output idx of node
a list of tuples [(node, idx)], each specifying output idx of node
All such formats are converted to the last format.
OutputNode
Special type of node that represents the output of the whole net (or the input when running in reverse).
outputs
ReversibleGraphNet
Bases: FrEIA.framework.graph_inn.GraphINN
FrEIA.framework.graph_inn.GraphINN
ReversibleSequential
Bases: FrEIA.framework.sequence_inn.SequenceINN
FrEIA.framework.sequence_inn.SequenceINN
SequenceINN
Simpler than FrEIA.framework.GraphINN: Only supports a sequential series of modules (no splitting, merging, branching off). Has an append() method, to add new blocks in a more simple way than the computation-graph based approach of GraphINN. For example:
``` inn = SequenceINN(channels, dims_H, dims_W)
inn.append(FrEIA.modules.AllInOneBlock, clamp=2.0, permute_soft=True)
inn.append(FrEIA.modules.HaarDownsampling) # and so on ```
append
Append a reversible block from FrEIA.modules to the network. module_class: Class from FrEIA.modules. cond (int): index of which condition to use (conditions will be passed as list to forward()).
Conditioning nodes are not needed for SequenceINN.
cond_shape (tuple[int]): the shape of the condition tensor. **kwargs: Further keyword arguments that are passed to the constructor of module_class (see example).
Executes the sequential INN in forward or inverse (rev=True) direction.
x_or_z – input tensor (in contrast to GraphINN, a list of tensors is not supported, as SequenceINN only has one input).
c – list of conditions.
rev – whether to compute the network forward or reversed.
jac – whether to compute the log jacobian
network output. jac (Tensor): log-jacobian-determinant.
z_or_x (Tensor)