Replace nan values in tensorflow tensor

后端 未结 4 2031
说谎
说谎 2021-01-04 00:02

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

4条回答
  •  生来不讨喜
    2021-01-04 00:12

    Clip by value made NaN infinity and where was overkill for one variable. I used this to convert a single value to 0 if it's NaN:

    value_not_nan = tf.dtypes.cast(tf.math.logical_not(tf.math.is_nan(value)), dtype=tf.float32)
    tf.math.multiply_no_nan(value, value_not_nan)
    

提交回复
热议问题