Skip to content

Commit

Permalink
fix example
Browse files Browse the repository at this point in the history
  • Loading branch information
adriangb committed Sep 2, 2020
1 parent 0b2ea43 commit 42710ea
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions rfcs/20200902-pickle-for-keras/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,13 @@ Solution (2) would look something like this (assuming `Model.save` worked with `
class Model:

def __reduce_ex__(self, protocol):
b = io.BytesIO()
self.save(b)
b = io.BytesIO() # python built in library
self.save(b) # i.e. tf.keras.Model.save
return load_model, (b.get_value()),) # where load_model is tf.keras.models.load_model
```

Note how this exactly mirrors the aforementioned blog post regarding PyTorch ([link](https://matthewrocklin.com/blog/work/2018/07/23/protocols-pickle)).

By implementing this in all of Keras' base classes, things will automatically work
with custom metrics and subclassed models.

Expand Down

0 comments on commit 42710ea

Please sign in to comment.