Skip to content

Commit

Permalink
do not create u_next in last PICNN layer
Browse files Browse the repository at this point in the history
  • Loading branch information
vascomedici committed Nov 15, 2023
1 parent c624dad commit 4442fcf
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pyforecaster/forecasting_models/neural_forecasters.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,6 @@ class PICNNLayer(nn.Module):

@nn.compact
def __call__(self, y, u, z):
# Traditional NN component
u_next = nn.Dense(features=self.features_x, name='u_dense')(u)
u_next = nn.relu(u_next)

# Input-Convex component without bias for the element-wise multiplicative interactions
wzu = self.activation(nn.Dense(features=self.features_out, use_bias=True, name='wzu')(u))
wzu = nn.relu(wzu)
Expand All @@ -228,8 +224,12 @@ def __call__(self, y, u, z):
z_next = z_next + y_next + nn.Dense(features=self.features_out, use_bias=True, name='wuz')(u)
if not self.prediction_layer:
z_next = nn.relu(z_next)

return u_next, z_next
# Traditional NN component only if it's not the prediction layer
u_next = nn.Dense(features=self.features_x, name='u_dense')(u)
u_next = nn.relu(u_next)
return u_next, z_next
else:
return None, z_next


class PartiallyICNN(nn.Module):
Expand Down

0 comments on commit 4442fcf

Please sign in to comment.