私はTFに迷惑メールだので、簡単に行く。TensorFlowエスティメータに入力パイプラインを渡す
ラベル付きのディレクトリにある一連の画像から簡単なCNNを訓練する必要があります。多くを見回した後、私はTF入力パイプラインを準備するこのコードを調理し、イメージアレイを印刷することができました。 TFのドキュメントに与えられた
image_list, label_list = load_dataset()
imagesq = ops.convert_to_tensor(image_list, dtype=dtypes.string)
labelsq = ops.convert_to_tensor(label_list, dtype=dtypes.int32)
# Makes an input queue
input_q = tf.train.slice_input_producer([imagesq, labelsq],
shuffle=True)
file_content = tf.read_file(input_q[0])
train_image = tf.image.decode_png(file_content,channels=3)
train_label = input_q[1]
train_image.set_shape([120,120,3])
# collect batches of images before processing
train_image_batch, train_label_batch = tf.train.batch(
[train_image, train_label],
batch_size=5
# ,num_threads=1
)
with tf.Session() as sess:
# initialize the variables
sess.run(tf.global_variables_initializer())
# initialize the queue threads to start to shovel data
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(coord=coord)
# print "from the train set:"
for i in range(len(image_list)):
print sess.run(train_image_batch)
# sess.run(train_image)
# sess.run(train_label)
# classifier.fit(input_fn=lambda: (train_image, train_label),
# steps=100,
# monitors=[logging_hook])
# stop our queue threads and properly close the session
coord.request_stop()
coord.join(threads)
sess.close()
しかしMNISTの例を見て、私は彼らが見積もりクラスと一緒に cnn_model_fn を使用して参照してください。
私は自分自身を定義しましたcnn_model_fn 2つを組み合わせたいと思います。これで前進する方法を教えてください。このコードは、
「は同じではありません、入力グラフおよびレイヤグラフ」それは、パイプラインがそうでなければ、その空に、セッションが実行された場合にのみ移入されると、それはとValueErrorを与えると思われる
classifier = learn.Estimator(model_fn=cnn_model_fn, model_dir='./test_model')
classifier.fit(input_fn=lambda: (train_image, train_label),
steps=100,
monitors=[logging_hook])
してください動作しません。助けて。