Skip to content

jaxpi.models

PINN base classes, model/optimizer factories, and the sharded training step.

TrainState [source]

Bases: TrainState

TrainState(step: int | jax.Array, apply_fn: collections.abc.Callable, params: flax.core.frozen_dict.FrozenDict[str, typing.Any], tx: optax._src.base.GradientTransformation, opt_state: Union[jax.Array, numpy.ndarray, numpy.bool, numpy.number, bool, int, float, complex, Iterable[ForwardRef('ArrayTree')], Mapping[Any, ForwardRef('ArrayTree')]], loss_weights: Dict, pts_weights: Dict, momentum: float, pts_momentum: float, prev_params: Any = None)

TrainState.apply_loss_weights() [source]

python
TrainState.apply_loss_weights(self, loss_weights, **kwargs)

TrainState.apply_pts_weights() [source]

python
TrainState.apply_pts_weights(self, pts_weights, **kwargs)

TrainState.replace() [source]

python
TrainState.replace(self, **updates)

Returns a new object replacing the specified fields with new values.

create_arch() [source]

python
create_arch(config)

create_lr_schedule() [source]

python
create_lr_schedule(config)

create_optimizer() [source]

python
create_optimizer(config, lr)

create_model() [source]

python
create_model(config, model_cls, *model_args, params=None, **model_kwargs)

Build a model from its config: lr schedule, optimizer, arch, state.

model_args / model_kwargs are forwarded to the model constructor (problem-specific arguments such as initial conditions or physical parameters). params warm-starts the train state (transfer learning).

create_train_state() [source]

python
create_train_state(
    config,
    tx,
    arch,
    params=None,
    train_state_cls=<class 'jaxpi.models.TrainState'>,
)

PINN [source]

PINN.neural_net() [source]

python
PINN.neural_net(self, params, *args)

PINN.r_net() [source]

python
PINN.r_net(self, params, *args)

PINN.losses() [source]

python
PINN.losses(self, params, state, batch)

PINN.compute_pts_weights() [source]

python
PINN.compute_pts_weights(self, state, init_state, batch)

PINN.compute_loss_weights() [source]

python
PINN.compute_loss_weights(self, state, batch)

Balance losses based on the gradient norms of each loss.

PINN.loss()

python
PINN.loss(self, params, state, batch)

PINN.create_step_fn() [source]

python
PINN.create_step_fn(self)

PINN.create_update_loss_weights_fn() [source]

python
PINN.create_update_loss_weights_fn(self)

PINN.create_update_pts_weights_fn() [source]

python
PINN.create_update_pts_weights_fn(self)

ForwardIVP [source]

Bases: PINN

ForwardIVP.compute_causal_weights()

python
ForwardIVP.compute_causal_weights(self, state, batch)

ForwardIVP.compute_residual_losses() [source]

python
ForwardIVP.compute_residual_losses(
    self,
    params,
    state,
    batch,
    pseudo_time=False,
    causal=False,
)

ForwardBVP [source]

Bases: PINN

ForwardBVP.compute_residual_losses() [source]

python
ForwardBVP.compute_residual_losses(self, params, state, batch, pseudo_time=False)

Released under the Apache 2.0 License.