Sequential vs. custom extending nn.Module


(Carsten Ditzel) #1

what is the difference in defining the net by plugging in a number of nn.layers in the Sequential container and inheriting from nn.Module with appropriate layer members and expliticit definition of the forward pass?

Are the situations in which it is advised to use one over the other?

thanks in advance


(Alban D) #2

Hi,

Both are the same. It the custom module is the most general way to do it. The Sequential has been added to be able to avoid having to reimplement it every time for networks that are sequential (and a bit for historical reasons).
You can use either of them, note that the custom forward will give you more freedom to do whatever you want :slight_smile:


(Carsten Ditzel) #3

thank you! I see that clearer now =)