Skip to content
This repository was archived by the owner on Apr 10, 2024. It is now read-only.

Commit e254694

Browse files
author
Ludwig Schubert
committed
Switch to more-itertools rather than rolling our own batching and backports
1 parent 893cf0d commit e254694

File tree

4 files changed

+8
-105
lines changed

4 files changed

+8
-105
lines changed

lucid/misc/batching.py

Lines changed: 0 additions & 78 deletions
This file was deleted.

lucid/recipes/activation_atlas/main.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
)
2525
from lucid.recipes.activation_atlas.layout import aligned_umap
2626
from lucid.recipes.activation_atlas.render import render_icons
27-
from lucid.misc.batching import batch
27+
from more_itertools import chunked
2828

2929

3030
def activation_atlas(
@@ -33,6 +33,7 @@ def activation_atlas(
3333
grid_size=10,
3434
icon_size=96,
3535
number_activations=NUMBER_OF_AVAILABLE_SAMPLES,
36+
icon_batch_size=32,
3637
verbose=False,
3738
):
3839
"""Renders an Activation Atlas of the given model's layer."""
@@ -43,7 +44,7 @@ def activation_atlas(
4344
layout, activations, grid_size
4445
)
4546
icons = []
46-
for directions_batch in batch(directions, batch_size=64):
47+
for directions_batch in chunked(directions, icon_batch_size):
4748
icon_batch, losses = render_icons(
4849
directions_batch, model, layer=layer.name, size=icon_size, num_attempts=1
4950
)
@@ -61,8 +62,9 @@ def aligned_activation_atlas(
6162
grid_size=10,
6263
icon_size=80,
6364
num_steps=1024,
64-
whiten_layers=False,
65+
whiten_layers=True,
6566
number_activations=NUMBER_OF_AVAILABLE_SAMPLES,
67+
icon_batch_size=32,
6668
verbose=False,
6769
):
6870
"""Renders two aligned Activation Atlases of the given models' layers.
@@ -82,7 +84,7 @@ def aligned_activation_atlas(
8284

8385
def _progressive_canvas_iterator():
8486
icons = []
85-
for directions_batch in batch(directions, batch_size=32, as_list=True):
87+
for directions_batch in chunked(directions, icon_batch_size):
8688
icon_batch, losses = render_icons(
8789
directions_batch,
8890
model,

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@
6464
"pyopengl",
6565
"click",
6666
"filelock",
67-
"cachetools"
67+
"cachetools",
68+
"more-itertools"
6869
],
6970
tests_require=test_deps,
7071
extras_require=extras,

tests/misc/test_batching.py

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)