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

tf.train.Saver() error in test.py #7

Open
zhixiaochuan12 opened this issue Apr 8, 2018 · 0 comments
Open

tf.train.Saver() error in test.py #7

zhixiaochuan12 opened this issue Apr 8, 2018 · 0 comments

Comments

@zhixiaochuan12
Copy link

zhixiaochuan12 commented Apr 8, 2018

python test.py --ws=4 --l2_reg=0.0004 --epoch=20 --max_len=40 --model_type=ABCNN3 --num_layers=2 --data_type=WebQA --classifier=LR

List of Variables:
CNN-1/aW:0
CNN-1/conv/weights:0
CNN-1/conv/biases:0
CNN-2/aW:0
CNN-2/conv/weights:0
CNN-2/conv/biases:0
output-layer/FC/weights:0
output-layer/FC/biases:0

==================================================
test data size: 10
2018-04-08 12:11:47.494259: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2018-04-08 12:11:47.494336: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2018-04-08 12:11:47.494347: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2018-04-08 12:11:47.494355: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2018-04-08 12:11:47.494364: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
Traceback (most recent call last):
File "/usr/local/lib/python3.4/site-packages/tensorflow/python/client/session.py", line 1139, in _do_call
return fn(*args)
File "/usr/local/lib/python3.4/site-packages/tensorflow/python/client/session.py", line 1121, in _run_fn
status, run_metadata)
File "/usr/local/lib/python3.4/contextlib.py", line 66, in exit
next(self.gen)
File "/usr/local/lib/python3.4/site-packages/tensorflow/python/framework/errors_impl.py", line 466, in raise_exception_on_not_ok_status
pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: Assign requires shapes of both tensors to match. lhs shape= [40,300] rhs shape= [96,300]
[[Node: save/Assign = Assign[T=DT_FLOAT, _class=["loc:@CNN-1/aW"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/cpu:0"](CNN-1/aW, save/RestoreV2)]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "test.py", line 147, in
classifier=params["classifier"], word2vec=params["word2vec"])
File "test.py", line 39, in test
saver.restore(sess, model_path + "-" + str(e))
File "/usr/local/lib/python3.4/site-packages/tensorflow/python/training/saver.py", line 1548, in restore
{self.saver_def.filename_tensor_name: save_path})
File "/usr/local/lib/python3.4/site-packages/tensorflow/python/client/session.py", line 789, in run
run_metadata_ptr)
File "/usr/local/lib/python3.4/site-packages/tensorflow/python/client/session.py", line 997, in _run
feed_dict_string, options, run_metadata)
File "/usr/local/lib/python3.4/site-packages/tensorflow/python/client/session.py", line 1132, in _do_run
target_list, options, run_metadata)
File "/usr/local/lib/python3.4/site-packages/tensorflow/python/client/session.py", line 1152, 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= [40,300] rhs shape= [96,300]
[[Node: save/Assign = Assign[T=DT_FLOAT, _class=["loc:@CNN-1/aW"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/cpu:0"](CNN-1/aW, save/RestoreV2)]]

Caused by op 'save/Assign', defined at:
File "test.py", line 147, in
classifier=params["classifier"], word2vec=params["word2vec"])
File "test.py", line 38, in test
saver = tf.train.Saver()
File "/usr/local/lib/python3.4/site-packages/tensorflow/python/training/saver.py", line 1139, in init
self.build()
File "/usr/local/lib/python3.4/site-packages/tensorflow/python/training/saver.py", line 1170, in build
restore_sequentially=self._restore_sequentially)
File "/usr/local/lib/python3.4/site-packages/tensorflow/python/training/saver.py", line 691, in build
restore_sequentially, reshape)
File "/usr/local/lib/python3.4/site-packages/tensorflow/python/training/saver.py", line 419, in _AddRestoreOps
assign_ops.append(saveable.restore(tensors, shapes))
File "/usr/local/lib/python3.4/site-packages/tensorflow/python/training/saver.py", line 155, in restore
self.op.get_shape().is_fully_defined())
File "/usr/local/lib/python3.4/site-packages/tensorflow/python/ops/state_ops.py", line 271, in assign
validate_shape=validate_shape)
File "/usr/local/lib/python3.4/site-packages/tensorflow/python/ops/gen_state_ops.py", line 45, in assign
use_locking=use_locking, name=name)
File "/usr/local/lib/python3.4/site-packages/tensorflow/python/framework/op_def_library.py", line 767, in apply_op
op_def=op_def)
File "/usr/local/lib/python3.4/site-packages/tensorflow/python/framework/ops.py", line 2506, in create_op
original_op=self._default_original_op, op_def=op_def)
File "/usr/local/lib/python3.4/site-packages/tensorflow/python/framework/ops.py", line 1269, in init
self._traceback = _extract_stack()

InvalidArgumentError (see above for traceback): Assign requires shapes of both tensors to match. lhs shape= [40,300] rhs shape= [96,300]
[[Node: save/Assign = Assign[T=DT_FLOAT, _class=["loc:@CNN-1/aW"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/cpu:0"](CNN-1/aW, save/RestoreV2)]]

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

1 participant