Hi,
No tanh cannot return nans as it’s gradient is well defined everywhere.
If this happens after some iterations, you should make sure your loss is well behaved and is not just diverging to very very large values until it gets nan.