From d97f18c848da799a90d7186c2ef50e229d625e30 Mon Sep 17 00:00:00 2001 From: Dong-Kyum Kim Date: Tue, 6 Feb 2024 15:09:18 +0900 Subject: [PATCH 1/3] update --- sparse_autoencoder/train/pipeline.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sparse_autoencoder/train/pipeline.py b/sparse_autoencoder/train/pipeline.py index 0aadd55a..9b458d3a 100644 --- a/sparse_autoencoder/train/pipeline.py +++ b/sparse_autoencoder/train/pipeline.py @@ -175,6 +175,8 @@ def generate_activations(self, store_size: PositiveInt) -> TensorActivationStore hook = partial(store_activations_hook, store=store, component_idx=component_idx) self.source_model.add_hook(cache_name, hook) + print("Generate Process Begin") + # Loop through the dataloader until the store reaches the desired size with torch.no_grad(): while len(store) < store_size: From 8b82a7947e4cc8ef45e1b8926031e1ba8332bfb0 Mon Sep 17 00:00:00 2001 From: Dong-Kyum Kim Date: Tue, 6 Feb 2024 15:31:38 +0900 Subject: [PATCH 2/3] update itertools --- sparse_autoencoder/train/pipeline.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sparse_autoencoder/train/pipeline.py b/sparse_autoencoder/train/pipeline.py index 9b458d3a..1bacdaf0 100644 --- a/sparse_autoencoder/train/pipeline.py +++ b/sparse_autoencoder/train/pipeline.py @@ -1,6 +1,8 @@ """Default pipeline.""" from collections.abc import Iterator from functools import partial + +import itertools import logging from pathlib import Path from tempfile import gettempdir @@ -139,7 +141,7 @@ def __init__( source_dataloader = source_dataset.get_dataloader( source_data_batch_size, num_workers=num_workers_data_loading ) - self.source_data = iter(source_dataloader) + self.source_data = itertools.cycle(source_dataloader) @validate_call def generate_activations(self, store_size: PositiveInt) -> TensorActivationStore: From c491e11b97da52a9ce14e8009d102b2b20ff9f1f Mon Sep 17 00:00:00 2001 From: Dong-Kyum Kim Date: Tue, 6 Feb 2024 15:37:30 +0900 Subject: [PATCH 3/3] clean up --- sparse_autoencoder/train/pipeline.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/sparse_autoencoder/train/pipeline.py b/sparse_autoencoder/train/pipeline.py index 1bacdaf0..5f142603 100644 --- a/sparse_autoencoder/train/pipeline.py +++ b/sparse_autoencoder/train/pipeline.py @@ -177,8 +177,6 @@ def generate_activations(self, store_size: PositiveInt) -> TensorActivationStore hook = partial(store_activations_hook, store=store, component_idx=component_idx) self.source_model.add_hook(cache_name, hook) - print("Generate Process Begin") - # Loop through the dataloader until the store reaches the desired size with torch.no_grad(): while len(store) < store_size: