InvalidArgumentError(请参见上面的回溯):重整形的输入是具有32个值的张量,但是请求的形有2个

时间:2018-06-20 22:44:05

标签: tensorflow neural-network python-3.6 convolutional-neural-network

with tf.name_scope('Model'):
#Convolutional Layer 1 + RELU
convo_1 = convolutional_layer(x,shape=[6,6,3,32])
#Pooling Layer 1
convo_1_pooling = max_pool_2by2(convo_1)
#Convolutional Layer 2 + RELU
convo_2 = convolutional_layer(convo_1_pooling,shape=[6,6,32,64])
#Pooling Layer 2
convo_2_pooling = max_pool_2by2(convo_2)
#Convolutional Layer 3 + RELU
convo_3 = convolutional_layer(convo_2_pooling,shape=[6,6,64,64])
#Pooling Layer 3
convo_3_pooling = max_pool_2by2(convo_3)
#Convolutional Layer 4 + RELU
convo_4 = convolutional_layer(convo_3_pooling,shape=[6,6,64,128])
#Pooling Layer 4
convo_4_pooling = max_pool_2by2(convo_4)
#Flattening
convo_4_flat = tf.reshape(convo_4_pooling,[-1,8*8*128])
#Fully Connected 1 + RELU
full_layer_one = tf.nn.relu(normal_full_layer(convo_4_flat,2048))
#Dropout Layer 1
hold_prob1 = tf.placeholder(tf.float32)
full_one_dropout = tf.nn.dropout(full_layer_one,keep_prob=hold_prob1)
#Fully Connected 1 + RELU
full_layer_two = tf.nn.relu(normal_full_layer(full_one_dropout,1024))
#Dropout Layer 1
hold_prob2 = tf.placeholder(tf.float32)
full_two_dropout = tf.nn.dropout(full_layer_two,keep_prob=hold_prob2)
#Output Layer,containing 2 output nodes.
y_pred = normal_full_layer(full_two_dropout,2)

with tf.Session() as sess:
sess.run(init)
summary_writer = tf.summary.FileWriter(DIR, graph=tf.get_default_graph())
for i in range(epochs):
    for j in range(0,steps,step_size):
        #Feeding step_size-amount data with 0.8 keeping probabilities on DROPOUT LAYERS
        _ , c , summary,d = sess.run([train,cross_entropy,merged_summary_op,acc],feed_dict={x:X[j:j+step_size] , y_true:Y[j:j+step_size] ,hold_prob1:0.8,hold_prob2:0.8})

我遇到错误 InvalidArgumentError(请参见上文以了解追溯信息):重塑的输入是具有32个值的张量,但请求的形状为2 我不知道为什么会这样。 代码参考:-https://github.com/MuhammedBuyukkinaci/TensorFlow-Binary-Image-Classification-using-CNN-s/blob/master/binary_image_classification_CPU.py

0 个答案:

没有答案