Zahlii / colab-tf-utils

Automatically backup keras/tensorflow models from Google's Colab service to your GoogleDrive based on a keras callback!
GNU General Public License v3.0
82 stars 23 forks source link

Save full model #8

Closed GeorgeMurAlkh closed 6 years ago

GeorgeMurAlkh commented 6 years ago
exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "/Users/georgezagraid/Projects/AI/Projects/binary_LSTM/load_model.py", line 69, in <module>
    model = load_model(os.path.join(os.path.dirname(__file__),"models/RNN_Final_0.62.model"))
  File "/anaconda3/lib/python3.6/site-packages/tensorflow/python/keras/engine/saving.py", line 229, in load_model
    model = model_from_config(model_config, custom_objects=custom_objects)
  File "/anaconda3/lib/python3.6/site-packages/tensorflow/python/keras/engine/saving.py", line 306, in model_from_config
    return deserialize(config, custom_objects=custom_objects)
  File "/anaconda3/lib/python3.6/site-packages/tensorflow/python/keras/layers/serialization.py", line 64, in deserialize
    printable_module_name='layer')
  File "/anaconda3/lib/python3.6/site-packages/tensorflow/python/keras/utils/generic_utils.py", line 173, in deserialize_keras_object
    list(custom_objects.items())))
  File "/anaconda3/lib/python3.6/site-packages/tensorflow/python/keras/engine/sequential.py", line 293, in from_config
    layer = layer_module.deserialize(conf, custom_objects=custom_objects)
  File "/anaconda3/lib/python3.6/site-packages/tensorflow/python/keras/layers/serialization.py", line 64, in deserialize
    printable_module_name='layer')
  File "/anaconda3/lib/python3.6/site-packages/tensorflow/python/keras/utils/generic_utils.py", line 193, in deserialize_keras_object
    function_name)
ValueError: Unknown layer:name

Getting this error when loading model with

from tensorflow.keras.models import load_model

Is it possible to save full model?

Zahlii commented 6 years ago

Are you trying to load a model trained somewhere else? The checkpointer here uses model.save() which should save both model config and model weights. Maybe the keras versions are mismatching?

GeorgeMurAlkh commented 6 years ago

Thanx for reply - yes you right I'm using tensorflow.keras - this one are best working for me, but in your package - keras. I was getting error when used keras with model saved by tensoflow.keras in my local environment.

GeorgeMurAlkh commented 6 years ago

So I forked, change dependencies in package, switch TF version in colab to be the same as my local env - and it's working now! Thanks.