Last active
October 17, 2018 15:15
-
-
Save anna-hope/c6090fbe62bf648ec6191938cf470b86 to your computer and use it in GitHub Desktop.
Get output dimension after all conv layers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def get_conv_out(dim_in, padding, kernel_size, stride): | |
out_dim = (dim_in + 2 * padding - kernel_size) / stride | |
out_dim += 1 | |
return int(np.floor(out_dim)) | |
layers = [(0, 7, 1), | |
(0, 3, 3), | |
(0, 7, 1), | |
(0, 3, 3), | |
(0, 3, 1), | |
(0, 3, 1), | |
(0, 3, 1), | |
(0, 3, 1), | |
(0, 3, 3)] | |
dim_in = 1014 | |
for padding, f, s in layers: | |
dim_in = get_conv_out(dim_in, padding, f, s) | |
# dim_in is now 34 | |
# 34 * 27 + 96 = 1014 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment