-
Notifications
You must be signed in to change notification settings - Fork 952
Remove extra convolutions in TCN #471
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
Remove extra convolutions in TCN #471
Conversation
darts/models/tcn_model.py
Outdated
@@ -84,7 +84,7 @@ def __init__(self, | |||
if weight_norm: | |||
self.conv1, self.conv2 = nn.utils.weight_norm(self.conv1), nn.utils.weight_norm(self.conv2) | |||
|
|||
if nr_blocks_below == 0 or nr_blocks_below == num_layers - 1: | |||
if nr_blocks_below in {0, num_layers - 1} and input_dim != output_dim: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually do you think we could simplify this to
if nr_blocks_below in {0, num_layers - 1} and input_dim != output_dim: | |
if input_dim != output_dim: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree! Looks super simple and clear
darts/models/tcn_model.py
Outdated
@@ -103,7 +103,8 @@ def forward(self, x): | |||
x = self.dropout_fn(x) | |||
|
|||
# add residual | |||
if self.nr_blocks_below in {0, self.num_layers - 1}: | |||
if (self.nr_blocks_below in {0, self.num_layers - 1} and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And also here just check, self.conv1.in_channels != self.conv2.out_channels
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for polishing our TCN!
Fixes #470. Add the 1x1 convolution in a case of different number of channels between input and output of a residual block