我有以下培训数据:
input -- output
1993,0,420,3,4,6 -- 1,0
1990,0,300,5,3,5 -- 0,1
1991,1,300,9,4,3 -- 0.5,0.5
...
因此有 6 输入图层和 2 输出图层,输出值可以是1,0 0,1或0.5,0.5
将此数据传递给tensorflow并训练NN的最简单方法是什么?
此时我还没有(还)对最好的网络架构感兴趣,我只是希望有一个Python脚本来训练NN。
谢谢!
答案 0 :(得分:0)
Guido,您可以使用此训练您的神经网络,此代码有一个隐藏层,您只需创建tf图
import tensorflow as tf
input_size = 6
output_size = 2
hidden_size = 6
input_y
input_data
with tf.variable_scope("hidden_Layer"):
weight = tf.truncated_normal([input_size, hidden_size], stddev=0.01)
bias = tf.constant(0.1, shape=[hidden_size])
hidden_input = tf.nn.bias_add(tf.matmul(input_data, weight), bias)
hidden_output = tf.nn.relu(hidden_input, name="Hidden_Output")
with tf.variable_scope("output_Layer"):
weight2 = tf.truncated_normal([hidden_size, output_size], stddev=0.01)
bias2 = tf.constant(0.1, shape=[output_size])
logits = tf.nn.bias_add(tf.matmul(hidden_output, weight2), bias2)
predictions = tf.argmax(logits, 1, name="predictions")
loss = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(logits=logits, labels=input_y))
correct_predictions = tf.equal(self.predictions, tf.argmax(input_y, 1))
classification_accuracy = tf.reduce_mean(tf.cast(correct_predictions, "float"), name="accuracy")