Skip to content

Commit

Permalink
Change the store to require a component dimension (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
alan-cooney authored Jan 2, 2024
1 parent a2de674 commit 2b7ca6e
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 455 deletions.
2 changes: 0 additions & 2 deletions sparse_autoencoder/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Sparse Autoencoder Library."""
from sparse_autoencoder.activation_resampler.activation_resampler import ActivationResampler
from sparse_autoencoder.activation_store.disk_store import DiskActivationStore
from sparse_autoencoder.activation_store.tensor_store import TensorActivationStore
from sparse_autoencoder.autoencoder.model import SparseAutoencoder
from sparse_autoencoder.loss.abstract_loss import LossReductionType
Expand Down Expand Up @@ -53,7 +52,6 @@
"CapacityMetric",
"Controller",
"ControllerType",
"DiskActivationStore",
"Distribution",
"Goal",
"HyperbandStopping",
Expand Down
10 changes: 5 additions & 5 deletions sparse_autoencoder/activation_store/base_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ class ActivationStore(
def append(
self,
item: Float[Tensor, Axis.names(Axis.INPUT_OUTPUT_FEATURE)],
component_idx: int = 0,
component_idx: int,
) -> Future | None:
"""Add a Single Item to the Store."""

@abstractmethod
def extend(
self,
batch: Float[Tensor, Axis.names(Axis.BATCH, Axis.INPUT_OUTPUT_FEATURE)],
component_idx: int = 0,
component_idx: int,
) -> Future | None:
"""Add a Batch to the Store."""

Expand All @@ -98,8 +98,8 @@ def __len__(self) -> int:

@abstractmethod
def __getitem__(
self, index: int
) -> Float[Tensor, Axis.names(Axis.COMPONENT_OPTIONAL, Axis.INPUT_OUTPUT_FEATURE)]:
self, index: tuple[int, ...] | slice | int
) -> Float[Tensor, Axis.names(Axis.ANY)]:
"""Get an Item from the Store."""

def shuffle(self) -> None:
Expand All @@ -124,7 +124,7 @@ def fill_with_test_data(
Example:
>>> from sparse_autoencoder.activation_store.tensor_store import TensorActivationStore
>>> store = TensorActivationStore(max_items=100, n_neurons=256)
>>> store = TensorActivationStore(max_items=100, n_neurons=256, n_components=1)
>>> store.fill_with_test_data(batch_size=100)
>>> len(store)
100
Expand Down
335 changes: 0 additions & 335 deletions sparse_autoencoder/activation_store/disk_store.py

This file was deleted.

Loading

0 comments on commit 2b7ca6e

Please sign in to comment.