From 361291d08054e69b3291ac6c4780f32eb0b39be3 Mon Sep 17 00:00:00 2001 From: William Brannon Date: Tue, 24 Sep 2024 23:03:53 +0000 Subject: [PATCH] specify torch.load weights_only --- images/sentiment-topic/topic-embeds.py | 2 +- images/sentiment-topic/topic-umap.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/images/sentiment-topic/topic-embeds.py b/images/sentiment-topic/topic-embeds.py index a410415..07e29ae 100755 --- a/images/sentiment-topic/topic-embeds.py +++ b/images/sentiment-topic/topic-embeds.py @@ -122,7 +122,7 @@ def _combine_cached_values(self): ids += [pd.read_csv(fname + '.csv')] with open(fname + '.pt', 'rb') as obj: - embeds += [torch.load(obj, 'cpu')] + embeds += [torch.load(obj, 'cpu', weights_only=True)] ids = pd.concat(ids, axis=0) embeds = torch.cat(embeds, dim=0) diff --git a/images/sentiment-topic/topic-umap.py b/images/sentiment-topic/topic-umap.py index c029f54..5146efb 100755 --- a/images/sentiment-topic/topic-umap.py +++ b/images/sentiment-topic/topic-umap.py @@ -60,7 +60,10 @@ embeds_file = os.path.join(data_dir, 'comment-topics/sentence-embeds.pt') with open(embeds_file, 'rb') as obj: - embeds = torch.load(obj, 'cpu').float().numpy()[train_mask, ...] + embeds = torch.load(obj, 'cpu', weights_only=True) \ + .float() \ + .numpy() \ + [train_mask, ...] params = { 'n_neighbors': 15,