Recommendation for Deep FNN

(Ritchie Ng) #1

This is a simple 1 hidden layer FNN

class Net(nn.Module):
    def __init__(self, input_size, hidden_size, num_classes):
        super(Net, self).__init__()
        self.fc1 = nn.Linear(input_size, hidden_size) 
        self.relu = nn.ReLU()
        self.fc2 = nn.Linear(hidden_size, num_classes)  
    def forward(self, x):
        out = self.fc1(x)
        out = self.relu(out)
        out = self.fc2(out)
        return out

What’s the recommendation to create a deep one say 16/32 layers, doesn’t seem reasonable to have 16/32 lines similar to one another.

(Miguel Varela Ramos) #2

Use nn.ModuleList and then iterate through it in the forward call