beinando
beinando

Reputation: 497

Style Transfer : Save&Restore checkpoint/model in tensorflow 1.15.0

i am a bit frustrated about saving and restoring models in tensorflow 1.15.0. I want to achieve it in a jupyter notebook / google colab notebook environment. The application is style-transfer of images.

I simply want to save the model and restore it in order to apply the style transfer for a larger number of images.

The tensorflow documentation is a bit confusing, (i did not find examples for this), so i never really know what the right syntax looks like.

I am at a point now where i want to achieve 1 thing:

  1. Restore the model correctly.

I will write the relevant lines now:

model = get_model()  
opt = tf.train.AdamOptimizer(learning_rate=2.5,beta1=0.99, epsilon=1e-1)
saver = tf.train.Checkpoint(model=model, optimizer=opt)
saver.save('/content/sample_data/test/_____NEU____')

When i want to restore the model, i use the command:

saver.restore('/content/sample_data/test/_____NEU____')

How can i fix this issue, and load my checkpoint files correctly? Thank you


The google colab project is here:

https://colab.research.google.com/drive/12hTitoQ2-tH8pYEsfMDR5jtsg8a96PgC


Upvotes: 0

Views: 460

Answers (2)

beinando
beinando

Reputation: 497

This technique is one where the model doesn't change, but you update the input image to produce the desired output. .. so there was nothing wrong with the saving, but the model just did not change.

Upvotes: 0

beinando
beinando

Reputation: 497

I also tried saving the model via the keras - syntax.

model.load_weights('/content/sample_data/saved_model/my_model6.h5')

and

model.save_weights('/content/sample_data/saved_model/my_model6.h5', save_format='h5')

There was no error message, but the model did not load in the previously trained weights. I asked someone in a mirc-channel yesterday and he said it could be a bug in tf.keras for tensorflow 1.15.0 , but i tried it with tensorflow 1.14.0 and 1.13.1 yesterday without success.

Upvotes: 0

Related Questions