Forex.csv:
AlAin,Y1,Y2,Y3,Y4,Y5,Y6,K,1,2,3,4,5,6,d
1,0,0,1,0,0,0,0,0,0,1,0,0,0,1
коды прогнозирующей части искусственной нейронной сети:
with tf.Session() as sess:
predictdataset=pd.read_csv('predict.csv')
y_predict=(sess.run(tf.argmax(y4.eval(feed_dict={x:[predictdataset]}),1)))
print(y_predict)
Я получаю ошибку «KeyError: 0».
предыдущие коды для обучения и тестирования
x = tf.placeholder (tf.float32, [None, 15]) y = tf.placeholder (tf.float32, [None, 1])
layer_1=128
layer_2=64
layer_3=32
layer_out=1
weight_1 = tf.Variable(tf.truncated_normal([15, layer_1], stddev=0.1))
bias_1 = tf.Variable(tf.constant(0.1, shape=[layer_1]))
weight_2 = tf.Variable(tf.truncated_normal([layer_1, layer_2], stddev=0.1))
bias_2 = tf.Variable(tf.constant(0.1, shape=[layer_2]))
weight_3 = tf.Variable(tf.truncated_normal([layer_2, layer_3], stddev=0.1))
bias_3 = tf.Variable(tf.constant(0.1, shape=[layer_3]))
weight_4 = tf.Variable(tf.truncated_normal([layer_3, layer_out], stddev=0.1))
bias_4 = tf.Variable(tf.constant(0.1, shape=[layer_out]))
y1=tf.nn.relu(tf.matmul(x,weight_1)+bias_1)
y2=tf.nn.relu(tf.matmul(y1,weight_2)+bias_2)
y3=tf.nn.relu(tf.matmul(y2,weight_3)+bias_3)
logits=tf.matmul(y3,weight_4)+bias_4
y4=tf.nn.softmax(logits)
xent = tf.nn.softmax_cross_entropy_with_logits(logits=logits, labels=y)
loss = tf.reduce_mean(xent)
correct_prediction = tf.equal(tf.argmax(y4, 1), tf.argmax(y, 1))
accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32)) # Başarı oranı
optimize = tf.train.AdamOptimizer(0.001). minimize(loss)
sess = tf.Session()
sess.run(tf.global_variables_initializer())