Assign requires shapes of both tensors to match. lhs shape= [3072] rhs shape= [4096]
[[node save/Assign_95 (defined at /home/psharma/.local/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/estimator.py:627) ]]
Caused by op 'save/Assign_95', defined at:
File "run_classifier.py", line 981, in <module>
tf.app.run()
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 125, in run
_sys.exit(main(argv))
File "run_classifier.py", line 963, in main
for (i, prediction) in enumerate(result):
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/contrib/tpu/python/tpu/tpu_estimator.py", line 2494, in predict
yield_single_examples=yield_single_examples):
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 627, in predict
hooks=all_hooks) as mon_sess:
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/monitored_session.py", line 934, in __init__
stop_grace_period_secs=stop_grace_period_secs)
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/monitored_session.py", line 648, in __init__
self._sess = _RecoverableSession(self._coordinated_creator)
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/monitored_session.py", line 1122, in __init__
_WrappedSession.__init__(self, self._create_session())
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/monitored_session.py", line 1127, in _create_session
return self._sess_creator.create_session()
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/monitored_session.py", line 805, in create_session
self.tf_sess = self._session_creator.create_session()
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/monitored_session.py", line 562, in create_session
self._scaffold.finalize()
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/monitored_session.py", line 217, in finalize
self._saver = training_saver._get_saver_or_default() # pylint: disable=protected-access
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 604, in _get_saver_or_default
saver = Saver(sharded=True, allow_empty=True)
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 832, in __init__
self.build()
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 844, in build
self._build(self._filename, build_save=True, build_restore=True)
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 881, in _build
build_save=build_save, build_restore=build_restore)
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 507, in _build_internal
restore_sequentially, reshape)
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 385, in _AddShardedRestoreOps
name="restore_shard"))
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 354, in _AddRestoreOps
assign_ops.append(saveable.restore(saveable_tensors, shapes))
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/saving/saveable_object_util.py", line 73, in restore
self.op.get_shape().is_fully_defined())
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/ops/state_ops.py", line 223, in assign
validate_shape=validate_shape)
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/ops/gen_state_ops.py", line 64, in assign
use_locking=use_locking, name=name)
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 788, in _apply_op_helper
op_def=op_def)
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 507, in new_func
return func(*args, **kwargs)
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3300, in create_op
op_def=op_def)
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1801, in __init__
self._traceback = tf_stack.extract_stack()
InvalidArgumentError (see above for traceback): Restoring from checkpoint failed. This is most likely due to a mismatch between the current graph and the graph from the checkpoint. Please ensure that you have not altered the graph expected based on the checkpoint. Original error:
Assign requires shapes of both tensors to match. lhs shape= [3072] rhs shape= [4096]
[[node save/Assign_95 (defined at /home/psharma/.local/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/estimator.py:627) ]]
INFO:tensorflow:prediction_loop marked as finished
WARNING:tensorflow:Reraising captured error
Traceback (most recent call last):
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1334, in _do_call
return fn(*args)
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1319, in _run_fn
options, feed_dict, fetch_list, target_list, run_metadata)
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1407, in _call_tf_sessionrun
run_metadata)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Assign requires shapes of both tensors to match. lhs shape= [3072] rhs shape= [4096]
[[{{node save/Assign_95}}]]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1276, in restore
{self.saver_def.filename_tensor_name: save_path})
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 929, in run
run_metadata_ptr)
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1152, in _run
feed_dict_tensor, options, run_metadata)
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1328, in _do_run
run_metadata)
File "/home/psharma/.local/lib/python3.6/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: Assign requires shapes of both tensors to match. lhs shape= [3072] rhs shape= [4096]
[[node save/Assign_95 (defined at /home/psharma/.local/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/estimator.py:627) ]]
Caused by op 'save/Assign_95', defined at:
File "run_classifier.py", line 981, in <module>
tf.app.run()
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 125, in run
_sys.exit(main(argv))
File "run_classifier.py", line 963, in main
for (i, prediction) in enumerate(result):
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/contrib/tpu/python/tpu/tpu_estimator.py", line 2494, in predict
yield_single_examples=yield_single_examples):
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 627, in predict
hooks=all_hooks) as mon_sess:
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/monitored_session.py", line 934, in __init__
stop_grace_period_secs=stop_grace_period_secs)
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/monitored_session.py", line 648, in __init__
self._sess = _RecoverableSession(self._coordinated_creator)
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/monitored_session.py", line 1122, in __init__
_WrappedSession.__init__(self, self._create_session())
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/monitored_session.py", line 1127, in _create_session
return self._sess_creator.create_session()
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/monitored_session.py", line 805, in create_session
self.tf_sess = self._session_creator.create_session()
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/monitored_session.py", line 562, in create_session
self._scaffold.finalize()
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/monitored_session.py", line 217, in finalize
self._saver = training_saver._get_saver_or_default() # pylint: disable=protected-access
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 604, in _get_saver_or_default
saver = Saver(sharded=True, allow_empty=True)
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 832, in __init__
self.build()
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 844, in build
self._build(self._filename, build_save=True, build_restore=True)
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 881, in _build
build_save=build_save, build_restore=build_restore)
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 507, in _build_internal
restore_sequentially, reshape)
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 385, in _AddShardedRestoreOps
name="restore_shard"))
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 354, in _AddRestoreOps
assign_ops.append(saveable.restore(saveable_tensors, shapes))
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/saving/saveable_object_util.py", line 73, in restore
self.op.get_shape().is_fully_defined())
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/ops/state_ops.py", line 223, in assign
validate_shape=validate_shape)
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/ops/gen_state_ops.py", line 64, in assign
use_locking=use_locking, name=name)
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 788, in _apply_op_helper
op_def=op_def)
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 507, in new_func
return func(*args, **kwargs)
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3300, in create_op
op_def=op_def)
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1801, in __init__
self._traceback = tf_stack.extract_stack()
InvalidArgumentError (see above for traceback): Assign requires shapes of both tensors to match. lhs shape= [3072] rhs shape= [4096]
[[node save/Assign_95 (defined at /home/psharma/.local/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/estimator.py:627) ]]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "run_classifier.py", line 981, in <module>
tf.app.run()
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 125, in run
_sys.exit(main(argv))
File "run_classifier.py", line 963, in main
for (i, prediction) in enumerate(result):
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/contrib/tpu/python/tpu/tpu_estimator.py", line 2500, in predict
rendezvous.raise_errors()
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/contrib/tpu/python/tpu/error_handling.py", line 128, in raise_errors
six.reraise(typ, value, traceback)
File "/home/psharma/.local/lib/python3.6/site-packages/six.py", line 693, in reraise
raise value
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/contrib/tpu/python/tpu/tpu_estimator.py", line 2494, in predict
yield_single_examples=yield_single_examples):
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 627, in predict
hooks=all_hooks) as mon_sess:
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/monitored_session.py", line 934, in __init__
stop_grace_period_secs=stop_grace_period_secs)
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/monitored_session.py", line 648, in __init__
self._sess = _RecoverableSession(self._coordinated_creator)
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/monitored_session.py", line 1122, in __init__
_WrappedSession.__init__(self, self._create_session())
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/monitored_session.py", line 1127, in _create_session
return self._sess_creator.create_session()
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/monitored_session.py", line 805, in create_session
self.tf_sess = self._session_creator.create_session()
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/monitored_session.py", line 571, in create_session
init_fn=self._scaffold.init_fn)
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/session_manager.py", line 281, in prepare_session
config=config)
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/session_manager.py", line 195, in _restore_checkpoint
saver.restore(sess, checkpoint_filename_with_path)
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1312, in restore
err, "a mismatch between the current graph and the graph")
tensorflow.python.framework.errors_impl.InvalidArgumentError: Restoring from checkpoint failed. This is most likely due to a mismatch between the current graph and the graph from the checkpoint. Please ensure that you have not altered the graph expected based on the checkpoint. Original error:
Assign requires shapes of both tensors to match. lhs shape= [3072] rhs shape= [4096]
[[node save/Assign_95 (defined at /home/psharma/.local/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/estimator.py:627) ]]
Caused by op 'save/Assign_95', defined at:
File "run_classifier.py", line 981, in <module>
tf.app.run()
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 125, in run
_sys.exit(main(argv))
File "run_classifier.py", line 963, in main
for (i, prediction) in enumerate(result):
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/contrib/tpu/python/tpu/tpu_estimator.py", line 2494, in predict
yield_single_examples=yield_single_examples):
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 627, in predict
hooks=all_hooks) as mon_sess:
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/monitored_session.py", line 934, in __init__
stop_grace_period_secs=stop_grace_period_secs)
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/monitored_session.py", line 648, in __init__
self._sess = _RecoverableSession(self._coordinated_creator)
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/monitored_session.py", line 1122, in __init__
_WrappedSession.__init__(self, self._create_session())
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/monitored_session.py", line 1127, in _create_session
return self._sess_creator.create_session()
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/monitored_session.py", line 805, in create_session
self.tf_sess = self._session_creator.create_session()
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/monitored_session.py", line 562, in create_session
self._scaffold.finalize()
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/monitored_session.py", line 217, in finalize
self._saver = training_saver._get_saver_or_default() # pylint: disable=protected-access
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 604, in _get_saver_or_default
saver = Saver(sharded=True, allow_empty=True)
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 832, in __init__
self.build()
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 844, in build
self._build(self._filename, build_save=True, build_restore=True)
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 881, in _build
build_save=build_save, build_restore=build_restore)
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 507, in _build_internal
restore_sequentially, reshape)
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 385, in _AddShardedRestoreOps
name="restore_shard"))
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 354, in _AddRestoreOps
assign_ops.append(saveable.restore(saveable_tensors, shapes))
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/training/saving/saveable_object_util.py", line 73, in restore
self.op.get_shape().is_fully_defined())
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/ops/state_ops.py", line 223, in assign
validate_shape=validate_shape)
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/ops/gen_state_ops.py", line 64, in assign
use_locking=use_locking, name=name)
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 788, in _apply_op_helper
op_def=op_def)
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 507, in new_func
return func(*args, **kwargs)
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3300, in create_op
op_def=op_def)
File "/home/psharma/.local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1801, in __init__
self._traceback = tf_stack.extract_stack()
InvalidArgumentError (see above for traceback): Restoring from checkpoint failed. This is most likely due to a mismatch between the current graph and the graph from the checkpoint. Please ensure that you have not altered the graph expected based on the checkpoint. Original error:
Assign requires shapes of both tensors to match. lhs shape= [3072] rhs shape= [4096]
[[node save/Assign_95 (defined at /home/psharma/.local/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/estimator.py:627) ]]
3条答案
按热度按时间hjqgdpho1#
当运行README.md中的预测示例时
ippsafx72#
我遇到了类似的问题。我正在使用另一个具有二分类的数据集,但我一直收到这个错误:
Assign需要两个Tensor的形状匹配。
3duebb1j3#
你们有没有找到解决这个问题的方法?