2017-08-19 12 views
1

ファイルフォルダしかし、デコード後、tf.train.batchを使用すると問題が発生する可能性があります。ここにコードがあります。Tensorflow ValueError:すべての図形を完全に定義する必要があります。[TensorShape([次元(なし)、次元(なし)、次元(3)])、TensorShape([])

def get_batch(image, label, batch_size, capacity): 

image = tf.cast(image, tf.string) 
label = tf.cast(label, tf.int32) 

input_queue = tf.train.slice_input_producer([image, label]) 

label = input_queue[1] 
image_contents = tf.read_file(input_queue[0]) 
image = tf.image.decode_jpeg(image_contents, channels=3) 
image = tf.image.per_image_whitening(image) 

image_batch, label_batch = tf.train.batch([image, label], 
              batch_size = batch_size, 
              num_threads = 8, 
              capacity = capacity) 

label_batch = tf.reshape(label_batch, [batch_size]) 
image_batch = tf.cast(image_batch, tf.float32) 

return image_batch, label_batch 

エラーは、私はいくつかのテンションを定義していないと言いました。どうやってやるのか分からない。デコードを適切な方法で使用しなかったのかもしれない。ここにエラーがある。

Traceback (most recent call last): 
    File "input_data.py", line 118, in <module> 
    image_batch, label_batch = get_batch(image_list, label_list, BATCH_SIZE, CAPACITY) 
    File "input_data.py", line 90, in get_batch 
    capacity = capacity) 
    File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/input.py", line 538, in batch 
    capacity=capacity, dtypes=types, shapes=shapes, shared_name=shared_name) 
    File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/data_flow_ops.py", line 453, in __init__ 
    shapes = _as_shape_list(shapes, dtypes) 
    File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/data_flow_ops.py", line 71, in _as_shape_list 
    raise ValueError("All shapes must be fully defined: %s" % shapes) 
ValueError: All shapes must be fully defined: [TensorShape([Dimension(None), Dimension(None), Dimension(3)]), TensorShape([])] 

答えて

1

あなたがバッチにしたいデータが事前定義された形状を持っている必要があり、あなたの場合には、テンソルimageは、あなたがimage.set_shapeまたはtf.image.resize_images

+0

と形状を指定する必要はありません。ありがとうございました。 – Abraham

関連する問題