How does SequentialModule chain modules


#1

I try to understand SequentialModule with reading an example https://github.com/apache/incubator-mxnet/blob/master/example/module/sequential_module.py.
In this example, both mod1 and mod2 take data=mx.symbol.Variable(‘data’) as an input. So I think mod1 and mod2 organize a parallel network and are not chained like:
data -> mod1
data -> mod2 -> output (Here is used for evaluation because take_labels=True.)

What I really want to do with SequentialModule is to pass the output from mod1 to mod2 like
data -> mod1 -> mod2 -> output.
Or, does the example do this by automatically passing the output from mod1 to mod2?

I would be happy if I could find information about chaining modules.


#2

hi,

you’re right that in the example both mod1 and mod2 take data=mx.symbol.Variable('data') as input. however, the example also does what you want here: https://github.com/apache/incubator-mxnet/blob/master/example/module/sequential_module.py#L56-L57.

So you’re also right that the example automatically passes the output from mod1 to mod2 in the code snippet referenced above. The sequentialModule definitely does what you want.