我学习机器学习,所以我在编写关于批处理的练习样本 不久我就会出现此错误。
我的代码是这个。
import tensorflow as tf
filename_queue = tf.train.string_input_producer(['C:\\Users\\조시내\\Desktop\\data-01-test-score.csv'], shuffle=False, name='fliename_queue')
reader = tf.TextLineReader()
key, value = reader.read(filename_queue)
record_defaults = [[0.], [0.], [0.], [0.]]
xy = tf.decode_csv(value, record_defaults=record_defaults)
train_x_batch, train_y_batch = tf.train.batch([xy[0:-1], xy[-1:]], batch_size=10)
x = tf.placeholder(tf.float32, shape=[None, 3])
y = tf.placeholder(tf.float32, shape=[None, 1])
w = tf.Variable(tf.random_normal([3,1]), name='weight')
b = tf.Variable(tf.random_normal([1]),name='bias')
hypothesis = tf.matmul(x, w) + b
cost = tf.reduce_mean(tf.square(hypothesis - y))
optimizer = tf.train.GradientDescentOptimizer(learning_rate=1e-5)
train = optimizer.minimize(cost)
sess = tf.Session()
sess.run(tf.global_variables_initializer())
coord =tf.train.Coordinator()
threads = tf.train.start_queue_runners(sess=sess, coord=coord)
for step in range(2001):
x_batch, y_batch = sess.run([train_x_batch, train_y_batch])
cost_val, hy_val, _ = sess.run([cost, hypothesis,train],feed_dict={x: x_batch, y: y_batch})
if step % 10 == 0:
print(step, "cost: ", cost_val, "\nprediction:\n", hy_val)
coord.request_stop()
coord.join(threads)
错误1)回调BaseAsyncIOLoop._handle_events(1052,1)中的异常 处理:
错误2)UnicodeEncodeError:'utf-8'编解码器无法在位置237中编码字符'\ udcc6':不允许替代 回调BaseAsyncIOLoop._handle_events(1052,1)中的异常
错误3)OutOfRangeError:FIFOQueue'_1_batch / fifo_queue'已关闭且元素不足(要求10,当前大小为0) [[节点:批处理= QueueDequeueManyV2 [component_types = [DT_FLOAT,DT_FLOAT],timeout_ms = -1,_device =“ / job:localhost /副本:0 /任务:0 / cpu:0”]](批处理/ fifo_queue,批处理/ n )]]
在处理上述异常期间,发生了另一个异常: