show-attend-and-tell
show-attend-and-tell copied to clipboard
Assign requires shapes of both tensors to match
I am trying to run the script and am keep getting this error.
InvalidArgumentError (see above for traceback): Assign requires shapes of both tensors to match. lhs shape= [1500] rhs shape= [1024] [[Node: save/Assign_8 = Assign[T=DT_FLOAT, _class=["loc:@initial_lstm/b_h"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/device:GPU:0"](initial_lstm/b_h, save/RestoreV2/_33)]]
I am wondering if I did something wrong on install or if the data files did not download, unzip, or pre-process properly but this is the only error i get even when trashing the whole data file and starting over.
Thanks in advance for any help.
INFO:tensorflow:Restoring parameters from ./model/lstm/model-18
InvalidArgumentError Traceback (most recent call last)
/data/raid_ssd/Show_Attend_and_Tell/show-attend-and-tell-tensorflow/core/solver.pyc in test(self, data, split, attention_visualization, save_sampled_captions) 202 with tf.Session(config=config) as sess: 203 saver = tf.train.Saver() --> 204 saver.restore(sess, self.test_model) 205 features_batch, image_files = sample_coco_minibatch(data, self.batch_size) 206 feed_dict = { self.model.features: features_batch }
/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.pyc in restore(self, sess, save_path) 1800 else: 1801 sess.run(self.saver_def.restore_op_name, -> 1802 {self.saver_def.filename_tensor_name: save_path}) 1803 1804 @staticmethod
/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.pyc in run(self, fetches, feed_dict, options, run_metadata) 898 try: 899 result = self._run(None, fetches, feed_dict, options_ptr, --> 900 run_metadata_ptr) 901 if run_metadata: 902 proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)
/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.pyc in _run(self, handle, fetches, feed_dict, options, run_metadata) 1133 if final_fetches or final_targets or (handle and feed_dict_tensor): 1134 results = self._do_run(handle, final_targets, final_fetches, -> 1135 feed_dict_tensor, options, run_metadata) 1136 else: 1137 results = []
/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.pyc in _do_run(self, handle, target_list, fetch_list, feed_dict, options, run_metadata) 1314 if handle is None: 1315 return self._do_call(_run_fn, feeds, fetches, targets, options, -> 1316 run_metadata) 1317 else: 1318 return self._do_call(_prun_fn, handle, feeds, fetches)
/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.pyc in _do_call(self, fn, *args) 1333 except KeyError: 1334 pass -> 1335 raise type(e)(node_def, op, message) 1336 1337 def _extend_graph(self):
InvalidArgumentError: Assign requires shapes of both tensors to match. lhs shape= [1500] rhs shape= [1024] [[Node: save/Assign_8 = Assign[T=DT_FLOAT, _class=["loc:@initial_lstm/b_h"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/device:GPU:0"](initial_lstm/b_h, save/RestoreV2/_33)]]
Caused by op u'save/Assign_8', defined at:
File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"main", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/usr/local/lib/python2.7/dist-packages/ipykernel_launcher.py", line 16, in
did u solved it ? i am also getting the same error
model = CaptionGenerator(word_to_idx, dim_feature=[196, 512], dim_embed=512, dim_hidden=1024, n_time_step=16, prev2out=True, ctx2out=True, alpha_c=1.0, selector=True, dropout=True)
@Yuli555 I have tried your method and it did not work. Have you tried it yourself?
could you tell me how to deal with it?
@chaoyan1037 I am getting the same problem.Have you solved it?
@chaoyan1037 I am getting the same problem.Have you solved it?
Yes, I changed some numbers and then it worked, but I do not remember which number I changed. You should read the source code and find out which number to change. Good luck.