将tensorflow与tf.image.adjust_jpeg_质量一起使用时出错,输出形状未知?
当我运行演示代码时:将tensorflow与tf.image.adjust_jpeg_质量一起使用时出错,输出形状未知?,tensorflow,Tensorflow,当我运行演示代码时: x = tf.random.normal(shape=(256, 256, 3)) y = tf.image.adjust_jpeg_quality(x, 75) print('y shape is: ', y.shape) 输出如下: y形为:(?,?,?) 输出是否应该是(256,256,3)?为什么?有什么问题吗 我的tensorflow版本是TF 1.x中的1.14要打印输出,您需要在会话中执行代码,如下所示 %tensorflow_version 1.x im
x = tf.random.normal(shape=(256, 256, 3))
y = tf.image.adjust_jpeg_quality(x, 75)
print('y shape is: ', y.shape)
输出如下:
y形为:(?,?,?)
输出是否应该是(256,256,3)?为什么?有什么问题吗
我的tensorflow版本是TF 1.x中的1.14要打印输出,您需要在
会话中执行代码,如下所示
%tensorflow_version 1.x
import tensorflow as tf
print(tf.__version__)
with tf.Session() as sess:
x = tf.random.normal(shape=(256, 256, 3))
y = tf.image.adjust_jpeg_quality(x, 75)
print(sess.run(tf.shape(y)))
输出:
1.15.2
[256 256 3]
2.2.0
(256, 256, 3)
在TF2.x中,默认情况下启用了急切执行,因此您不需要会话
%tensorflow_version 2.x
import tensorflow as tf
print(tf.__version__)
x = tf.random.normal(shape=(256, 256, 3))
y = tf.image.adjust_jpeg_quality(x, 75)
print(y.shape)
输出:
1.15.2
[256 256 3]
2.2.0
(256, 256, 3)
在TF 1.x中,要打印输出,您需要在会话中执行代码,如下所示
%tensorflow_version 1.x
import tensorflow as tf
print(tf.__version__)
with tf.Session() as sess:
x = tf.random.normal(shape=(256, 256, 3))
y = tf.image.adjust_jpeg_quality(x, 75)
print(sess.run(tf.shape(y)))
输出:
1.15.2
[256 256 3]
2.2.0
(256, 256, 3)
在TF2.x中,默认情况下启用了急切执行,因此您不需要会话
%tensorflow_version 2.x
import tensorflow as tf
print(tf.__version__)
x = tf.random.normal(shape=(256, 256, 3))
y = tf.image.adjust_jpeg_quality(x, 75)
print(y.shape)
输出:
1.15.2
[256 256 3]
2.2.0
(256, 256, 3)