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

Check if 'cnn_output_size' is zero in CNNembedding. #1281

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions sbi/neural_nets/embedding_nets/cnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ def __init__(
cnn_output_size = input_shape
stride = 1
padding = 1

for ii in range(num_conv_layers):
# Defining another 2D convolution layer
conv_layer = conv_module(
Expand All @@ -141,6 +142,12 @@ def __init__(
# Calculate change of output size of each CNN layer
cnn_output_size = get_new_cnn_output_size(cnn_output_size, conv_layer, pool)

assert all(
cnn_output_size
), f"""CNN output size is zero at layer {ii + 1}. Either reduce
num_cnn_layers to {ii} or adjust the kernel_size
and pool_kernel_size accordingly."""

self.cnn_subnet = nn.Sequential(*cnn_layers)

# Construct linear post processing net.
Expand Down