Thanks. But, this network is getting trained only for batchsize = 1. That too, it is giving finite values for the first epoch and nan values after that. I am not able to sort out the problem. Could you find any issue with the training part of the code I have posted early?