Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Load Model from Checkpoints After Pre-training for Fine-Tuning Issue #192

Open
fatmacelebi opened this issue Feb 12, 2022 · 0 comments
Open

Comments

@fatmacelebi
Copy link

After I run the simclr on custom dataset, I got checkpoints and I tried to load checkpoints to resnet model like below ;
import tensorflow as tf
from tensorflow.keras.models import *
checkpoint_path = '/tmp/model.ckpt-13079'

model =tf.keras.applications.ResNet101(
include_top=True, weights=None, input_shape=(224, 224, 3))
model.load_weights(checkpoint_path)
and I was not able to lead weights from checkpoints path and I got below error;
AssertionError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_15012/3954170122.py in
----> 1 model.load_weights(checkpoint_path)

~\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\keras\engine\training.py in load_weights(self, filepath, by_name, skip_mismatch, options)
2306 # streaming restore for any variables created in the future.
2307 trackable_utils.streaming_restore(status=status, session=session)
-> 2308 status.assert_nontrivial_match()
2309 return status
2310 if h5py is None:

~\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\training\tracking\util.py in assert_nontrivial_match(self)
1023 # assert_nontrivial_match and assert_consumed (and both are less
1024 # useful since we don't touch Python objects or Python state).
-> 1025 return self.assert_consumed()
1026
1027 def _gather_saveable_objects(self):

~\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\training\tracking\util.py in assert_consumed(self)
1000 raise AssertionError(
1001 "Some objects had attributes which were not restored:{}".format(
-> 1002 "".join(unused_attribute_strings)))
1003 for trackable in self._graph_view.list_objects():
1004 # pylint: disable=protected-access

AssertionError: Some objects had attributes which were not restored:
<tf.Variable 'conv1_conv/kernel:0' shape=(7, 7, 3, 64) dtype=float32, numpy

Can you help please?
Thanks in Advance.

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

No branches or pull requests

1 participant