[英]Tensorflow Python - easiest way to create a NN from plain data (txt file)
我有以下訓練數據:
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
將數據傳遞到張量流並訓練NN的最簡單方法是什么?
目前,我對最佳的網絡體系結構不感興趣,我只是想擁有一個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")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.