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

Commit

Permalink
Switch to more-itertools rather than rolling our own batching and b…
Browse files Browse the repository at this point in the history
…ackports
  • Loading branch information
Ludwig Schubert committed Dec 19, 2018
1 parent 893cf0d commit e254694
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 105 deletions.
78 changes: 0 additions & 78 deletions lucid/misc/batching.py

This file was deleted.

10 changes: 6 additions & 4 deletions lucid/recipes/activation_atlas/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
)
from lucid.recipes.activation_atlas.layout import aligned_umap
from lucid.recipes.activation_atlas.render import render_icons
from lucid.misc.batching import batch
from more_itertools import chunked


def activation_atlas(
Expand All @@ -33,6 +33,7 @@ def activation_atlas(
grid_size=10,
icon_size=96,
number_activations=NUMBER_OF_AVAILABLE_SAMPLES,
icon_batch_size=32,
verbose=False,
):
"""Renders an Activation Atlas of the given model's layer."""
Expand All @@ -43,7 +44,7 @@ def activation_atlas(
layout, activations, grid_size
)
icons = []
for directions_batch in batch(directions, batch_size=64):
for directions_batch in chunked(directions, icon_batch_size):
icon_batch, losses = render_icons(
directions_batch, model, layer=layer.name, size=icon_size, num_attempts=1
)
Expand All @@ -61,8 +62,9 @@ def aligned_activation_atlas(
grid_size=10,
icon_size=80,
num_steps=1024,
whiten_layers=False,
whiten_layers=True,
number_activations=NUMBER_OF_AVAILABLE_SAMPLES,
icon_batch_size=32,
verbose=False,
):
"""Renders two aligned Activation Atlases of the given models' layers.
Expand All @@ -82,7 +84,7 @@ def aligned_activation_atlas(

def _progressive_canvas_iterator():
icons = []
for directions_batch in batch(directions, batch_size=32, as_list=True):
for directions_batch in chunked(directions, icon_batch_size):
icon_batch, losses = render_icons(
directions_batch,
model,
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@
"pyopengl",
"click",
"filelock",
"cachetools"
"cachetools",
"more-itertools"
],
tests_require=test_deps,
extras_require=extras,
Expand Down
22 changes: 0 additions & 22 deletions tests/misc/test_batching.py

This file was deleted.

0 comments on commit e254694

Please sign in to comment.