# 将数组/Tensor中所有等于255的值修改成0
# 对于 numpy 数组 a
a[a == 255] = 0
# 对于 tensorflow Tensor类 a
a = tf.where(tf.not_equal(a, 255), a, tf.zeros_like(a))
TensorFlow 实现 numpy 中的索引+赋值
最新推荐文章于 2024-05-21 10:42:55 发布
# 将数组/Tensor中所有等于255的值修改成0
# 对于 numpy 数组 a
a[a == 255] = 0
# 对于 tensorflow Tensor类 a
a = tf.where(tf.not_equal(a, 255), a, tf.zeros_like(a))