raghakot / keras-vis

Neural network visualization toolkit for keras
https://raghakot.github.io/keras-vis
MIT License
2.98k stars 661 forks source link

AssertionError with Conv example #25

Closed ManavA closed 7 years ago

ManavA commented 7 years ago

I'm trying the example as given, but get the following error. Python 2.7, latest keras&tensorflow.


AssertionError Traceback (most recent call last)

in () 19 vis_images = [] 20 for idx in filters: ---> 21 img = visualize_activation(model, layer_idx, filter_indices=idx) 22 img = utils.draw_text(img, str(idx)) 23 vis_images.append(img) /home/manava/anaconda2/lib/python2.7/site-packages/vis/visualization.pyc in visualize_activation(model, layer_idx, filter_indices, seed_img, text, act_max_weight, lp_norm_weight, tv_weight, **optimizer_params) 108 ] 109 --> 110 opt = Optimizer(model.input, losses, norm_grads=False) 111 img = opt.minimize(**optimizer_params)[0] 112 if text: /home/manava/anaconda2/lib/python2.7/site-packages/vis/optimizer.pyc in __init__(self, img_input, losses, wrt, norm_grads) 33 # Perf optimization. Don't build loss function with 0 weight. 34 if weight != 0: ---> 35 loss_fn = weight * loss.build_loss() 36 overall_loss = loss_fn if overall_loss is None else overall_loss + loss_fn 37 self.loss_names.append(loss.name) /home/manava/anaconda2/lib/python2.7/site-packages/vis/losses.pyc in build_loss(self) 85 else: 86 # slicer is used to deal with theano/tensorflow without the ugly conditional statements. ---> 87 loss += -K.mean(layer_output[utils.slicer[:, idx, ...]]) 88 89 return loss /home/manava/anaconda2/lib/python2.7/site-packages/vis/utils/utils.pyc in __getitem__(self, item_slice) 247 """Assuming a slice for shape `(samples, channels, image_dims...)` 248 """ --> 249 assert len(item_slice) == 4 250 if K.image_data_format() == 'channels_first': 251 return item_slice AssertionError:
raghakot commented 7 years ago

Ah yes, fixed. I will double check all the examples in the docs too

ManavA commented 7 years ago

Thanks. On Wed, May 10, 2017 at 9:22 PM, Raghavendra Kotikalapudi < notifications@github.com> wrote:

Closed #25 https://github.com/raghakot/keras-vis/issues/25.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/raghakot/keras-vis/issues/25#event-1077563090, or mute the thread https://github.com/notifications/unsubscribe-auth/ABDMDYa4jeKogiWi-_mhCD3M9h8JkbkYks5r4ozjgaJpZM4NUznU .

absurdvision commented 7 years ago

I still have this issue. Can you point to the fix or give some more information ?

AlvarHHM commented 7 years ago

I also encounter this issue

ManavA commented 7 years ago

I believe this is because the github is not synced with the pypi package. You should get the latest from github or just comment out the assertion.