【发布时间】:2021-10-09 08:24:10
【问题描述】:
我尝试减去两个张量,然后使用 relu 函数将每个负值转换为零,但我不能这样做,因为当我减去两个张量时,tensorflow 出于某种原因将 256 添加到每个负值!!
img = mpimg.imread('/home/moumenshobaky/tensorflow_files/virtualenv/archive/training/Dessert/82
7.jpg')
img2 = tf.math.floordiv(img,64)*64
img3 = img2-img
# showing an example of the Flatten class and operation
from tensorflow.keras.layers import Flatten
flatten = Flatten(dtype='float32')
print(flatten(img2))
print(img3)
现在结果是
tf.Tensor(
[[ 0 0 0 ... 64 64 0]
[ 0 0 0 ... 64 0 0]
[64 64 0 ... 64 0 0]
...
[64 64 64 ... 64 64 64]
[64 64 64 ... 64 64 64]
[64 64 64 ... 64 64 64]], shape=(384, 1536), dtype=uint8)
tf.Tensor(
[[198 197 213 ... 229 252 202]
[194 193 207 ... 235 193 207]
[250 253 198 ... 238 193 207]
...
[227 217 207 ... 218 230 242]
[226 216 206 ... 217 230 239]
[225 215 203 ... 214 227 235]], shape=(384, 1536), dtype=uint8)
【问题讨论】:
-
你是在减去负值,结果是加法吗?
-
no :/ 实际上,由于某种原因,这些值被添加到一个常量值,它是 256 我不知道为什么会发生这种情况
标签: tensorflow tensor