为什么我在张量流的占位符维度中出现错误?

时间:2018-12-28 12:49:07

标签: python-3.x tensorflow

我正在尝试创建一个神经网络。 这是我的神经网络设计

    num_channels=3
    filter_size_conv1=3
    filter_size_conv2=3
    filter_size_conv3=3
    num_filters_conv1=32
    num_filters_conv2=64
    num_filters_conv3=128
    num_classes=1
    img_size=196.0
    fc_layer_size=80000
    num_channelss=3.0
    #__________________Creating the MODEL______________________

    x = tf.placeholder(tf.float32, shape=[None, img_size,img_size,num_channelss], name="x_placeholder")

    y = tf.placeholder(tf.float32, shape=[None, num_classes], name="y_true")
    y_true_cls = tf.argmax(y, axis=1)



    #neural network Design
    layer_conv1 = create_convolutional_layer(input=x,num_input_channels=num_channels,conv_filter_size=filter_size_conv1,num_filters=num_filters_conv1,name="conv1")

layer_conv1_1 = create_convolutional_layer(input=layer_conv1,num_input_channels=num_filters_conv1,conv_filter_size=filter_size_conv1,num_filters=num_filters_conv1,name="conv2")

layer_conv1_1_1 = create_convolutional_layer(input=layer_conv1_1,num_input_channels=num_filters_conv1,conv_filter_size=filter_size_conv1,num_filters=num_filters_conv1,name="conv3")

max_pool_1=maxpool2d(layer_conv1_1_1,2,name="maxpool_1")

drop_out_1=dropout(max_pool_1,name="dropout_1")

flatten_layer=create_flatten_layer(drop_out_3)

layer_fc2 = create_fc_layer(input=flatten_layer,num_inputs=fc_layer_size,num_outputs=num_classes,use_relu=True)


y_pred = tf.nn.softmax(layer_fc2,name="y_pred")

cost = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits_v2(labels=y,logits=y_pred))

#Defining objective
train = tf.train.AdamOptimizer(learning_rate=0.00001).minimize(cost)


print ("_____Neural Network Architecture Created Succefully_____")
epochs=10
    matches = tf.equal(tf.argmax(y_pred,axis=1),tf.argmax(y,axis=1))
acc = tf.reduce_mean(tf.cast(matches,tf.float32))


#Initializing weights
init = tf.global_variables_initializer()

with tf.Session() as sess:
    #writing output to the logs for tensorboard 
    writer=tf.summary.FileWriter("./logs",sess.graph)
    sess.run(init)

    for i in range(epochs):
        #creating smaller batches

        for j in  range(0,steps-remaining,step_size):
            sess.run([acc,train,cost],feed_dict={x:X_train[j:j+step_size],y:y_train[j:j+step_size]})
  

现在我从 X_train 首先输入到模型的尺寸为(7,196,196,3)

X_train包含22张图像。

这是 错误跟踪:

InvalidArgumentError (see above for traceback): You must feed a value for placeholder tensor 'x_placeholder' with dtype float and shape [?,196,196,3]
     [[Node: x_placeholder = Placeholder[dtype=DT_FLOAT, shape=[?,196,196,3], _device="/job:localhost/replica:0/task:0/device:GPU:0"]()]]
     [[Node: Mean/_15 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_147_Mean", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]

我找不到错误,我正在输入正确的尺寸,仍然是错误。

0 个答案:

没有答案