Skip to content

DnnLayer Input & Output

DnnLayerInput

softneuro.core.DnnLayerInput(layer, input_index)

Input class that consists of input of a layer.

Attributes

  • prev_layer: The preceding DnnLayer object of the input.
  • prev_layer_output_index: Output index in the preceding DnnLayer object.
  • tensor: The Tensor object of the input.

Examples

dnn = softneuro.Dnn()
net = dnn.add_net('test')

layer0 = net.add_layer('source0', 'source')
layer1 = net.add_layer('source1', 'source')
layer2 = net.add_layer('add0', 'add')
layer3 = net.add_layer('add1', 'add')
layer0.connect(0, layer2, 0)
layer0.connect(0, layer3, 0)
layer1.connect(0, layer2, 1)
layer1.connect(0, layer3, 1)

dnn_layer_input0 = layer2.inputs[0]
print(dnn_layer_input0.prev_layer) # Results in DnnLayer(name='source0', type='source', outputs=[..])
print(dnn_layer_input0.prev_layer_output_index) # Results in 0

DnnLayerOutput

Output class that consists of output of a layer.

Attributes

  • next_layers: A series of DnnLayer objects those are connected to the layer.
  • next_layer_input_indices: A series of input indices of succeeding layers.
  • tensor: The Tensor object of output.

Examples

dnn = softneuro.Dnn()
net = dnn.add_net('test')

layer0 = net.add_layer('source0', 'source')
layer1 = net.add_layer('source1', 'source')
layer2 = net.add_layer('add0', 'add')
layer3 = net.add_layer('add1', 'add')

# Connect between layers
layer0.connect(0, layer2, 0)
layer0.connect(0, layer3, 0)
layer1.connect(0, layer2, 1)
layer1.connect(0, layer3, 1)

# next_layers
output0 = layer0.outputs[0]
output1 = layer1.outputs[0]
layer = output0.next_layers[0]
print(layer) # Results in DnnLayer(name='add0', type='add', inputs=[..], outputs=[..])

# next_layer_input_indices
indices0 = output0.next_layer_input_indices
print(indices0) # Results in [0, 0]
indices1 = output1.next_layer_input_indices
print(indices1) # Results in [1, 1]