20

私は TensorFlow を学習しようとしており、次のリンクから MNIST の例を実装しました: http://openmachin.es/blog/tensorflow-mnist トレーニング/テスト イメージを実際に表示できるようにしたいと考えています。だから私は最初のバッチの最初の列車の写真を表示するコードを追加しようとしています:

x_i = batch_xs[0]
image = tf.reshape(x_i,[28,28])

ここで、データは float32 型 ([0,1] の範囲の値) であるため、画像を表示するために uint16 に変換してから png にエンコードしようとしました。を使用してみtf.image.convert_image_dtype and tf.image.encode_pngましたが、成功しませんでした。生データを画像に変換して画像を表示する方法を教えてください。

4

6 に答える 6

15

チュートリアルを読んだ後、TF を必要とせずに numpy ですべてを実行できます。

import matplotlib.pyplot as plt
first_array=batch_xs[0]
#Not sure you even have to do that if you just want to visualize it
#first_array=255*first_array
#first_array=first_array.astype("uint8")
plt.imshow(first_array)
#Actually displaying the plot if you are not in interactive mode
plt.show()
#Saving plot
plt.savefig("fig.png")

また、PIL やその他の視覚化ツールを使用することもできます。

于 2016-07-11T13:45:32.563 に答える