Get output size of a model

Hi there,

is there any way one can figure out the output dimension of a model without passing a sample to it?

For example, I have two network net1 and net2. I want to use another network net3, which maps the concatenation of net1 and net2 as the feature to some label. By defining the net3, I have to specify the input dimension which equals net1.output_size + net2.output_size.

My idea would be net1.modules[-1].out_features + net2.modules[-1].out_features. Is there a more elegant solution?

Thanks!

I think your approach is valid, if the last layer is an instance of nn.Linear and I’m nor sure, if there is a more elegant approach.

Thanks for replying.

The last layer is indeed a nn.Linear. Concretely, I want to implement the RNN Transducer here.