Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config in MaxPooling 1d #48

Open
renph opened this issue Apr 15, 2021 · 0 comments
Open

Config in MaxPooling 1d #48

renph opened this issue Apr 15, 2021 · 0 comments

Comments

@renph
Copy link

renph commented Apr 15, 2021

Hi Awni Y. Hannun, I have been reproducing you paper published on Nature medicine.

I am confused about your settings of MaxPooling 1d.

Here is the function for building the whole network.

ecg/ecg/network.py

Lines 42 to 81 in c97bb96

def resnet_block(
layer,
num_filters,
subsample_length,
block_index,
**params):
from keras.layers import Add
from keras.layers import MaxPooling1D
from keras.layers.core import Lambda
def zeropad(x):
y = K.zeros_like(x)
return K.concatenate([x, y], axis=2)
def zeropad_output_shape(input_shape):
shape = list(input_shape)
assert len(shape) == 3
shape[2] *= 2
return tuple(shape)
shortcut = MaxPooling1D(pool_size=subsample_length)(layer)
zero_pad = (block_index % params["conv_increase_channels_at"]) == 0 \
and block_index > 0
if zero_pad is True:
shortcut = Lambda(zeropad, output_shape=zeropad_output_shape)(shortcut)
for i in range(params["conv_num_skip"]):
if not (block_index == 0 and i == 0):
layer = _bn_relu(
layer,
dropout=params["conv_dropout"] if i > 0 else 0,
**params)
layer = add_conv_weight(
layer,
params["conv_filter_length"],
num_filters,
subsample_length if i == 0 else 1,
**params)
layer = Add()([shortcut, layer])
return layer

You created the shortcut on line 62, where the subsample_length can only be 1 or 2 in your settings.

    shortcut = MaxPooling1D(pool_size=subsample_length)(layer) 

when subsample_length = 1, MaxPooling1D applies 1x1 window on input data, therefore, no change made to the input.
Is this intended?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant