Created
February 1, 2020 14:21
-
-
Save hartikainen/29cbab60e5039219a513c9f0231d9fc4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pickle | |
import tensorflow as tf | |
def main(): | |
x = tf.keras.layers.Input((3, )) | |
y = tf.keras.layers.Dense(5)(x) | |
model_1 = tf.keras.Model(x, y) | |
_ = model_1(tf.random.uniform((15, 3))) | |
model_2 = pickle.loads(pickle.dumps(model_1)) | |
for w1, w2 in zip(model_1.get_weights(), model_2.get_weights()): | |
tf.debugging.assert_equal(w1, w2) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment