0

私はTensorflowを初めて使い、build_image_data.pyファイルとチュートリアルhereを使用しました。TFRecordファイルから正しくレコードを読み込めませんか?

私は自分のデータセットを2つのクラスで分類するために小さな畳み込みニューラルネットワークを構築しました。私のコードを実行したとき、私は形状変更に関連したエラーが発生しました。基本的には画像は72x72 RGBピクセルです。だから私が定義した形は[72, 72, 3]だった。私はInvalidArgumentError (see above for traceback): Input to reshape is a tensor with 14040 values, but the requested shape has 15552を得ていた。今私は72*72*3 = 15552と思った15552値でなければなりません。 14040しかなかった場合は、おそらく画像に何か問題がありますか?

私は自分で画像を撮ったり、Googleから取得したりして、すべての画像を72x72ピクセルにリサイズするためにJavaプログラムを使用しました。

私は画像がモデルに入ってきたときに画像を表示しようとしましたが、出力がなく、シャットダウンするまで何も表示されません。

sess = tf.InteractiveSession() 

filename = "../../dataset/traffic_sign/train-00000-of-00001" 

# convert filename to a queue for an input pipeline. 
filenameQ = tf.train.string_input_producer([filename], num_epochs=None) 

# OUTPUT = AttributeError: 'FIFOQueue' object has no attribute 'eval' 
print(filenameQ.eval()) 

# object to read records 
recordReader = tf.TFRecordReader() 

# read the full set of features for a single example 
key, fullExample = recordReader.read(filenameQ) 

# NO OUTPUT: program hangs 
print(fullExample.eval()) 

# parse the full example into its' component features. 
features = tf.parse_single_example(
fullExample, 
features={ 
    'image/height': tf.FixedLenFeature([], tf.int64), 
    'image/width': tf.FixedLenFeature([], tf.int64), 
    'image/colorspace': tf.FixedLenFeature([], dtype=tf.string, default_value=''), 
    'image/channels': tf.FixedLenFeature([], tf.int64), 
    'image/class/label': tf.FixedLenFeature([], tf.int64), 
    'image/class/text': tf.FixedLenFeature([], dtype=tf.string, default_value=''), 
    'image/format': tf.FixedLenFeature([], dtype=tf.string, default_value=''), 
    'image/filename': tf.FixedLenFeature([], dtype=tf.string, default_value=''), 
    'image/encoded': tf.FixedLenFeature([], dtype=tf.string, default_value='') 
}) 

# now we are going to manipulate the label and image features 

label = features['image/class/label'] 
image_buffer = features['image/encoded'] 

# Decode the jpeg 
with tf.name_scope('decode_jpeg', [image_buffer], None): 
# decode turns tensor of type string. 0-D the JPEG encoded image 
# to tensor of type uint8. 3-D with shape [height, width, channels] 
    image = tf.image.decode_jpeg(image_buffer, channels=3) 


image = tf.reshape(image, [HEIGHT, WIDTH, NUM_CHANNELS]) 
image = tf.to_float(image, "ToFloat") 

# re-define label as a "one-hot" vector 
# it will be [0,1] or [1,0] here. 
# This approach can easily be extended to more classes 
label = tf.one_hot(label - 1, NUM_CLASSES, dtype=tf.int64) 


init = tf.global_variables_initializer() 
sess.run(init) 
# NO OUTPUT: program hangs 
print(label.eval()) 

私はgostopを含むラベルファイルmylabels.txtで例hereに続いTFRecordファイルを作成したとき、私のディレクトリ構造は次のとおりです。

:私はコマンドを使用
traffic_sign/train/go/go*.jpeg 
traffic_sign/train/stop/stop*.jpeg 
traffic_sign/validation/go/go*.jpeg 
traffic_sign/validation/stop/stop*.jpeg 

python build_image_data.py --train_directory=./train --output_directory=./ \ 
--validation_directory=./validation --labels_file=mylabels.txt \ 
--train_shards=1 --validation_shards=1 --num_threads=1 

レコードファイルが作成され、多くのバイトが含まれています。

私はこれを解決する手がかりがありません。私がデータセットを作成する間違いをしたかどうかはわかりません。しかし、画像は72x72x3でなければならないので、私は14040の値で私のモデルにテンソルがあるのか​​分かりません。そして、私はテンソルを評価することができず、ちょうどハングするプログラムは私にデバッグを許さないという事実。 MUCH

答えて

0

を高く評価し

ヘルプそれは72x65だった私のデータセット内の不正な画像が故に14040結果...ありましたが判明しました。私は72x72の画像とその画像に置き換えました。

関連する問題