0
Tensorflowを使用して簡単なCNNを構築しようとしています。問題は、単純な.pngファイルをCNNに送ることができないということです。pngファイルを読み込み、cnnを送ります。Tensorflow
>>> filename = tf.constant("training/a1.png")
>>> filename
<tf.Tensor 'Const_1:0' shape=() dtype=string>
>>> image_string = tf.read_file(filename)
>>> image_string
<tf.Tensor 'ReadFile_1:0' shape=() dtype=string>
>>> image_decoded = tf.image.decode_png(image_string)
>>> image_decoded
<tf.Tensor 'DecodePng_1:0' shape=(?, ?, ?) dtype=uint8>
上記のコードのとおりです。 tf.image.decode_png(image_string)は、未知のテンソルの形状を返します。
ありがとうございましたvladimir-bystricky!わかった。他の人に役立つかもしれないコードはここにあります。
>>> import tensorflow as tf
>>> filename = tf.constant("training/a1.png")
>>> image_string = tf.read_file(filename)
>>> image_decoded = tf.image.decode_png(image_string)
>>> shape = tf.shape(image_decoded)
>>> sess = tf.Session()
>>> print(sess.run(shape))
[360 360 4]