笔者仅为深度学习与tensorflow小白,该系列文章仅为记录自己的学习历程并帮助自己或如笔者一般的初学者入门与回忆相关的知识点。如有疏漏,请大家提点,待笔者学习修正。
神经网络的组成主要分为读取训练样本,前向传播模型、后向传播与训练。本文旨在记录如何使用tensorflow读取自己的图像,同时记录出现的问题与解决方法。
<pre>
import matplotlib.pyplot as plt
import tensorflow as tf
image_contents=tf.read_file("a.jpg")
image = tf.image.decode_jpeg(image_contents, channels=3)
with tf.Session() as sess:
print(type(img_contents)) # bytes
print(type(image)) # Tensor
print(type(image.eval())) # ndarray
print(image.eval().shape)#(240,320,3)
print(image.eval().dtype)#uint8
plt.figure(1)
plt.imshow(image.eval())
plt.show()
<pre>
网友评论