python - InvalidArgumentError: <unprintable InvalidArgumentError object> -
i meet invalidargumenterror in tensorflow,following code:
for batch_idx in xrange(batch_count): xs_, ys_ = batches_data[batch_idx], batches_labels[batch_idx] print np.shape(xs_),np.shape(ys_) batch_res = session.run([ train_step, cross_entropy, accuracy ], feed_dict = { xs: xs_, ys: ys_, lr: learning_rate, is_training: true, keep_prob: 0.8 })
the train_step, cross_entropy, accuracy ops like
ys_ = tf.nn.softmax( tf.matmul(current, wfc) + bfc cross_entropy = -tf.reduce_mean(ys * tf.log(ys_ + 1e-12)) l2 = tf.add_n([tf.nn.l2_loss(var) var in tf.trainable_variables()]) train_step = tf.train.momentumoptimizer(lr, 0.9, use_nesterov=true).minimize(cross_entropy + l2 * weight_decay) correct_prediction = tf.equal(tf.argmax(ys_, 1), tf.argmax(ys, 1)) accuracy = tf.reduce_mean(tf.cast(correct_prediction, "float"))
but:
train: (3154, 200, 100, 1) (3154, 3) test: (99, 200, 100, 1) (99, 3) batch per epoch: 788 (4, 200, 100, 1) (4, 3) traceback (most recent call last):
file "<ipython-input-20-e1d54884a028>", line 1, in <module> runfile('/home/zhao/文档/gl/densenet.py', wdir='/home/zhao/文档/gl') file "/home/zhao/anaconda2/lib/python2.7/site-packages/spyder/utils/site/sitecustomize.py",
line 866, in runfile execfile(filename, namespace)
file "/home/zhao/anaconda2/lib/python2.7/site-packages/spyder/utils/site/sitecustomize.py",
line 94, in execfile builtins.execfile(filename, *where)
file "/home/zhao/文档/gl/densenet.py", line 164, in <module> run() file "/home/zhao/文档/gl/densenet.py", line 162, in run run_model(data, image_h, image_w, channel, label_count, 40) file "/home/zhao/文档/gl/densenet.py", line 126, in run_model feed_dict = { xs: xs_, ys: ys_, lr: learning_rate, is_training: true, keep_prob: 0.8 }) file "/home/zhao/anaconda2/lib/python2.7/site-packages/tensorflow/python/client/session.py",
line 789, in run run_metadata_ptr)
file "/home/zhao/anaconda2/lib/python2.7/site-packages/tensorflow/python/client/session.py",
line 997, in _run feed_dict_string, options, run_metadata)
file "/home/zhao/anaconda2/lib/python2.7/site-packages/tensorflow/python/client/session.py",
line 1132, in _do_run target_list, options, run_metadata)
file "/home/zhao/anaconda2/lib/python2.7/site-packages/tensorflow/python/client/session.py",
line 1152, in _do_call raise type(e)(node_def, op, message)
invalidargumenterror: <unprintable invalidargumenterror object>
the placeholder define following:
xs = tf.placeholder("float", shape=[none, 200,100,1]) ys = tf.placeholder("float", shape=[none, 3]) lr = tf.placeholder("float", shape=[]) keep_prob = tf.placeholder(tf.float32) is_training = tf.placeholder("bool", shape=[])
looks nothing wrong, how can fix it? thx!
Comments
Post a Comment