I\'m working on a convolutional neural network in tensorflow and I have a problem. The problem is the input image I read through tfrecords contains a certain number of nan v
A much easier approach, compatible with TF2.0, is to just use tf.clip_by_value, which mirrors np.clip and removes NaNs (see here):
no_nans = tf.clip_by_value(has_nans, -1e12, 1e12)
Some caveats: 1) this also removes infs 2) Depending on your application you may need to set the clip value to a high value to avoid losing info.