Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatible shapes: [20,1] vs. [80,1] #84

Open
pengcao opened this issue Aug 1, 2019 · 2 comments
Open

Incompatible shapes: [20,1] vs. [80,1] #84

pengcao opened this issue Aug 1, 2019 · 2 comments

Comments

@pengcao
Copy link

pengcao commented Aug 1, 2019

I am runing the code on tensoflow=1.12, but have a problem:
Traceback (most recent call last):
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\python\client\session.py", line 1334, in _do_call
return fn(*args)
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\python\client\session.py", line 1319, in _run_fn
options, feed_dict, fetch_list, target_list, run_metadata)
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\python\client\session.py", line 1407, in _call_tf_sessionrun
run_metadata)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Incompatible shapes: [20,1] vs. [80,1]
[[{{node prediction/logistic_loss/mul}} = Mul[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"](prediction/Squeeze, prediction/ToFloat)]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "F:/09.Practice/chatbot-deeplearning-retrieval/udc_train.py", line 72, in
tf.app.run()
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\python\platform\app.py", line 125, in run
_sys.exit(main(argv))
File "F:/09.Practice/chatbot-deeplearning-retrieval/udc_train.py", line 68, in main
estimator.fit(input_fn=input_fn_train, steps=None, monitors=[eval_monitor])
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\python\util\deprecation.py", line 488, in new_func
return func(*args, **kwargs)
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\contrib\learn\python\learn\estimators\estimator.py", line 525, in fit
loss = self._train_model(input_fn=input_fn, hooks=hooks)
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\contrib\learn\python\learn\estimators\estimator.py", line 1095, in _train_model
_, loss = mon_sess.run([model_fn_ops.train_op, model_fn_ops.loss])
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\python\training\monitored_session.py", line 671, in run
run_metadata=run_metadata)
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\python\training\monitored_session.py", line 1156, in run
run_metadata=run_metadata)
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\python\training\monitored_session.py", line 1255, in run
raise six.reraise(*original_exc_info)
File "C:\01.develop\tool\python3\lib\site-packages\six.py", line 693, in reraise
raise value
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\python\training\monitored_session.py", line 1240, in run
return self._sess.run(*args, **kwargs)
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\python\training\monitored_session.py", line 1320, in run
run_metadata=run_metadata))
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\contrib\learn\python\learn\monitors.py", line 1294, in after_run
induce_stop = m.step_end(self._last_step, result)
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\contrib\learn\python\learn\monitors.py", line 368, in step_end
return self.every_n_step_end(step, output)
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\contrib\learn\python\learn\monitors.py", line 753, in every_n_step_end
validation_outputs = self._evaluate_estimator()
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\contrib\learn\python\learn\monitors.py", line 718, in _evaluate_estimator
name=self.name)
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\python\util\deprecation.py", line 488, in new_func
return func(*args, **kwargs)
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\contrib\learn\python\learn\estimators\estimator.py", line 618, in evaluate
log_progress=log_progress)
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\contrib\learn\python\learn\estimators\estimator.py", line 940, in _evaluate_model
config=self._session_config)
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\python\training\evaluation.py", line 274, in _evaluate_once
session.run(eval_ops, feed_dict)
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\python\training\monitored_session.py", line 671, in run
run_metadata=run_metadata)
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\python\training\monitored_session.py", line 1156, in run
run_metadata=run_metadata)
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\python\training\monitored_session.py", line 1255, in run
raise six.reraise(*original_exc_info)
File "C:\01.develop\tool\python3\lib\site-packages\six.py", line 693, in reraise
raise value
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\python\training\monitored_session.py", line 1240, in run
return self._sess.run(*args, **kwargs)
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\python\training\monitored_session.py", line 1312, in run
run_metadata=run_metadata)
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\python\training\monitored_session.py", line 1076, in run
return self._sess.run(*args, **kwargs)
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\python\client\session.py", line 929, in run
run_metadata_ptr)
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\python\client\session.py", line 1152, in _run
feed_dict_tensor, options, run_metadata)
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\python\client\session.py", line 1328, in _do_run
run_metadata)
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\python\client\session.py", line 1348, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Incompatible shapes: [20,1] vs. [80,1]
[[node prediction/logistic_loss/mul (defined at F:\09.Practice\chatbot-deeplearning-retrieval\models\dual_encoder.py:87) = Mul[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"](prediction/Squeeze, prediction/ToFloat)]]

Caused by op 'prediction/logistic_loss/mul', defined at:
File "F:/09.Practice/chatbot-deeplearning-retrieval/udc_train.py", line 72, in
tf.app.run()
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\python\platform\app.py", line 125, in run
_sys.exit(main(argv))
File "F:/09.Practice/chatbot-deeplearning-retrieval/udc_train.py", line 68, in main
estimator.fit(input_fn=input_fn_train, steps=None, monitors=[eval_monitor])
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\python\util\deprecation.py", line 488, in new_func
return func(*args, **kwargs)
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\contrib\learn\python\learn\estimators\estimator.py", line 525, in fit
loss = self._train_model(input_fn=input_fn, hooks=hooks)
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\contrib\learn\python\learn\estimators\estimator.py", line 1095, in _train_model
_, loss = mon_sess.run([model_fn_ops.train_op, model_fn_ops.loss])
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\python\training\monitored_session.py", line 671, in run
run_metadata=run_metadata)
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\python\training\monitored_session.py", line 1156, in run
run_metadata=run_metadata)
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\python\training\monitored_session.py", line 1240, in run
return self._sess.run(*args, **kwargs)
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\python\training\monitored_session.py", line 1320, in run
run_metadata=run_metadata))
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\contrib\learn\python\learn\monitors.py", line 1294, in after_run
induce_stop = m.step_end(self._last_step, result)
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\contrib\learn\python\learn\monitors.py", line 368, in step_end
return self.every_n_step_end(step, output)
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\contrib\learn\python\learn\monitors.py", line 753, in every_n_step_end
validation_outputs = self._evaluate_estimator()
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\contrib\learn\python\learn\monitors.py", line 718, in _evaluate_estimator
name=self.name)
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\python\util\deprecation.py", line 488, in new_func
return func(*args, **kwargs)
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\contrib\learn\python\learn\estimators\estimator.py", line 618, in evaluate
log_progress=log_progress)
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\contrib\learn\python\learn\estimators\estimator.py", line 911, in _evaluate_model
model_fn_results = self._get_eval_ops(features, labels, metrics)
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\contrib\learn\python\learn\estimators\estimator.py", line 1293, in _get_eval_ops
model_fn_lib.ModeKeys.EVAL, metrics)
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\contrib\learn\python\learn\estimators\estimator.py", line 1228, in _call_model_fn
model_fn_results = self._model_fn(features, labels, **kwargs)
File "F:\09.Practice\chatbot-deeplearning-retrieval\udc_model.py", line 92, in model_fn
tf.concat(all_targets, 0))
File "F:\09.Practice\chatbot-deeplearning-retrieval\models\dual_encoder.py", line 87, in dual_encoder_model
losses = tf.nn.sigmoid_cross_entropy_with_logits(logits=logits, labels=tf.to_float(targets))
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\python\ops\nn_impl.py", line 181, in sigmoid_cross_entropy_with_logits
relu_logits - logits * labels,
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\python\ops\math_ops.py", line 866, in binary_op_wrapper
return func(x, y, name=name)
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\python\ops\math_ops.py", line 1131, in _mul_dispatch
return gen_math_ops.mul(x, y, name=name)
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\python\ops\gen_math_ops.py", line 5357, in mul
"Mul", x=x, y=y, name=name)
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 787, in _apply_op_helper
op_def=op_def)
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\python\util\deprecation.py", line 488, in new_func
return func(*args, **kwargs)
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\python\framework\ops.py", line 3274, in create_op
op_def=op_def)
File "C:\01.develop\tool\python3\lib\site-packages\tensorflow\python\framework\ops.py", line 1770, in init
self._traceback = tf_stack.extract_stack()

InvalidArgumentError (see above for traceback): Incompatible shapes: [20,1] vs. [80,1]
[[node prediction/logistic_loss/mul (defined at F:\09.Practice\chatbot-deeplearning-retrieval\models\dual_encoder.py:87) = Mul[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"](prediction/Squeeze, prediction/ToFloat)]]

@Alice1222518
Copy link

I have the same problem, have you solved it?

@xjy233
Copy link

xjy233 commented May 29, 2020

I have the same problem, have you solved it?

you can set tf.flags.DEFINE_integer("eval_batch_size", 1, "Batch size during evaluation") in udc_hparams.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants