Hello,
I found in keras a nice multilayer perceptron of the form
model.add(Dense(512, input_shape=(784,)))
model.add(Activation(‘tanh’))
model.add(Dropout(0.2))
model.add(Dense(512))
model.add(Activation(‘linear’))
model.add(Dropout(0.2))
model.add(Dense(512))
model.add(Activation(‘sigmoid’))
model.add(Dropout(0.2))
model.add(Dense(512))
model.add(Activation(‘linear’))
model.add(Dropout(0.2))
model.add(Dense(10))
model.add(Activation(‘softmax’))
I was not sure how to do the linear layers in pytorch, trying to mimic the tutorial I have
class Net(nn.Module):
def init(self):
super(Net, self).init()
self.hidden = nn.Linear(784,512)
self.hidden2 = nn.Linear(512,512)
self.hidden3 = nn.Linear(512,10)
self.out = nn.Linear(10,1)
def forward(self, x):
    x = F.tanh(self.hidden(x))
    x = F.dropout(self.hidden(x),0.2)
    x = F.sigmoid(self.hidden(x))
    x = F.dropout(self.hidden(x),0.2)
    x = F.softmax(self.hidden(x))
    x = self.out(x) 

def num_flat_features(self, x):
    size = x.size()[1:]  # all dimensions except the batch dimension
    num_features = 1
    for s in size:
        num_features *= s
    return num_features

But,

How do you create the purely linear layers?
As follow up nn itself has linear and nonlinear methods, but to do softmax etc I still use linear (per the example), what is the nonlinear layer functionality for?
Can someone describe the purpose/point of the num_flat_features function?
Am I settuping up the dropout right?

My apologies if these are basic questions, but I couldn’t quite find the right examples. In this case I’m just trying to create a multilayer perceptron with many nonlinear layers, so sometimes I am not sure if some of the functionality in the examples is for convolutional or more complicated nets specifically,