在Python中访问字典会导致TypeError:无法散列的类型:'sl​​ice'

时间:2018-10-07 12:46:21

标签: python tensorflow

step = 0
batch_size = 128
iters = 2618730
while step * batch_size < iters:
    batch_x = train_data[(step * batch_size):((step+1) * batch_size)]
    batch_y = labels[(step * batch_size):((step+1) * batch_size)]
    sess.run(optimizer, feed_dict={x: batch_x, y: batch_y keep_prob: dropout})

在上面的代码段中,我试图以128的批次访问133 x 229498(以字典形式)的train_data,但是它抛出以下错误

batch_x = train_data[(step * size):((step+1) * size)]
TypeError: unhashable type: 'slice'

我正在使用Python 3.6

0 个答案:

没有答案