lululxvi / deepxde

A library for scientific machine learning and physics-informed learning
https://deepxde.readthedocs.io
GNU Lesser General Public License v2.1
2.47k stars 712 forks source link

[Fix] TF Backend Regularization fix. #1781

Closed agniv-the-marker closed 1 week ago

agniv-the-marker commented 1 week ago

TF Regularization

Check the docs and the argument for tf.keras.regualizers.l1/l2 is of the form l1/l2 instead of just l in the current version. Without it this breaks:

net = dde.maps.PFNN(
    network,
    "swish",
    "Glorot normal",
    regularization=["l2", 1e-8]
)

Specifically it gives you the error:

TypeError: L1.__init__() got an unexpected keyword argument 'l'

As of right now, the following works instead:

net = dde.maps.PFNN(
    network,
    "swish",
    "Glorot normal",
    regularization=["l1+l2", 1e-8, 1e-8]
)

But merging would allow for each one to be used on their own.

lululxvi commented 1 week ago

Split the regularization and model save into two PRs.