I am trying to understand about why I can't train my network model but I couldn't. I will be very appreciated if you could help me to solve this issue.
我试图理解为什么我不能训练我的网络模型,但我不能。如果你能帮助我解决这个问题,我将非常感激。
I already read my image data (600), resized (14x14) and normalize it. Also, I created my onehot_encoding in my code.
我已经读过我的图像数据(600),调整大小(14x14)并将其标准化。另外,我在我的代码中创建了onehot_encoding。
My "img_data" variable in the code has normalized 600 images (14x14 size of each image) and "labels_training" variable has 600 (each label has 10 binary number) labeled onehot_encoding. I am expecting that tf.train.batch() should return (50, 196) and (50,10) but it returns:
我在代码中的“img_data”变量已经规范化了600个图像(每个图像的大小为14x14),“labels_training”变量具有600个(每个标签具有10个二进制数),标记为onehot_encoding。我期待tf.train.batch()应该返回(50,196)和(50,10),但它返回:
Tensor("batch_31:0", shape=(50, 600, 196), dtype=float32) for X_truth Tensor("batch_31:1", shape=(50, 600, 10), dtype=float32) for X_label
对于X_label,X_truth Tensor(“batch_31:1”,shape =(50,600,10),dtype = float32)的Tensor(“batch_31:0”,shape =(50,600,196),dtype = float32)
Why does tf.train.batch() function returns 3 values (50, 600, 196) and (50, 600, 10)?
为什么tf.train.batch()函数返回3个值(50,600,196)和(50,600,10)?
Also, when I try .eval() for X_truth and X_label, it never ends.
此外,当我为X_truth和X_label尝试.eval()时,它永远不会结束。
epochs = 12
print("Start to train")
sess = tf.InteractiveSession()
tf.global_variables_initializer().run()
for _ in range(1000):
tf.train.start_queue_runners(sess=sess)
for i in range(epochs):
print("Epoch ", i)
X_truth, X_label = tf.train.batch([img_data, labels_training],batch_size=50)
x_input=X_truth.eval()
y_input=X_label.eval()
sess.run(train_step, feed_dict={x: x_input, y_: y_input})
Many many thanks for the help.
很多人都感谢你的帮助。
1 个解决方案
#1
0
From Tensorflow documentation https://www.tensorflow.org/api_docs/python/tf/train/batch
来自Tensorflow文档https://www.tensorflow.org/api_docs/python/tf/train/batch
If enqueue_many is False, tensors is assumed to represent a single example. An input tensor with shape [x, y, z] will be output as a tensor with shape [batch_size, x, y, z].
如果enqueue_many为False,则假定张量代表单个示例。具有形状[x,y,z]的输入张量将被输出为具有形状[batch_size,x,y,z]的张量。
enqueue_many
is False by default
enqueue_many默认为False
#1
0
From Tensorflow documentation https://www.tensorflow.org/api_docs/python/tf/train/batch
来自Tensorflow文档https://www.tensorflow.org/api_docs/python/tf/train/batch
If enqueue_many is False, tensors is assumed to represent a single example. An input tensor with shape [x, y, z] will be output as a tensor with shape [batch_size, x, y, z].
如果enqueue_many为False,则假定张量代表单个示例。具有形状[x,y,z]的输入张量将被输出为具有形状[batch_size,x,y,z]的张量。
enqueue_many
is False by default
enqueue_many默认为False