Skip to content

Problem with custom CNN VGG16 (unsupported operand type(s) for *: 'int' and 'NoneType') #232

@ruvsv

Description

@ruvsv
  • [* ] Check that you are up-to-date with the master branch of keras-vis. You can update with:
    pip install git+git://github.com/raghakot/keras-vis.git --upgrade --no-deps

  • [- ] If running on TensorFlow, check that you are up-to-date with the latest version. The installation instructions can be found here.

Everything works on the pretrained vgg16 keras model.
The one below does not work.
What are the ways to calculate gradients for the multiple model?

tensorboard 1.15.0
tensorflow 1.15.2
tensorflow-estimator 1.15.1
Keras 2.3.1
Keras-Applications 1.0.8
Keras-Preprocessing 1.1.0
keras-vis 0.5.0
Keras 2.3.1
Keras-Applications 1.0.8
Keras-Preprocessing 1.1.0
keras-vis 0.5.0
scipy 1.1.0

1
`---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
in
6 max_iter = 100,
7 verbose = True,
----> 8 filter_indices = None)
9 print(activation_max.shape)
10 plt.imshow(activation_max)

~/anaconda3/lib/python3.6/site-packages/vis/visualization/activation_maximization.py in visualize_activation(model, layer_idx, filter_indices, wrt_tensor, seed_input, input_range, backprop_modifier, grad_modifier, act_max_weight, lp_norm_weight, tv_weight, **optimizer_params)
110
111 return visualize_activation_with_losses(model.input, losses, wrt_tensor,
--> 112 seed_input, input_range, **optimizer_params)

~/anaconda3/lib/python3.6/site-packages/vis/visualization/activation_maximization.py in visualize_activation_with_losses(input_tensor, losses, wrt_tensor, seed_input, input_range, **optimizer_params)
40 }, **optimizer_params)
41
---> 42 opt = Optimizer(input_tensor, losses, input_range, wrt_tensor=wrt_tensor)
43 img = opt.minimize(**optimizer_params)[0]
44

~/anaconda3/lib/python3.6/site-packages/vis/optimizer.py in init(self, input_tensor, losses, input_range, wrt_tensor, norm_grads)
50 # Perf optimization. Don't build loss function with 0 weight.
51 if weight != 0:
---> 52 loss_fn = weight * loss.build_loss()
53 overall_loss = loss_fn if overall_loss is None else overall_loss + loss_fn
54 self.loss_names.append(loss.name)

~/anaconda3/lib/python3.6/site-packages/vis/regularizers.py in build_loss(self)
99 value = K.pow(K.sum(K.pow(K.abs(self.img), self.p)), 1. / self.p)
100
--> 101 return normalize(self.img, value)

~/anaconda3/lib/python3.6/site-packages/vis/regularizers.py in normalize(input_tensor, output_tensor)
22 """
23 image_dims = utils.get_img_shape(input_tensor)[1:]
---> 24 return output_tensor / np.prod(image_dims)
25
26

<array_function internals> in prod(*args, **kwargs)

~/anaconda3/lib/python3.6/site-packages/numpy/core/fromnumeric.py in prod(a, axis, dtype, out, keepdims, initial, where)
2960 """
2961 return _wrapreduction(a, np.multiply, 'prod', axis, dtype, out,
-> 2962 keepdims=keepdims, initial=initial, where=where)
2963
2964

~/anaconda3/lib/python3.6/site-packages/numpy/core/fromnumeric.py in _wrapreduction(obj, ufunc, method, axis, dtype, out, **kwargs)
88 return reduction(axis=axis, out=out, **passkwargs)
89
---> 90 return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
91
92

TypeError: unsupported operand type(s) for *: 'int' and 'NoneType'`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions