From 728dc16814f536509a913dfb932dd8c10841c787 Mon Sep 17 00:00:00 2001 From: Wok Date: Sun, 31 Jan 2021 15:19:57 +0100 Subject: [PATCH] Store features as float16 instead of float64 https://github.com/openai/CLIP/issues/30 --- build_feature_index.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/build_feature_index.py b/build_feature_index.py index 30aa2a9..87e0524 100644 --- a/build_feature_index.py +++ b/build_feature_index.py @@ -57,9 +57,19 @@ def build_feature_index( if (counter % 1000) == 0: print("{}/{} in {:.2f} s".format(counter, num_games, time() - start)) - np.save(feature_filename, Y_hat) - - np.save(feature_filename, Y_hat) + np.save( + feature_filename, + np.asarray(Y_hat, dtype=np.float16), + allow_pickle=False, + fix_imports=False, + ) + + np.save( + feature_filename, + np.asarray(Y_hat, dtype=np.float16), + allow_pickle=False, + fix_imports=False, + ) return