Skip to content

Commit

Permalink
Fix bug when running on CPU
Browse files Browse the repository at this point in the history
  • Loading branch information
hvy committed Jan 20, 2017
1 parent 881c645 commit ea8329a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ def visualize_layer_activations(model, im, layer_idx):
of size one, i.e. a single image.
"""

if hasattr(model, '_device_id') and model._device_id >= 0: # Using GPU
if model._device_id is not None and model._device_id >= 0: # Using GPU
im = cupy.array(im)

activations = model.activations(Variable(im), layer_idx)

if hasattr(model, '_device_id') and model._device_id >= 0:
if isinstance(activations, cupy.ndarray):
activations = cupy.asnumpy(activations)

# Rescale to [0, 255]
Expand Down

0 comments on commit ea8329a

Please sign in to comment.