Error : CNN Visualizations Occlusion function

Hello all,
I have a doubt.
In 0511_CNNVisualisation, under occlusion function-

  • width, height = image.shape[-2], image.shape[-1]

if we have have an image with dimensions (3,4,5)
image.shape[-1] is for no of columns(which in this case is equal to 5 ) and image.shape[-2] is for no of rows (which in this case is equal to 4)

Width should be equal to no of of columns and height should be equal to no of rows.

So in this context, is this initialisation correct ?

  • width, height = image.shape[-2], image.shape[-1]
1 Like

I came here with the same doubt.
As per this comment, images are represented in Pytorch as [channels, height, width], so the correct statement should have been height, width = image.shape[-2], image.shape[-1]. It didn’t break here because we are using square shape images.


Hi @shresth.mishra.cse22, @databaaz,
Thanks for pointing this! :slight_smile:
Both of you are right.


The for loops inside occlusion function has h and w range from 0 to height and 0 to width respectively. Shouldn’t they be varying from 0 to output_height and output_width respectively ?

Even the assignment statement later would change:
input_image[:, :, h_start:h_end, w_start:w_end] = occ_pixel
instead of
input_image[:, :, w_start:w_end, h_start:h_end] = occ_pixel