Hi,
I wanted to count the hidden layer of the model
model = nn.Sequential(
nn.Flatten(),
nn.Linear(784,128),
nn.ELU(),
nn.Linear(128,128),
nn.ELU(),
nn.Linear(128,10))
in this case the number of hidden layers 1 or 2?
Does nn.Flatten() count as a layer?
Flatten will return a view of the tensor, which shares the actual data with the original tensor. Only how the data is viewed is changed.
So you are only “reshaping” it. I would not count it as a hidden layer since there are no weights to be trained.
1 Like
Thanks for your comment. In that case number of hidden layers should be 1?
Yes
1 change of view
1 input
1 hidden
2 activations
1 output
1 Like
Typically the layers with learnable parameters are counted as layers.
1 Like