【发布时间】:2019-12-19 07:40:42
【问题描述】:
这里我有 x 和 y 作为形状的张量变量:每个 [5,256,256,3] 和 dtype: float32。这里,5 是我的批量大小,[256,256,3] 是三通道图像。我正在尝试执行这样的操作:
y[y>255] = 255
x[x > 255] = 255
y[y<0] = 0
x[x<0] = 0
#I have tried to create two tf variables by:
var_255 = tf.Variable(tf.ones(tf.shape(x), tf.float32))*255
var_0 = tf.Variable(tf.zeros(tf.shape(x), tf.float32))
#and tried to use tf.assign(). However, it still is not what I need.
我收到此错误:
'Tensor' 对象不支持项赋值
【问题讨论】:
-
您想在 Keras 或 TensorFlow 中执行此操作吗?
标签: python tensorflow keras