当我尝试用Tensorflow训练CNN方法时,我得到了这个错误:
Traceback (most recent call last):
File "./train.py", line 87, in
l2_reg_lambda=FLAGS.l2_reg_lambda)
TypeError: Expected int32, got list containing Tensors of type '_Message' instead.我怎么才能修复它?
这是我的代码:
with tf.Graph().as_default():
session_conf = tf.ConfigProto(
allow_soft_placement=FLAGS.allow_soft_placement,
log_device_placement=FLAGS.log_device_placement)
sess = tf.Session(config=session_conf)
with sess.as_default():
cnn = TextCNN(
sequence_length=x_train.shape[1],
num_classes=2,
vocab_size=len(vocab_processor.vocabulary_),
embedding_size=FLAGS.embedding_dim,
filter_sizes=list(map(int, FLAGS.filter_sizes.split(","))),
num_filters=FLAGS.num_filters,
l2_reg_lambda=FLAGS.l2_reg_lambda) (line 87)发布于 2017-09-07 13:54:35
x_train.shape[1]返回一个Tensor,它的值直到sess.run()才会被计算出来,所以你应该传递一个int32值而不是shape1。
https://stackoverflow.com/questions/46088602
复制相似问题