1
# Import data
from tensorflow.examples.tutorials.mnist import input_data
import tensorflow as tf
mnist = input_data.read_data_sets('/tmp/tensorflow/mnist/input_data', one_hot=True)
# Create the model
x = tf.placeholder(tf.float32, [None, 784])
W = tf.Variable(tf.zeros([784, 10]))
b = tf.Variable(tf.zeros([10]))
k = tf.matmul(x, W) + b
y = tf.nn.softmax(k)
i = 0
# Define loss and optimizer
y_ = tf.placeholder(tf.float32, [None, 10])
learning_rate = 0.5
cost = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(k, y_))
train_step = tf.train.GradientDescentOptimizer(learning_rate).minimize(cost)
print ("Training")
sess = tf.Session()
init = tf.global_variables_initializer() #.run()
sess.run(init)
for _ in range(1000):
print(i)
batch_xs, batch_ys = mnist.train.next_batch(100)
print(i)
sess.run(train_step, feed_dict={x: batch_xs, y_: batch_ys})
print(i)
i=i+1
print ('b is ',sess.run(b))
print('W is',sess.run(W))
설명.
이것은 softmax를 사용하는 MNIST 코드입니다. for 루프의Tensorflow. 훈련 할 때 커널이 죽었습니다. 창 아나콘다
문제
sess.run ({: batch_xs, Y_ batch_ys X} train_step, feed_dict =)에 나타난다.
커널이 죽어서 오류 메시지와 함께 다시 시작됩니다. 코드가 다른 사람에게 잘 작동하기 때문에 문제가되지 않을 수도 있습니다.
저는 Windows10 Anaconda를 사용하고 있습니다.
무엇이 문제입니까?
"커널"에 대한 언급에서 Jupyter/IPython을 사용하는 것처럼 들립니다. 'python.exe'를 사용하여 직접 스크립트를 실행하면 더 좋은 오류 메시지를 포함하여 더 많은 정보를 얻을 수 있습니다. 그것을 시도하고 전체 오류 메시지를 게시 할 수 있습니까? – mrry