我试图实现一个神经网络来解决分类问题,但是我的程序:
_, c = sess.run([train_op, loss_op], feed_dict={X: x_train,Y: y_train})
我试图重塑数据并尝试了堆栈中给出的许多解决方案来解决我的问题,但对我不起作用,我想知道我该怎么办?
最重要的部分:
...
n_output = 8
n_input = 9 # Max number of input that may have features of one single program
################################ Dfine data ####################################
from google.colab import files
import io
uploaded = files.upload()
x_train_ = pd.read_csv(io.StringIO(uploaded['x_train.csv'].decode('utf-8')), skiprows=1, header=None)
uploaded1 = files.upload()
y_train_ = pd.read_csv(io.StringIO(uploaded1['y_train.csv'].decode('utf-8')), skiprows=1, header=None)
x_train.fillna(-1, inplace=True)
x_train = np.array(x_train)
y_train = np.array(y_train)
################################ Input, weights, biases ########################
# tf Graph input
X = tf.placeholder(shape=[None, n_input], dtype=tf.float32)
Y = tf.placeholder(shape=[None, n_output], dtype=tf.float32)
.....
################################ Construct model ###############################
logits = multilayer_perceptron(X)
# Define loss and optimizer
loss_op = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(logits=logits, labels=Y))
optimizer = tf.train.AdamOptimizer(learning_rate=learning_rate)
train_op = optimizer.minimize(loss_op)
...
# Initializing the variables
init = tf.global_variables_initializer()
with tf.Session() as sess:
sess.run(init)
# Training cycle
for epoch in range(training_epochs):
avg_cost = 0.
_, c = sess.run([train_op, loss_op], feed_dict={X: x_train,Y: y_train})
...
print("Optimization Finished!")
编辑:一旦我打印出来:print(y_train_.head()) 它给出:
0
0 2
1 4
2 8
3 16
4 32
翻阅古今
拉丁的传说
相关分类