Skip to content

Commit

Permalink
Change the order of regularizers
Browse files Browse the repository at this point in the history
  • Loading branch information
vl-dud committed Nov 1, 2024
1 parent 3de1044 commit 571233a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions deepxde/nn/regularizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ def get(identifier):
return tf.keras.regularizers.L1(l1=factor[0])
if name == "l2":
return tf.keras.regularizers.L2(l2=factor[0])
if name in ("l1l2", "l1+l2"):
if len(factor) < 2:
raise ValueError("L1L2 regularizer requires both L1/L2 penalties.")
return tf.keras.regularizers.L1L2(l1=factor[0], l2=factor[1])
if name == "orthogonal":
if not hasattr(tf.keras.regularizers, "OrthogonalRegularizer"):
raise ValueError(
"The 'orthogonal' regularizer is not available "
"in your version of TensorFlow"
)
return tf.keras.regularizers.OrthogonalRegularizer(factor=factor[0])
if name in ("l1l2", "l1+l2"):
if len(factor) < 2:
raise ValueError("L1L2 regularizer requires both L1/L2 penalties.")
return tf.keras.regularizers.L1L2(l1=factor[0], l2=factor[1])
raise ValueError(f"Unknown regularizer name: {name}")

0 comments on commit 571233a

Please sign in to comment.