module = nn.Concat(dim)Concat concatenates the output of one layer of "parallel" modules along the provided dimension
dim
: they take the same inputs, and their output is
concatenated.
mlp=nn.Concat(1); mlp:add(nn.Linear(5,3)) mlp:add(nn.Linear(5,7)) require "lab" print(mlp:forward(lab.randn(5)))which gives the output:
0.7486 0.1349 0.7924 -0.0371 -0.4794 0.3044 -0.0835 -0.7928 0.7856 -0.1815 [torch.Tensor of dimension 10]