deepr.layers.Rename
- class deepr.layers.Rename(layer, inputs=None, outputs=None)[source]
Wrap Layer in a Node to rename inputs / outputs.
Allows you to rename inputs / outputs nodes of a
Layer
instance. This can be useful if you end up with aLayer
instance with inputs and outputs name that are not suitable for your needs.For example:
@deepr.layers.layer(n_in=2, n_out=1) def Add(tensors): x, y = tensors return x + y add = Add(inputs="a, b", outputs="c") layer = deepr.layers.Rename(layer=add, inputs="x, y", outputs="z") layer((1, 1)) # 2 layer({"x": 1, "y": 1}) # {"z": 2}
Note that the same behavior can be achieved using
Select
andDAG
as follows:layer = deepr.layers.DAG( deepr.layers.Select(inputs=("x", "y"), outputs=("a", "b")), Add(inputs=("a", "b"), outputs="c"), deepr.layers.Select("c", "z"), )
Methods
__init__
(layer[, inputs, outputs])forward
(tensors[, mode])Forward method of the layer
forward_as_dict
(tensors[, mode])Forward method on a dictionary of Tensors.