heatmaps icon indicating copy to clipboard operation
heatmaps copied to clipboard

to_heatmap function error

Open viX-shaw opened this issue 7 years ago • 2 comments

viX-shaw avatar Nov 17 '18 07:11 viX-shaw

Model type detected: global pooling Model cut at layer: 1

ValueError Traceback (most recent call last) in () ----> 1 new_model = to_heatmap(model) 2 idx = 0 # The index of the class you care about, here the first one. 3 display_heatmap(new_model, "./32390.JPG", idx)

/content/heatmaps/heatmap/heatmap.py in to_heatmap(model, input_shape) 238 239 if model_type == "global pooling": --> 240 x = copy_last_layers(model, index + 1, x) 241 242 elif model_type == "local pooling - flatten":

/content/heatmaps/heatmap/heatmap.py in copy_last_layers(model, begin, x, last_activation) 166 last_activation = layer.get_config()["activation"] 167 if i == len(model.layers) - 1: --> 168 x = add_reshaped_layer(layer, x, 1, no_activation=True) 169 else: 170 x = add_reshaped_layer(layer, x, 1)

/content/heatmaps/heatmap/heatmap.py in add_reshaped_layer(layer, x, size, no_activation, atrous_rate) 208 x = new_layer(x) 209 # We transfer the weights: --> 210 insert_weights(layer, new_layer) 211 return x 212

/content/heatmaps/heatmap/heatmap.py in insert_weights(layer, new_layer) 153 W, b = layer.get_weights() 154 ax1, ax2, previous_filter, n_filter = new_layer.get_weights()[0].shape --> 155 new_W = W.reshape((ax1, ax2, previous_filter, n_filter)) 156 new_W = new_W.transpose((0, 1, 2, 3)) 157

ValueError: cannot reshape array of size 4096 into shape (1,1,3,2)

viX-shaw avatar Nov 17 '18 07:11 viX-shaw

Could you share the code that you used and also format it correctly with markdown? It's going to be easier to read.

gabrieldemarmiesse avatar Nov 17 '18 09:11 gabrieldemarmiesse