Skip to content

Commit

Permalink
fixed fnn constructor for pytorch to add regularization
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Woolford committed Sep 6, 2024
1 parent d5a903d commit 584f315
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions deepxde/nn/pytorch/fnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class FNN(NN):
"""Fully-connected neural network."""

def __init__(self, layer_sizes, activation, kernel_initializer):
def __init__(self, layer_sizes, activation, kernel_initializer, regularization=None):
super().__init__()
if isinstance(activation, list):
if not (len(layer_sizes) - 1) == len(activation):
Expand All @@ -31,7 +31,9 @@ def __init__(self, layer_sizes, activation, kernel_initializer):
)
initializer(self.linears[-1].weight)
initializer_zero(self.linears[-1].bias)

self.regularizer=regularization
# currently list with two components: regularization type, weight decay
# currently supports l2 regularization
def forward(self, inputs):
x = inputs
if self._input_transform is not None:
Expand Down

0 comments on commit 584f315

Please sign in to comment.