2024-04-19 07:25:41 发布
网友
我有以下培训数据:
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,1或0.5,0.5
把这些数据传递给tensorflow和训练神经网络最简单的方法是什么?你知道吗
在这一点上,我对最好的网络体系结构不感兴趣,我只想有一个Python脚本来训练NN。你知道吗
谢谢!你知道吗
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")
Guido,你可以用这个训练你的神经网络,这个代码有一个隐藏层,你只需要创建tf图
相关问题 更多 >
编程相关推荐