@ptrblck Thanks for your reply. I changed the number of filters and also the sequence conv - bn - relu - pool to match the Keras code. As for the dropout, I used nn.Dropout then explicitly go to training mode by
setting net = net.train() before looping through the batches and setting net = net.eval() when validating at the end of each epoch like the following:
x = nn.Dropout(p = 0.5)(torch.tanh(self.F8(x)))
......
net = net.train()
for local_batch, local_labels in training_generator:
......
net = net.eval()
with torch.no_grad():
.....

For each epoch in Pytorch I get:
epoch: 0 | train loss: 0.6084
epoch: 1 | train loss: 0.4554
whereas in Keras I get:
epoch: 0 | loss: 0.9154
epoch: 1 | loss: 0.2524
Over two epochs I still don’t recover Keras results.