DnnNet Input & Output
DnnNetInput
DnnNetInput class that consists of Dnn.
Attributes
- prev_net: The preceding DnnNet object of the input.
- prev_net_output_index: Output index in the preceding DnnNet object.
- tensor: The Tensor object of the input.
Examples
# --- main0 ---
# | |
# prenet --+ +-- postnet
# | |
# --- main1 ---
#
def create_pre_network(dnn):
net = dnn.add_net('preprocess')
net.add_layer('source0', 'source')
:
net.add_layer('sink0', 'sink')
return net
def create_main_network(dnn, name):
net = dnn.add_net(name)
net.add_layer('source0', 'source')
:
net.add_layer('sink0', 'sink')
return net
def create_post_network(dnn):
# network with two inputs
net = dnn.add_net('postprocess')
net.add_layer('source0', 'source')
net.add_layer('source1', 'source')
:
net.add_layer('sink0', 'sink')
return net
dnn = softneuro.Dnn()
# Create networks
prenet = create_pre_network(dnn)
main0 = create_main_network(dnn, 'main0')
main1 = create_main_network(dnn, 'main1')
postnet = create_post_network(dnn)
# Connect networks
prenet.pipe(0, main0, 0)
prenet.pipe(0, main1, 0)
main0.pipe(0, postnet, 0)
main1.pipe(0, postnet, 1)
# Get DnnNetInput object
dnn_net_input1 = postnet.inputs[1] # postnet has two inputs
print(dnn_net_input1) # Results in DnnNetInput(tensor=Tensor(..), prev_net=DnnNet(..), prev_net_output_index=0)
print(dnn_net_input1.prev_net) # Results in DnnNet(name='main1', layers=[..], inputs=[..], outputs=[..])
print(dnn_net_input1.prev_net_output_index) # Results in 0
DnnNetOutput
DnnNetOutput class that consists of Dnn.
Attributes
- next_nets: A series of DnnNet objects those are connected to the network.
- next_net_input_indices: A series of input indices of succeeding networks.
- tensor: The Tensor object of output.
Examples
# Given the Example in DnnNetInput...
net = dnn.nets[0]
print(net.name) # Results in 'preprocess'
output = net.outputs[0]
# prenet's output is connected to two different networks
print(output0.next_nets) # Results in '[0: DnnNet(name='main0' ... ), 1: DnnNet(name='main1' ...)]
print(output0.next_net_input_indices) # Results in [0, 0]