stackflow解释
http://*.com/questions/4674473/valueerror-setting-an-array-element-with-a-sequence
原因是在把数据输入网络的时候列表的行数列数不匹配,比如
[[1,2], [2, [3, 4]]]
[[1,2], [2, 3, 4]]
而tensor必须要2*2或者3*3的输入才行
此时报错,只会报最后一行的错误,所以要注意有可能是前几行复制出现问题
File "main.py", line 49, in <module>
model.train(sess, batch, bag_train, sen_id, lpos, rpos, real_sen, namepos)
File "/home/apRE/model.py", line 225, in train
self.bag_seg: bag_seg
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 767, in run
run_metadata_ptr)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 938, in _run
np_val = np.asarray(subfeed_val, dtype=subfeed_dtype)
File "/usr/local/lib/python2.7/dist-packages/numpy/core/numeric.py", line 531, in asarray
return array(a, dtype, copy=False, order=order)
ValueError: setting an array element with a sequence.
对应的网络输入的语句是
sess.run(self.train_op, feed_dict={
self.input: batch,
self.mask: mask,
self.preds: preds,
self.wps1: wps_left,
self.wps2: wps_right,
self.bag_seg: bag_seg
})
就只会报错到最后一行,但实际上是mask那行出现了上述问题,以后需要注意。