Keyword arguments in torch.nn.Sequential

Hello at all!

a question regarding keywords in torch.nn.Sequential, it is possible in some way to forward keywords to specific models in a sequence?

    model = torch.nn.Sequential(model_0, MaxPoolingChannel(1))
    res = model(input_ids_2, keyword_test=mask)

here, keyword_test should be forwarded only to the first model.

Thank a lot and best regards!

Hi,

You can pass any single input to the sequential. So you can pass a tuple or dict if you want and unpack them in your first model.
The implementation is simple and can be found here if you want to see the forward method of the Sequential

2 Likes