Creating a pytorch model based on Keras

I am new to pytorch. I am looking to create a model fully connected, 512 hidden layer neurons and dropout rate of 10% with ReLU nonlinearity.
This is the model I created :
torch.nn.Sequential(
torch.nn.Linear(512,4),
torch.nn.ReLU(),
torch.nn.Dropout(0.10),
)

Not sure if this correct.

Keras equivalent :
Sequential([
Dense(512, input_dim=64),
Activation(‘relu’),
Dropout(0.1),
Dense(4)
])

Any help on how to approach this would be appreciated.

I’m also new to this world. The following tutorial helps me alot

Pytorch equivalent is

torch.nn.Sequential(
torch.nn.Linear(64, 512),
torch.nn.ReLU(),
torch.nn.Dropout(0.10),
torch.nn.Linear(512, 4)
)

Please actively search for pytorch documents, you should have done it by yourself.

1 Like