Created
October 30, 2018 12:20
-
-
Save AppleHolic/36a740c52a6bc509fb4883d06df4a208 to your computer and use it in GitHub Desktop.
calculate convolution dimensions
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
x = 80 # spectrogram scale | |
output = 24000 # waveform scale | |
max_f = 50 | |
max_s = 50 | |
N = 2 | |
# calculate function | |
calc_conv_dim = lambda x, f, s, p: (x - f + p) // s + 1 | |
calc_deconv_dim = lambda x, f, s, p: int((x - 1) * s - p + f) | |
combination_f = lambda: [(f, s) for f in range(0, max_f, 2) for s in range(0, max_s, 2)] | |
# get all of the combination | |
combination = combination_f() | |
for _ in range(N - 1): | |
combination = [[*x, *y] for x in combination for y in combination_f()] | |
# match all | |
for item in combination: | |
x_ = x | |
for n in range(0, N): | |
f, s = item[n * 2], item[n * 2 + 1] | |
x_ = calc_deconv_dim(x_, f, s, 0) | |
if x_ == output: | |
print(item) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment