-
Notifications
You must be signed in to change notification settings - Fork 177
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
Error in training with densenet #16
Comments
I am having the same issue here. I guess it's because when we build densenet model, in the DenseBlock init method, we use a list to store the layers, but this is not allowed if we want to save the model using checkpoint. If we save the checkpoint in .h5 format, it's okay, but if we use default format to save, this is not okay. I tried to write DenseBlock in function rather than a subclass, the issue still exists. I am still thinking about how to walkaround. The issue is mentioned in TensorFlow issues as well, tensorflow/tensorflow#36916
Have you had any idea how to solve this problem yet? |
Suggest this code https://github.com/Keyird/DeepLearning-TensorFlow2.0/blob/master/DenseNet/model.py |
Thank you very much! I just figured this out! I changed the code in DenseBlock and this problem seems solved. Original implementation:
After I changed:
|
run train.py report errors
Traceback (most recent call last):
File "E:/work/Basic_CNNs_TensorFlow2-master/train_test.py", line 100, in
model.save_weights(filepath=save_model_dir+"epoch-{}".format(epoch), save_format='tf')
File "E:\anaconda3\envs\tf2\lib\site-packages\tensorflow_core\python\keras\engine\network.py", line 1123, in save_weights
self._trackable_saver.save(filepath, session=session)
File "E:\anaconda3\envs\tf2\lib\site-packages\tensorflow_core\python\training\tracking\util.py", line 1168, in save
file_prefix=file_prefix_tensor, object_graph_tensor=object_graph_tensor)
File "E:\anaconda3\envs\tf2\lib\site-packages\tensorflow_core\python\training\tracking\util.py", line 1108, in _save_cached_when_graph_building
object_graph_tensor=object_graph_tensor)
File "E:\anaconda3\envs\tf2\lib\site-packages\tensorflow_core\python\training\tracking\util.py", line 1076, in _gather_saveables
feed_additions) = self._graph_view.serialize_object_graph()
File "E:\anaconda3\envs\tf2\lib\site-packages\tensorflow_core\python\training\tracking\graph_view.py", line 379, in serialize_object_graph
trackable_objects, path_to_root = self._breadth_first_traversal()
File "E:\anaconda3\envs\tf2\lib\site-packages\tensorflow_core\python\training\tracking\graph_view.py", line 199, in _breadth_first_traversal
for name, dependency in self.list_dependencies(current_trackable):
File "E:\anaconda3\envs\tf2\lib\site-packages\tensorflow_core\python\training\tracking\graph_view.py", line 159, in list_dependencies
return obj._checkpoint_dependencies
File "E:\anaconda3\envs\tf2\lib\site-packages\tensorflow_core\python\training\tracking\data_structures.py", line 509, in _checkpoint_dependencies
"automatically un-wrapped and subsequently ignored." % (self,)))
ValueError: Unable to save the object ListWrapper([]) (a list wrapper constructed to track trackable TensorFlow objects). A list element was replaced (setitem, setslice), deleted (delitem, delslice), or moved (sort). In order to support restoration on object creation, tracking is exclusively for append-only data structures.
If you don't need this list checkpointed, wrap it in a tf.contrib.checkpoint.NoDependency object; it will be automatically un-wrapped and subsequently ignored.
How to solve
The text was updated successfully, but these errors were encountered: