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

changing wanted word to only one word - error #70

Open
Aishaj opened this issue Aug 20, 2021 · 1 comment
Open

changing wanted word to only one word - error #70

Aishaj opened this issue Aug 20, 2021 · 1 comment

Comments

@Aishaj
Copy link

Aishaj commented Aug 20, 2021

Hi,

Why when I change the wanted words to only one word (yes for example) I get the following error

Traceback (most recent call last): File "test.py", line 199, in <module> test() File "test.py", line 44, in test model.load_weights(FLAGS.checkpoint).expect_partial() File "C:\Users\ash_j\anaconda3\envs\newenvt\lib\site-packages\tensorflow\python\keras\engine\training.py", line 2297, in load_weights status = self._trackable_saver.restore(filepath, options) File "C:\Users\ash_j\anaconda3\envs\newenvt\lib\site-packages\tensorflow\python\training\tracking\util.py", line 1339, in restore checkpoint=checkpoint, proto_id=0).restore(self._graph_view.root) File "C:\Users\ash_j\anaconda3\envs\newenvt\lib\site-packages\tensorflow\python\training\tracking\base.py", line 258, in restore restore_ops = trackable._restore_from_checkpoint_position(self) # pylint: disable=protected-access File "C:\Users\ash_j\anaconda3\envs\newenvt\lib\site-packages\tensorflow\python\training\tracking\base.py", line 978, in _restore_from_checkpoint_position tensor_saveables, python_saveables)) File "C:\Users\ash_j\anaconda3\envs\newenvt\lib\site-packages\tensorflow\python\training\tracking\util.py", line 309, in restore_saveables validated_saveables).restore(self.save_path_tensor, self.options) File "C:\Users\ash_j\anaconda3\envs\newenvt\lib\site-packages\tensorflow\python\training\saving\functional_saver.py", line 339, in restore restore_ops = restore_fn() File "C:\Users\ash_j\anaconda3\envs\newenvt\lib\site-packages\tensorflow\python\training\saving\functional_saver.py", line 323, in restore_fn restore_ops.update(saver.restore(file_prefix, options)) File "C:\Users\ash_j\anaconda3\envs\newenvt\lib\site-packages\tensorflow\python\training\saving\functional_saver.py", line 116, in restore restored_tensors, restored_shapes=None) File "C:\Users\ash_j\anaconda3\envs\newenvt\lib\site-packages\tensorflow\python\training\saving\saveable_object_util.py", line 132, in restore self.handle_op, self._var_shape, restored_tensor) File "C:\Users\ash_j\anaconda3\envs\newenvt\lib\site-packages\tensorflow\python\ops\resource_variable_ops.py", line 308, in shape_safe_assign_variable_handle shape.assert_is_compatible_with(value_tensor.shape) File "C:\Users\ash_j\anaconda3\envs\newenvt\lib\site-packages\tensorflow\python\framework\tensor_shape.py", line 1161, in assert_is_compatible_with raise ValueError("Shapes %s and %s are incompatible" % (self, other)) ValueError: Shapes (3,) and (12,) are incompatible WARNING:tensorflow:Unresolved object in checkpoint: (root).optimizer WARNING:tensorflow:Unresolved object in checkpoint: (root).optimizer.iter WARNING:tensorflow:Unresolved object in checkpoint: (root).optimizer.beta_1 WARNING:tensorflow:Unresolved object in checkpoint: (root).optimizer.beta_2 WARNING:tensorflow:Unresolved object in checkpoint: (root).optimizer.decay WARNING:tensorflow:Unresolved object in checkpoint: (root).optimizer's state 'm' for (root).layer_with_weights-0.kernel WARNING:tensorflow:Unresolved object in checkpoint: (root).optimizer's state 'm' for (root).layer_with_weights-0.bias WARNING:tensorflow:Unresolved object in checkpoint: (root).optimizer's state 'm' for (root).layer_with_weights-1.gamma WARNING:tensorflow:Unresolved object in checkpoint: (root).optimizer's state 'm' for (root).layer_with_weights-1.beta

@Burton2000
Copy link
Contributor

You are trying to load the checkpoint from a previously trained model that was trained with 10 keywords so the output layer has a different number of neurons in it than the one with only 1 keyword.

Because the sizes of these final layers are different TensorFlow is not able to load the checkpoint. which is the error you get.

You can try passing skip_mismatch=True to the load weights call so hopefully TensorFlow will load all the weights it can and ignore the ones it can not.

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

2 participants