相关疑难解决方法(0)

ValueError:必须完全定义所有形状.由于评论tf.random_crop而导致的问题

这个问题在某种程度上是一个扩展我如何使用从TFRecords读取的值作为tf.reshape的参数?

我使用以下代码将图像转换为特定形状:

height = tf.cast(features['height'],tf.int32)
width = tf.cast(features['width'],tf.int32)
image = tf.reshape(image,tf.pack([height, width, 3]))
Run Code Online (Sandbox Code Playgroud)

在cifar10_input代码中,图像随后被扭曲,其中IMAGE_SIZE = 32:

height = IMAGE_SIZE
width = IMAGE_SIZE
distorted_image = tf.random_crop(image, [height, width, 3])
Run Code Online (Sandbox Code Playgroud)

但是,就我的目的而言,我现在不需要随机播种.因此,我用以下内容替换了该行:

distorted_image = image
Run Code Online (Sandbox Code Playgroud)

当我这样做时,它会抛出以下错误:

Traceback (most recent call last):
  File "cnn_train.py", line 128, in <module>
    tf.app.run()
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/default/_app.py", line 30, in run
    sys.exit(main(sys.argv))
  File "cnn_train.py", line 124, in main
    train()
  File "cnn_train.py", line 56, in train
    images, labels = cnn.distorted_inputs()
  File "/home/samuelchin/tensorflow/my_code/CNN/cnn.py", line 123, in distorted_inputs
    batch_size=BATCH_SIZE)
  File "/home/samuelchin/tensorflow/my_code/CNN/cnn_input.py", line …
Run Code Online (Sandbox Code Playgroud)

tensorflow

4
推荐指数
1
解决办法
5738
查看次数

标签 统计

tensorflow ×1