2016-06-12 1 views
0

tf.image.resize_image_with_crop_or_padを入力画像の一部を切り抜くために使用します。しかし、エラーが発生します:ValueError: 'image' must be fully defined。そしてTensor.set_shape()を追加したWhy do I get ValueError('\'image\' must be fully defined.') when transforming image in Tensorflow?を確認しましたが、動作しません。 は、私は次のように私のコードとエラーをリスト:Tensorflow:Tensor.set_shape()ValueError: 'image'は完全に定義されている必要があります

example = tf.image.decode_png(file_contents, channels=3) 
example.set_shape = ([256,256,3]) 
crop_image = tf.image.resize_image_with_crop_or_pad(example, crop_size, crop_size) 

エラー:エラーが出て来ても、私は画像に一定の形状を設定する理由

File "/home/kang/Documents/work_code_PC1/VGG_tensorflow_UCMerced/readUClandUsedImagetxt.py", line 97, in _input_pipeline 
    crop_image = tf.image.resize_image_with_crop_or_pad(image, crop_size, crop_size) 

    File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/image_ops.py", line 534, in resize_image_with_crop_or_pad 
    _Check3DImage(image, require_static=True) 

    File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/image_ops.py", line 221, in _Check3DImage 
    raise ValueError('\'image\' must be fully defined.') 

ValueError: 'image' must be fully defined. 

が、私は知りませんが。 しかし、私はこのようなコードをテスト:

example = tf.image.decode_png(file_contents, channels=3) 
example = tf.reshape(example, [256,256,3]) 
crop_image = tf.image.resize_image_with_crop_or_pad(example, crop_size, crop_size) 

それは動作します。私は同じ形状に変形してもテンソルの値の順序は変わらないと思います、そうですか?多分それが解決策になるかもしれない。

答えて

1

問題は、あなたが方法tf.Tensor.set_shapeをオーバーライドし、値に設定している

example.set_shape = ([256,256,3]) 

ラインです。

example.set_shape([256,256,3]) 

その後、あなたのコードは動作します:

set_shape

は、このようにあなたはそれを適切に呼び出す必要があり、方法です。

I think reshape to the same shape does not change the order of values in Tensor, am I right?

はい、あなたは右

+0

ああです。どうもありがとうございました。それは愚かな間違いです... –

関連する問題