我正在尝试学习Tensor Flow,所以我通过https://pythonprogramming.net/tensorflow-neural-network-session-machine-learning-tutorial/关注了神经网络的教程.
我正在尝试运行代码,但即使我的尺寸看起来正确,也要保持相同的尺寸错误.
我是Tensor Flow的新手,所以我不确定我做错了什么.
我会发布代码和错误.
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("/tmp/data/", one_hot=True)
n_nodes_hl1 = 500
n_nodes_hl2 = 500
n_nodes_hl3 = 500
n_classes = 10
batch_size = 100
x = tf.placeholder('float', [None,784])
y = tf.placeholder('float')
def neural_network_model(data):
#(input_data * weights) + biases
hidden_1_layer = {
'weights' : tf.Variable(tf.random_normal([784,n_nodes_hl1])),
'biases' : tf.Variable(tf.random_normal([n_nodes_hl1]))
}
hidden_2_layer = {
'weights' : tf.Variable(tf.random_normal([n_nodes_hl1,n_nodes_hl2])),
'biases' : tf.Variable(tf.random_normal([n_nodes_hl2]))
}
hidden_3_layer = {
'weights' : tf.Variable(tf.random_normal([n_nodes_hl2,n_nodes_hl3])),
'biases' : tf.Variable(tf.random_normal([n_nodes_hl3]))
}
output_layer …Run Code Online (Sandbox Code Playgroud)