keras-vis icon indicating copy to clipboard operation
keras-vis copied to clipboard

i have some problem in using visualize_cam when i load a inceptionV3 network!

Open zhangxiaodi opened this issue 8 years ago • 2 comments

File "/home/xy/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 2209, in set_shapes_for_outputs shapes = shape_func(op)

File "/home/xy/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 2159, in call_with_requiring return call_cpp_shape_fn(op, require_shape_fn=True)

File "/home/xy/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/common_shapes.py", line 627, in call_cpp_shape_fn require_shape_fn)

File "/home/xy/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/common_shapes.py", line 691, in _call_cpp_shape_fn_impl raise ValueError(err.message)

ValueError: slice index 5 of dimension 1 out of bounds. for 'strided_slice_1' (op: 'StridedSlice') with input shapes: [?,5], [2], [2], [2] and with computed input tensors: input[1] = <0 5>, input[2] = <0 6>, input[3] = <1 1>.

zhangxiaodi avatar Nov 27 '17 11:11 zhangxiaodi

i want to know how use the visualize_cam in InceptionV3? please recommend me!

zhangxiaodi avatar Nov 27 '17 11:11 zhangxiaodi

I was able to use visualize_cam on Inception V3 by making a few modifications to the VGG example here: https://github.com/raghakot/keras-vis/blob/master/examples/vggnet/attention.ipynb

I had to define the input_shape to the network, so that the neural network layers were all of defined sizes (this is done by default in VGG, but not in Inception V3):

from keras.applications import InceptionV3 model = InceptionV3(weights='imagenet', include_top=True, input_shape=(299, 299, 3))

and then changing the image load size to (299, 299):

img1 = utils.load_img('test-a.jpg', target_size=(299, 299))

4OH4 avatar Jan 21 '18 12:01 4OH4