iamtrask / Grokking-Deep-Learning

this repository accompanies the book "Grokking Deep Learning"
7.38k stars 1.57k forks source link

chapter 10, is the `for row_start in range(layer_0.shape[1]-kernel_rows)` correct? #43

Open DawnEve opened 4 years ago

DawnEve commented 4 years ago

8x8 image with a 3x3 kernel, we get 6x6 output, which means 8-3+1=6.

when using for row_start in range(layer_0.shape[1]-kernel_rows) , it discards the last pixel in the row.

What do you think?

DawnEve commented 4 years ago

for i in range(6): [i, i+3) 0 3 1 4 2 5 3 6 4 7 [5, 8) # this last slice shouldn't be neglected.

chnwiki commented 2 days ago

hidden_size = ((input_rows - kernel_rows+1) (input_cols - kernel_cols+1)) num_kernels

for row_start in range(layer_0.shape[1]-kernel_rows+1): for col_start in range(layer_0.shape[2] - kernel_cols+1): sect = get_image_section(layer_0, row_start, row_start+kernel_rows, col_start, col_start+kernel_cols) it works