Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将tensorflow与tf.image.adjust_jpeg_质量一起使用时出错,输出形状未知?_Tensorflow - Fatal编程技术网

将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)