Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ruvsv opened this issue Oct 9, 2020 · 0 comments

Comments

@ruvsv
Copy link

ruvsv commented Oct 9, 2020

  • [* ] 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'`

@ruvsv ruvsv changed the title Problev whith custom CNN VGG16 (unsupported operand type(s) for *: 'int' and 'NoneType') Problem hith custom CNN VGG16 (unsupported operand type(s) for *: 'int' and 'NoneType') Oct 9, 2020
@ruvsv ruvsv changed the title Problem hith custom CNN VGG16 (unsupported operand type(s) for *: 'int' and 'NoneType') Problem with custom CNN VGG16 (unsupported operand type(s) for *: 'int' and 'NoneType') Oct 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant