From 42710ea3ce7f4af826120b341c4bf277604fe080 Mon Sep 17 00:00:00 2001 From: Adrian Garcia Badaracco <1755071+adriangb@users.noreply.github.com> Date: Wed, 2 Sep 2020 18:01:37 -0500 Subject: [PATCH] fix example --- rfcs/20200902-pickle-for-keras/README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rfcs/20200902-pickle-for-keras/README.md b/rfcs/20200902-pickle-for-keras/README.md index b25ef54ee..847ce227e 100644 --- a/rfcs/20200902-pickle-for-keras/README.md +++ b/rfcs/20200902-pickle-for-keras/README.md @@ -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.