[英]TensorFlow MLP unhashable type 'list'
I'm trying to feed a MLP with an array. 我正在尝试为MLP提供数组。 The input array contains 120 floats and the output contains 2. 输入数组包含120个浮点数,输出包含2个。
sess.run(init)
# Training cycle
train = True
if train is True:
for i in range(50):
for letter in d1:
#print(letter[0][0][0:5])
letter[0][0][0:5] = sorted(letter[0][0][0:5], key=itemgetter(0))
letter[0][0][5:10] = sorted(letter[0][0][5:10], key=itemgetter(0))
#print(np.squeeze(np.asarray(d1[0])))
result=[]
for x in letter[0][0]:
for y in x:
result.append(y)
div = (result)
xxx = [letter[0][1][0], int(not letter[0][1][0])]
xxx = (xxx)
print(result)
#print(letter[1])
_, c = sess.run([optimizer, cost], feed_dict={x: div, y: xxx})
When executing the last line it throws the exception: 当执行最后一行时,它将引发异常:
Traceback (most recent call last):
File "tf.py", line 97, in <module>
_, c = sess.run([optimizer, cost], feed_dict={x: div, y: xxx})
TypeError: unhashable type: 'list'
I suppose you had at the beginning of your code two placeholder x
and y
: 我想您在代码的开头有两个占位符x
和y
:
x = tf.placeholder(tf.float32)
y = tf.placeholder(tf.float32)
The issue is that in your code, you use again the same name x
and y
for two variables: 问题是在代码中,您再次对两个变量使用了相同的名称x
和y
:
for x in letter[0][0]:
for y in x:
result.append(y)
This will erase the previous value of x
and y
. 这将删除x
和y
的先前值。
Instead, you should use other names like: 相反,您应该使用其他名称,例如:
for ix in letter[0][0]:
for iy in ix:
result.append(iy)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.