How to use Pytorch to define my special layers like Lasagne.layers.concat?

in Lasagne, the code like this:

l_in_imgdim = nn.layers.InputLayer(
        shape=(batch_size, 2),
        name='imgdim'
    )

layers = []
l_conv = Conv2DLayer(layers[-1],
                         num_filters=32, filter_size=(7, 7), stride=(2, 2),
                         border_mode='same',
                         W=nn.init.Orthogonal(1.0), b=nn.init.Constant(0.1),
                         untie_biases=True)
layers.append(l_conv)
# after adding some common layers here...and the last one of these is FC-layer.
l_first_repr = layers[-1]
l_coarse_repr = nn.layers.concat([l_first_repr,    l_in_imgdim])
layers.append(l_coarse_repr)

My goal is to implement the networks based on Lasagne by Pytorch.

You could just define your model and concat the tensors in the forward function.
Here is a small example:

class MyModel(nn.Module):
    def __init__(self):
        super(MyModel, self).__init__()
        self.fc1a = nn.Linear(20, 10)
        self.fc1b = nn.Linear(20, 10)
        self.fc2 = nn.Linear(20, 2)
        
    def forward(self, x):
        x1 = F.relu(self.fc1a(x))
        x2 = F.relu(self.fc1b(x))
        x = torch.cat((x1, x2), dim=1)
        x = self.fc2(x)
        return x

model = MyModel()
x = torch.randn(1, 20)
output = model(x)

Thank you @ptrblck :smiley:, I will try it ~