我是新来tensorflow和我有一个快速的问题,这是我的模式,为MNISTMNIST图像预测模型
def neural_network_model(data):
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 = {'weights': tf.Variable(tf.random_normal([n_nodes_hl3, n_classes])),
'biases': tf.Variable(tf.random_normal([n_classes])), }
l1 = tf.add(
tf.matmul(
data,
hidden_1_layer['weights']),
hidden_1_layer['biases'])
l1 = tf.nn.relu(l1)
l2 = tf.add(
tf.matmul(
l1,
hidden_2_layer['weights']),
hidden_2_layer['biases'])
l2 = tf.nn.relu(l2)
l3 = tf.add(
tf.matmul(
l2,
hidden_3_layer['weights']),
hidden_3_layer['biases'])
l3 = tf.nn.relu(l3)
output = tf.matmul(l3, output_layer['weights']) + output_layer['biases']
return output
我的问题是,这种功能代表了输入输出值“数据的代码'?或者这个函数代表了一个完整的模型,将用于测试/预测训练后的图像?
这里是我用于特定图像的预测的代码:
prediction=neural_network_model(mnist_training_data_set)
p=tf.argmax(prediction,1)
print(p.eval(feed_dict={x: i}, session=sess))
所以在这里我很困惑,即函数是否是一个模型或仅返回预测输出。任何人都可以解释,谢谢
此代码是否运行?你能以一种让我运行它的格式提供完整的代码吗? (例如Github) – finbarr
是的代码工作,但我的问题是关于模型制作 –
这个功能据说是训练模型以及输入图像的输出吗? –