Renaming
* solvers -> solver * adaptive_functions -> adaptive_function * callbacks -> callback * operators -> operator * pinns -> physics_informed_solver * layers -> block
This commit is contained in:
committed by
Nicola Demo
parent
810d215ca0
commit
df673cad4e
@@ -10,6 +10,7 @@ __all__ = [
|
|||||||
|
|
||||||
from .label_tensor import LabelTensor
|
from .label_tensor import LabelTensor
|
||||||
from .graph import Graph
|
from .graph import Graph
|
||||||
from .solvers.solver import SolverInterface, MultiSolverInterface
|
from .solver import SolverInterface, MultiSolverInterface
|
||||||
from .trainer import Trainer
|
from .trainer import Trainer
|
||||||
from .condition.condition import Condition
|
from .condition.condition import Condition
|
||||||
|
from .data import PinaDataModule
|
||||||
@@ -9,7 +9,7 @@ from abc import ABCMeta
|
|||||||
class AdaptiveActivationFunctionInterface(torch.nn.Module, metaclass=ABCMeta):
|
class AdaptiveActivationFunctionInterface(torch.nn.Module, metaclass=ABCMeta):
|
||||||
r"""
|
r"""
|
||||||
The
|
The
|
||||||
:class:`~pina.adaptive_functions.adaptive_func_interface.AdaptiveActivationFunctionInterface`
|
:class:`~pina.adaptive_function.adaptive_func_interface.AdaptiveActivationFunctionInterface`
|
||||||
class makes a :class:`torch.nn.Module` activation function into an adaptive
|
class makes a :class:`torch.nn.Module` activation function into an adaptive
|
||||||
trainable activation function. If one wants to create an adpative activation
|
trainable activation function. If one wants to create an adpative activation
|
||||||
function, this class must be use as base class.
|
function, this class must be use as base class.
|
||||||
10
pina/callback/__init__.py
Normal file
10
pina/callback/__init__.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
__all__ = [
|
||||||
|
"SwitchOptimizer",
|
||||||
|
"R3Refinement",
|
||||||
|
"MetricTracker",
|
||||||
|
"PINAProgressBar",
|
||||||
|
]
|
||||||
|
|
||||||
|
from .optimizer_callback import SwitchOptimizer
|
||||||
|
from .adaptive_refinment_callback import R3Refinement
|
||||||
|
from .processing_callback import MetricTracker, PINAProgressBar
|
||||||
@@ -19,7 +19,7 @@ class SwitchOptimizer(Callback):
|
|||||||
|
|
||||||
:param new_optimizers: The model optimizers to switch to. Can be a
|
:param new_optimizers: The model optimizers to switch to. Can be a
|
||||||
single :class:`torch.optim.Optimizer` or a list of them for multiple
|
single :class:`torch.optim.Optimizer` or a list of them for multiple
|
||||||
model solvers.
|
model solver.
|
||||||
:type new_optimizers: pina.optim.TorchOptimizer | list
|
:type new_optimizers: pina.optim.TorchOptimizer | list
|
||||||
:param epoch_switch: The epoch at which to switch to the new optimizer.
|
:param epoch_switch: The epoch at which to switch to the new optimizer.
|
||||||
:type epoch_switch: int
|
:type epoch_switch: int
|
||||||
@@ -87,12 +87,12 @@ class PINAProgressBar(TQDMProgressBar):
|
|||||||
:Keyword Arguments:
|
:Keyword Arguments:
|
||||||
The additional keyword arguments specify the progress bar
|
The additional keyword arguments specify the progress bar
|
||||||
and can be choosen from the `pytorch-lightning
|
and can be choosen from the `pytorch-lightning
|
||||||
TQDMProgressBar API <https://lightning.ai/docs/pytorch/stable/_modules/lightning/pytorch/callbacks/progress/tqdm_progress.html#TQDMProgressBar>`_
|
TQDMProgressBar API <https://lightning.ai/docs/pytorch/stable/_modules/lightning/pytorch/callback/progress/tqdm_progress.html#TQDMProgressBar>`_
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
>>> pbar = PINAProgressBar(['mean'])
|
>>> pbar = PINAProgressBar(['mean'])
|
||||||
>>> # ... Perform training ...
|
>>> # ... Perform training ...
|
||||||
>>> trainer = Trainer(solver, callbacks=[pbar])
|
>>> trainer = Trainer(solver, callback=[pbar])
|
||||||
"""
|
"""
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
# check consistency
|
# check consistency
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
__all__ = [
|
|
||||||
"SwitchOptimizer",
|
|
||||||
"R3Refinement",
|
|
||||||
"MetricTracker",
|
|
||||||
"PINAProgressBar",
|
|
||||||
]
|
|
||||||
|
|
||||||
from .optimizer_callbacks import SwitchOptimizer
|
|
||||||
from .adaptive_refinment_callbacks import R3Refinement
|
|
||||||
from .processing_callbacks import MetricTracker, PINAProgressBar
|
|
||||||
@@ -27,7 +27,7 @@ class InputPointsEquationCondition(ConditionInterface):
|
|||||||
if key == 'input_points':
|
if key == 'input_points':
|
||||||
check_consistency(
|
check_consistency(
|
||||||
value, (LabelTensor)
|
value, (LabelTensor)
|
||||||
) # for now only labeltensors, we need labels for the operators!
|
) # for now only labeltensors, we need labels for the operator!
|
||||||
InputPointsEquationCondition.__dict__[key].__set__(self, value)
|
InputPointsEquationCondition.__dict__[key].__set__(self, value)
|
||||||
elif key == 'equation':
|
elif key == 'equation':
|
||||||
check_consistency(value, (EquationInterface))
|
check_consistency(value, (EquationInterface))
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
""" Module """
|
""" Module """
|
||||||
|
|
||||||
from .equation import Equation
|
from .equation import Equation
|
||||||
from ..operators import grad, div, laplacian
|
from ..operator import grad, div, laplacian
|
||||||
|
|
||||||
|
|
||||||
class FixedValue(Equation):
|
class FixedValue(Equation):
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
import torch
|
import torch
|
||||||
from torch import nn, cat
|
from torch import nn, cat
|
||||||
from .layers import AVNOBlock
|
from .block import AVNOBlock
|
||||||
from .base_no import KernelNeuralOperator
|
from .base_no import KernelNeuralOperator
|
||||||
from pina.utils import check_consistency
|
from ..utils import check_consistency
|
||||||
|
|
||||||
|
|
||||||
class AveragingNeuralOperator(KernelNeuralOperator):
|
class AveragingNeuralOperator(KernelNeuralOperator):
|
||||||
|
|||||||
@@ -3,14 +3,14 @@ Kernel Neural Operator Module.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
from pina.utils import check_consistency
|
from ..utils import check_consistency
|
||||||
|
|
||||||
|
|
||||||
class KernelNeuralOperator(torch.nn.Module):
|
class KernelNeuralOperator(torch.nn.Module):
|
||||||
r"""
|
r"""
|
||||||
Base class for composing Neural Operators with integral kernels.
|
Base class for composing Neural Operators with integral kernels.
|
||||||
|
|
||||||
This is a base class for composing neural operators with multiple
|
This is a base class for composing neural operator with multiple
|
||||||
integral kernels. All neural operator models defined in PINA inherit
|
integral kernels. All neural operator models defined in PINA inherit
|
||||||
from this class. The structure is inspired by the work of Kovachki, N.
|
from this class. The structure is inspired by the work of Kovachki, N.
|
||||||
et al. see Figure 2 of the reference for extra details. The Neural
|
et al. see Figure 2 of the reference for extra details. The Neural
|
||||||
|
|||||||
35
pina/model/block/__init__.py
Normal file
35
pina/model/block/__init__.py
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
__all__ = [
|
||||||
|
"ContinuousConvBlock",
|
||||||
|
"ResidualBlock",
|
||||||
|
"EnhancedLinear",
|
||||||
|
"SpectralConvBlock1D",
|
||||||
|
"SpectralConvBlock2D",
|
||||||
|
"SpectralConvBlock3D",
|
||||||
|
"FourierBlock1D",
|
||||||
|
"FourierBlock2D",
|
||||||
|
"FourierBlock3D",
|
||||||
|
"PODBlock",
|
||||||
|
"OrthogonalBlock",
|
||||||
|
"PeriodicBoundaryEmbedding",
|
||||||
|
"FourierFeatureEmbedding",
|
||||||
|
"AVNOBlock",
|
||||||
|
"LowRankBlock",
|
||||||
|
"RBFBlock",
|
||||||
|
"GNOBlock"
|
||||||
|
]
|
||||||
|
|
||||||
|
from .convolution_2d import ContinuousConvBlock
|
||||||
|
from .residual import ResidualBlock, EnhancedLinear
|
||||||
|
from .spectral import (
|
||||||
|
SpectralConvBlock1D,
|
||||||
|
SpectralConvBlock2D,
|
||||||
|
SpectralConvBlock3D,
|
||||||
|
)
|
||||||
|
from .fourier import FourierBlock1D, FourierBlock2D, FourierBlock3D
|
||||||
|
from .pod import PODBlock
|
||||||
|
from .orthogonal import OrthogonalBlock
|
||||||
|
from .embedding import PeriodicBoundaryEmbedding, FourierFeatureEmbedding
|
||||||
|
from .avno_layer import AVNOBlock
|
||||||
|
from .lowrank_layer import LowRankBlock
|
||||||
|
from .rbf_layer import RBFBlock
|
||||||
|
from .gno_block import GNOBlock
|
||||||
@@ -2,7 +2,7 @@ import torch
|
|||||||
import torch.nn as nn
|
import torch.nn as nn
|
||||||
from ...utils import check_consistency
|
from ...utils import check_consistency
|
||||||
|
|
||||||
from pina.model.layers import (
|
from pina.model.block import (
|
||||||
SpectralConvBlock1D,
|
SpectralConvBlock1D,
|
||||||
SpectralConvBlock2D,
|
SpectralConvBlock2D,
|
||||||
SpectralConvBlock3D,
|
SpectralConvBlock3D,
|
||||||
@@ -18,7 +18,7 @@ class MIONet(torch.nn.Module):
|
|||||||
.. seealso::
|
.. seealso::
|
||||||
|
|
||||||
**Original reference**: Jin, Pengzhan, Shuai Meng, and Lu Lu.
|
**Original reference**: Jin, Pengzhan, Shuai Meng, and Lu Lu.
|
||||||
*MIONet: Learning multiple-input operators via tensor product.*
|
*MIONet: Learning multiple-input operator via tensor product.*
|
||||||
SIAM Journal on Scientific Computing 44.6 (2022): A3490-A351
|
SIAM Journal on Scientific Computing 44.6 (2022): A3490-A351
|
||||||
DOI: `10.1137/22M1477751
|
DOI: `10.1137/22M1477751
|
||||||
<https://doi.org/10.1137/22M1477751>`_
|
<https://doi.org/10.1137/22M1477751>`_
|
||||||
@@ -289,8 +289,8 @@ class DeepONet(MIONet):
|
|||||||
.. seealso::
|
.. seealso::
|
||||||
|
|
||||||
**Original reference**: Lu, L., Jin, P., Pang, G. et al. *Learning
|
**Original reference**: Lu, L., Jin, P., Pang, G. et al. *Learning
|
||||||
nonlinear operators via DeepONet based on the universal approximation
|
nonlinear operator via DeepONet based on the universal approximation
|
||||||
theorem of operators*. Nat Mach Intell 3, 218–229 (2021).
|
theorem of operator*. Nat Mach Intell 3, 218–229 (2021).
|
||||||
DOI: `10.1038/s42256-021-00302-5
|
DOI: `10.1038/s42256-021-00302-5
|
||||||
<https://doi.org/10.1038/s42256-021-00302-5>`_
|
<https://doi.org/10.1038/s42256-021-00302-5>`_
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
import torch
|
import torch
|
||||||
import torch.nn as nn
|
import torch.nn as nn
|
||||||
from ..utils import check_consistency
|
from ..utils import check_consistency
|
||||||
from .layers.residual import EnhancedLinear
|
from .block.residual import EnhancedLinear
|
||||||
|
|
||||||
|
|
||||||
class FeedForward(torch.nn.Module):
|
class FeedForward(torch.nn.Module):
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import torch.nn as nn
|
|||||||
from ..label_tensor import LabelTensor
|
from ..label_tensor import LabelTensor
|
||||||
import warnings
|
import warnings
|
||||||
from ..utils import check_consistency
|
from ..utils import check_consistency
|
||||||
from .layers.fourier import FourierBlock1D, FourierBlock2D, FourierBlock3D
|
from .block.fourier import FourierBlock1D, FourierBlock2D, FourierBlock3D
|
||||||
from .base_no import KernelNeuralOperator
|
from .base_no import KernelNeuralOperator
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import torch
|
import torch
|
||||||
from torch.nn import Tanh
|
from torch.nn import Tanh
|
||||||
from .layers import GNOBlock
|
from .block import GNOBlock
|
||||||
from .base_no import KernelNeuralOperator
|
from .base_no import KernelNeuralOperator
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
__all__ = [
|
|
||||||
"ContinuousConvBlock",
|
|
||||||
"ResidualBlock",
|
|
||||||
"EnhancedLinear",
|
|
||||||
"SpectralConvBlock1D",
|
|
||||||
"SpectralConvBlock2D",
|
|
||||||
"SpectralConvBlock3D",
|
|
||||||
"FourierBlock1D",
|
|
||||||
"FourierBlock2D",
|
|
||||||
"FourierBlock3D",
|
|
||||||
"PODBlock",
|
|
||||||
"OrthogonalBlock",
|
|
||||||
"PeriodicBoundaryEmbedding",
|
|
||||||
"FourierFeatureEmbedding",
|
|
||||||
"AVNOBlock",
|
|
||||||
"LowRankBlock",
|
|
||||||
"RBFBlock",
|
|
||||||
"GNOBlock"
|
|
||||||
]
|
|
||||||
|
|
||||||
from .convolution_2d import ContinuousConvBlock
|
|
||||||
from .residual import ResidualBlock, EnhancedLinear
|
|
||||||
from .spectral import (
|
|
||||||
SpectralConvBlock1D,
|
|
||||||
SpectralConvBlock2D,
|
|
||||||
SpectralConvBlock3D,
|
|
||||||
)
|
|
||||||
from .fourier import FourierBlock1D, FourierBlock2D, FourierBlock3D
|
|
||||||
from .pod import PODBlock
|
|
||||||
from .orthogonal import OrthogonalBlock
|
|
||||||
from .embedding import PeriodicBoundaryEmbedding, FourierFeatureEmbedding
|
|
||||||
from .avno_layer import AVNOBlock
|
|
||||||
from .lowrank_layer import LowRankBlock
|
|
||||||
from .rbf_layer import RBFBlock
|
|
||||||
from .gno_block import GNOBlock
|
|
||||||
|
|||||||
@@ -3,10 +3,10 @@
|
|||||||
import torch
|
import torch
|
||||||
from torch import nn, cat
|
from torch import nn, cat
|
||||||
|
|
||||||
from pina.utils import check_consistency
|
from ..utils import check_consistency
|
||||||
|
|
||||||
from .base_no import KernelNeuralOperator
|
from .base_no import KernelNeuralOperator
|
||||||
from .layers.lowrank_layer import LowRankBlock
|
from .block.lowrank_layer import LowRankBlock
|
||||||
|
|
||||||
|
|
||||||
class LowRankNeuralOperator(KernelNeuralOperator):
|
class LowRankNeuralOperator(KernelNeuralOperator):
|
||||||
@@ -19,7 +19,7 @@ class LowRankNeuralOperator(KernelNeuralOperator):
|
|||||||
to other functions. It can be trained with Supervised or PINN based
|
to other functions. It can be trained with Supervised or PINN based
|
||||||
learning strategies.
|
learning strategies.
|
||||||
LowRankNeuralOperator does convolution by performing a low rank
|
LowRankNeuralOperator does convolution by performing a low rank
|
||||||
approximation, see :class:`~pina.model.layers.lowrank_layer.LowRankBlock`.
|
approximation, see :class:`~pina.model.block.lowrank_layer.LowRankBlock`.
|
||||||
|
|
||||||
.. seealso::
|
.. seealso::
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
"""Module for Spline model"""
|
"""Module for Spline model"""
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
import torch.nn as nn
|
|
||||||
from ..utils import check_consistency
|
from ..utils import check_consistency
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
"""
|
"""
|
||||||
Module for operators vectorize implementation. Differential operators are used to write any differential problem.
|
Module for operator vectorize implementation. Differential operator are used to write any differential problem.
|
||||||
These operators are implemented to work on different accellerators: CPU, GPU, TPU or MPS.
|
These operator are implemented to work on different accellerators: CPU, GPU, TPU or MPS.
|
||||||
All operators take as input a tensor onto which computing the operator, a tensor with respect
|
All operator take as input a tensor onto which computing the operator, a tensor with respect
|
||||||
to which computing the operator, the name of the output variables to calculate the operator
|
to which computing the operator, the name of the output variables to calculate the operator
|
||||||
for (in case of multidimensional functions), and the variables name on which the operator is calculated.
|
for (in case of multidimensional functions), and the variables name on which the operator is calculated.
|
||||||
"""
|
"""
|
||||||
@@ -16,7 +16,7 @@ class InverseProblem(AbstractProblem):
|
|||||||
|
|
||||||
:Example:
|
:Example:
|
||||||
>>> from pina.problem import SpatialProblem, InverseProblem
|
>>> from pina.problem import SpatialProblem, InverseProblem
|
||||||
>>> from pina.operators import grad
|
>>> from pina.operator import grad
|
||||||
>>> from pina.equation import ParametricEquation, FixedValue
|
>>> from pina.equation import ParametricEquation, FixedValue
|
||||||
>>> from pina import Condition
|
>>> from pina import Condition
|
||||||
>>> from pina.geometry import CartesianDomain
|
>>> from pina.geometry import CartesianDomain
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class ParametricProblem(AbstractProblem):
|
|||||||
|
|
||||||
:Example:
|
:Example:
|
||||||
>>> from pina.problem import SpatialProblem, ParametricProblem
|
>>> from pina.problem import SpatialProblem, ParametricProblem
|
||||||
>>> from pina.operators import grad
|
>>> from pina.operator import grad
|
||||||
>>> from pina.equations import Equation, FixedValue
|
>>> from pina.equations import Equation, FixedValue
|
||||||
>>> from pina import Condition
|
>>> from pina import Condition
|
||||||
>>> from pina.geometry import CartesianDomain
|
>>> from pina.geometry import CartesianDomain
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class SpatialProblem(AbstractProblem):
|
|||||||
|
|
||||||
:Example:
|
:Example:
|
||||||
>>> from pina.problem import SpatialProblem
|
>>> from pina.problem import SpatialProblem
|
||||||
>>> from pina.operators import grad
|
>>> from pina.operator import grad
|
||||||
>>> from pina.equation import Equation, FixedValue
|
>>> from pina.equation import Equation, FixedValue
|
||||||
>>> from pina import Condition
|
>>> from pina import Condition
|
||||||
>>> from pina.geometry import CartesianDomain
|
>>> from pina.geometry import CartesianDomain
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class TimeDependentProblem(AbstractProblem):
|
|||||||
|
|
||||||
:Example:
|
:Example:
|
||||||
>>> from pina.problem import SpatialProblem, TimeDependentProblem
|
>>> from pina.problem import SpatialProblem, TimeDependentProblem
|
||||||
>>> from pina.operators import grad, laplacian
|
>>> from pina.operator import grad, laplacian
|
||||||
>>> from pina.equation import Equation, FixedValue
|
>>> from pina.equation import Equation, FixedValue
|
||||||
>>> from pina import Condition
|
>>> from pina import Condition
|
||||||
>>> from pina.geometry import CartesianDomain
|
>>> from pina.geometry import CartesianDomain
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ from pina import Condition
|
|||||||
from pina.problem import SpatialProblem, TimeDependentProblem
|
from pina.problem import SpatialProblem, TimeDependentProblem
|
||||||
from pina.equation.equation import Equation
|
from pina.equation.equation import Equation
|
||||||
from pina.domain import CartesianDomain
|
from pina.domain import CartesianDomain
|
||||||
from pina.operators import grad
|
from pina.operator import grad
|
||||||
|
|
||||||
def diffusion_reaction(input_, output_):
|
def diffusion_reaction(input_, output_):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ from pina import Condition, LabelTensor
|
|||||||
from pina.problem import SpatialProblem, TimeDependentProblem, InverseProblem
|
from pina.problem import SpatialProblem, TimeDependentProblem, InverseProblem
|
||||||
from pina.equation.equation import Equation
|
from pina.equation.equation import Equation
|
||||||
from pina.domain import CartesianDomain
|
from pina.domain import CartesianDomain
|
||||||
from pina.operators import grad
|
from pina.operator import grad
|
||||||
|
|
||||||
def diffusion_reaction(input_, output_):
|
def diffusion_reaction(input_, output_):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
import torch
|
import torch
|
||||||
from pina import Condition, LabelTensor
|
from pina import Condition, LabelTensor
|
||||||
from pina.problem import SpatialProblem, InverseProblem
|
from pina.problem import SpatialProblem, InverseProblem
|
||||||
from pina.operators import laplacian
|
from pina.operator import laplacian
|
||||||
from pina.domain import CartesianDomain
|
from pina.domain import CartesianDomain
|
||||||
from pina.equation.equation import Equation
|
from pina.equation.equation import Equation
|
||||||
from pina.equation.equation_factory import FixedValue
|
from pina.equation.equation_factory import FixedValue
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
""" Definition of the Poisson problem on a square domain."""
|
""" Definition of the Poisson problem on a square domain."""
|
||||||
|
|
||||||
from pina.problem import SpatialProblem
|
from pina.problem import SpatialProblem
|
||||||
from pina.operators import laplacian
|
from pina.operator import laplacian
|
||||||
from pina import Condition
|
from pina import Condition
|
||||||
from pina.domain import CartesianDomain
|
from pina.domain import CartesianDomain
|
||||||
from pina.equation.equation import Equation
|
from pina.equation.equation import Equation
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ __all__ = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
from .solver import SolverInterface, SingleSolverInterface, MultiSolverInterface
|
from .solver import SolverInterface, SingleSolverInterface, MultiSolverInterface
|
||||||
from .pinns import *
|
from .physic_informed_solver import *
|
||||||
from .supervised import SupervisedSolver
|
from .supervised import SupervisedSolver
|
||||||
from .rom import ReducedOrderModelSolver
|
from .rom import ReducedOrderModelSolver
|
||||||
from .garom import GAROM
|
from .garom import GAROM
|
||||||
@@ -11,7 +11,7 @@ class CausalPINN(PINN):
|
|||||||
r"""
|
r"""
|
||||||
Causal Physics Informed Neural Network (CausalPINN) solver class.
|
Causal Physics Informed Neural Network (CausalPINN) solver class.
|
||||||
This class implements Causal Physics Informed Neural
|
This class implements Causal Physics Informed Neural
|
||||||
Network solvers, using a user specified ``model`` to solve a specific
|
Network solver, using a user specified ``model`` to solve a specific
|
||||||
``problem``. It can be used for solving both forward and inverse problems.
|
``problem``. It can be used for solving both forward and inverse problems.
|
||||||
|
|
||||||
The Causal Physics Informed Network aims to find
|
The Causal Physics Informed Network aims to find
|
||||||
@@ -12,7 +12,7 @@ class CompetitivePINN(PINNInterface, MultiSolverInterface):
|
|||||||
r"""
|
r"""
|
||||||
Competitive Physics Informed Neural Network (PINN) solver class.
|
Competitive Physics Informed Neural Network (PINN) solver class.
|
||||||
This class implements Competitive Physics Informed Neural
|
This class implements Competitive Physics Informed Neural
|
||||||
Network solvers, using a user specified ``model`` to solve a specific
|
Network solver, using a user specified ``model`` to solve a specific
|
||||||
``problem``. It can be used for solving both forward and inverse problems.
|
``problem``. It can be used for solving both forward and inverse problems.
|
||||||
|
|
||||||
The Competitive Physics Informed Network aims to find
|
The Competitive Physics Informed Network aims to find
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
import torch
|
import torch
|
||||||
|
|
||||||
from .pinn import PINN
|
from .pinn import PINN
|
||||||
from pina.operators import grad
|
from pina.operator import grad
|
||||||
from pina.problem import SpatialProblem
|
from pina.problem import SpatialProblem
|
||||||
|
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ class GradientPINN(PINN):
|
|||||||
r"""
|
r"""
|
||||||
Gradient Physics Informed Neural Network (GradientPINN) solver class.
|
Gradient Physics Informed Neural Network (GradientPINN) solver class.
|
||||||
This class implements Gradient Physics Informed Neural
|
This class implements Gradient Physics Informed Neural
|
||||||
Network solvers, using a user specified ``model`` to solve a specific
|
Network solver, using a user specified ``model`` to solve a specific
|
||||||
``problem``. It can be used for solving both forward and inverse problems.
|
``problem``. It can be used for solving both forward and inverse problems.
|
||||||
|
|
||||||
The Gradient Physics Informed Network aims to find
|
The Gradient Physics Informed Network aims to find
|
||||||
@@ -11,7 +11,7 @@ class PINN(PINNInterface, SingleSolverInterface):
|
|||||||
r"""
|
r"""
|
||||||
Physics Informed Neural Network (PINN) solver class.
|
Physics Informed Neural Network (PINN) solver class.
|
||||||
This class implements Physics Informed Neural
|
This class implements Physics Informed Neural
|
||||||
Network solvers, using a user specified ``model`` to solve a specific
|
Network solver, using a user specified ``model`` to solve a specific
|
||||||
``problem``. It can be used for solving both forward and inverse problems.
|
``problem``. It can be used for solving both forward and inverse problems.
|
||||||
|
|
||||||
The Physics Informed Network aims to find
|
The Physics Informed Network aims to find
|
||||||
@@ -18,7 +18,7 @@ from ...condition import (
|
|||||||
class PINNInterface(SolverInterface, metaclass=ABCMeta):
|
class PINNInterface(SolverInterface, metaclass=ABCMeta):
|
||||||
"""
|
"""
|
||||||
Base PINN solver class. This class implements the Solver Interface
|
Base PINN solver class. This class implements the Solver Interface
|
||||||
for Physics Informed Neural Network solvers.
|
for Physics Informed Neural Network solver.
|
||||||
|
|
||||||
This class can be used to define PINNs with multiple ``optimizers``,
|
This class can be used to define PINNs with multiple ``optimizers``,
|
||||||
and/or ``models``.
|
and/or ``models``.
|
||||||
@@ -11,7 +11,7 @@ class RBAPINN(PINN):
|
|||||||
r"""
|
r"""
|
||||||
Residual-based Attention PINN (RBAPINN) solver class.
|
Residual-based Attention PINN (RBAPINN) solver class.
|
||||||
This class implements Residual-based Attention Physics Informed Neural
|
This class implements Residual-based Attention Physics Informed Neural
|
||||||
Network solvers, using a user specified ``model`` to solve a specific
|
Network solver, using a user specified ``model`` to solve a specific
|
||||||
``problem``. It can be used for solving both forward and inverse problems.
|
``problem``. It can be used for solving both forward and inverse problems.
|
||||||
|
|
||||||
The Residual-based Attention Physics Informed Neural Network aims to find
|
The Residual-based Attention Physics Informed Neural Network aims to find
|
||||||
@@ -39,7 +39,7 @@ class SelfAdaptivePINN(PINNInterface, MultiSolverInterface):
|
|||||||
r"""
|
r"""
|
||||||
Self Adaptive Physics Informed Neural Network (SelfAdaptivePINN)
|
Self Adaptive Physics Informed Neural Network (SelfAdaptivePINN)
|
||||||
solver class. This class implements Self-Adaptive Physics Informed Neural
|
solver class. This class implements Self-Adaptive Physics Informed Neural
|
||||||
Network solvers, using a user specified ``model`` to solve a specific
|
Network solver, using a user specified ``model`` to solve a specific
|
||||||
``problem``. It can be used for solving both forward and inverse problems.
|
``problem``. It can be used for solving both forward and inverse problems.
|
||||||
|
|
||||||
The Self Adapive Physics Informed Neural Network aims to find
|
The Self Adapive Physics Informed Neural Network aims to find
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import torch
|
import torch
|
||||||
|
|
||||||
from pina.solvers import SupervisedSolver
|
from pina.solver import SupervisedSolver
|
||||||
|
|
||||||
|
|
||||||
class ReducedOrderModelSolver(SupervisedSolver):
|
class ReducedOrderModelSolver(SupervisedSolver):
|
||||||
@@ -15,7 +15,7 @@ class SupervisedSolver(SingleSolverInterface):
|
|||||||
The Supervised Solver class aims to find
|
The Supervised Solver class aims to find
|
||||||
a map between the input :math:`\mathbf{s}:\Omega\rightarrow\mathbb{R}^m`
|
a map between the input :math:`\mathbf{s}:\Omega\rightarrow\mathbb{R}^m`
|
||||||
and the output :math:`\mathbf{u}:\Omega\rightarrow\mathbb{R}^m`. The input
|
and the output :math:`\mathbf{u}:\Omega\rightarrow\mathbb{R}^m`. The input
|
||||||
can be discretised in space (as in :obj:`~pina.solvers.rom.ROMe2eSolver`),
|
can be discretised in space (as in :obj:`~pina.solver.rom.ROMe2eSolver`),
|
||||||
or not (e.g. when training Neural Operators).
|
or not (e.g. when training Neural Operators).
|
||||||
|
|
||||||
Given a model :math:`\mathcal{M}`, the following loss function is
|
Given a model :math:`\mathcal{M}`, the following loss function is
|
||||||
@@ -4,7 +4,7 @@ import torch
|
|||||||
import lightning
|
import lightning
|
||||||
from .utils import check_consistency
|
from .utils import check_consistency
|
||||||
from .data import PinaDataModule
|
from .data import PinaDataModule
|
||||||
from .solvers import SolverInterface, PINNInterface
|
from .solver import SolverInterface, PINNInterface
|
||||||
|
|
||||||
|
|
||||||
class Trainer(lightning.pytorch.Trainer):
|
class Trainer(lightning.pytorch.Trainer):
|
||||||
|
|||||||
@@ -7,6 +7,10 @@ from functools import reduce
|
|||||||
from .label_tensor import LabelTensor
|
from .label_tensor import LabelTensor
|
||||||
|
|
||||||
|
|
||||||
|
def custom_warning_format(
|
||||||
|
message, category, filename, lineno, file=None, line=None
|
||||||
|
):
|
||||||
|
return f"{filename}: {category.__name__}: {message}\n"
|
||||||
|
|
||||||
def check_consistency(object, object_instance, subclass=False):
|
def check_consistency(object, object_instance, subclass=False):
|
||||||
"""Helper function to check object inheritance consistency.
|
"""Helper function to check object inheritance consistency.
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
import torch
|
import torch
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from pina.adaptive_functions import (AdaptiveReLU, AdaptiveSigmoid, AdaptiveTanh,
|
from pina.adaptive_function import (AdaptiveReLU, AdaptiveSigmoid, AdaptiveTanh,
|
||||||
AdaptiveSiLU, AdaptiveMish, AdaptiveELU,
|
AdaptiveSiLU, AdaptiveMish, AdaptiveELU,
|
||||||
AdaptiveCELU, AdaptiveGELU, AdaptiveSoftmin,
|
AdaptiveCELU, AdaptiveGELU, AdaptiveSoftmin,
|
||||||
AdaptiveSoftmax, AdaptiveSIREN, AdaptiveExp)
|
AdaptiveSoftmax, AdaptiveSIREN, AdaptiveExp)
|
||||||
|
|
||||||
|
|
||||||
adaptive_functions = (AdaptiveReLU, AdaptiveSigmoid, AdaptiveTanh,
|
adaptive_function = (AdaptiveReLU, AdaptiveSigmoid, AdaptiveTanh,
|
||||||
AdaptiveSiLU, AdaptiveMish, AdaptiveELU,
|
AdaptiveSiLU, AdaptiveMish, AdaptiveELU,
|
||||||
AdaptiveCELU, AdaptiveGELU, AdaptiveSoftmin,
|
AdaptiveCELU, AdaptiveGELU, AdaptiveSoftmin,
|
||||||
AdaptiveSoftmax, AdaptiveSIREN, AdaptiveExp)
|
AdaptiveSoftmax, AdaptiveSIREN, AdaptiveExp)
|
||||||
x = torch.rand(10, requires_grad=True)
|
x = torch.rand(10, requires_grad=True)
|
||||||
|
|
||||||
@pytest.mark.parametrize("Func", adaptive_functions)
|
@pytest.mark.parametrize("Func", adaptive_function)
|
||||||
def test_constructor(Func):
|
def test_constructor(Func):
|
||||||
if Func.__name__ == 'AdaptiveExp':
|
if Func.__name__ == 'AdaptiveExp':
|
||||||
# simple
|
# simple
|
||||||
@@ -50,12 +50,12 @@ def test_constructor(Func):
|
|||||||
Func(alpha='s')
|
Func(alpha='s')
|
||||||
Func(alpha=1)
|
Func(alpha=1)
|
||||||
|
|
||||||
@pytest.mark.parametrize("Func", adaptive_functions)
|
@pytest.mark.parametrize("Func", adaptive_function)
|
||||||
def test_forward(Func):
|
def test_forward(Func):
|
||||||
af = Func()
|
af = Func()
|
||||||
af(x)
|
af(x)
|
||||||
|
|
||||||
@pytest.mark.parametrize("Func", adaptive_functions)
|
@pytest.mark.parametrize("Func", adaptive_function)
|
||||||
def test_backward(Func):
|
def test_backward(Func):
|
||||||
af = Func()
|
af = Func()
|
||||||
y = af(x)
|
y = af(x)
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
from pina.model.layers import ContinuousConvBlock
|
from pina.model.block import ContinuousConvBlock
|
||||||
import torch
|
import torch
|
||||||
|
|
||||||
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import torch
|
import torch
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from pina.model.layers import PeriodicBoundaryEmbedding, FourierFeatureEmbedding
|
from pina.model.block import PeriodicBoundaryEmbedding, FourierFeatureEmbedding
|
||||||
|
|
||||||
# test tolerance
|
# test tolerance
|
||||||
tol = 1e-6
|
tol = 1e-6
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
from pina.model.layers import FourierBlock1D, FourierBlock2D, FourierBlock3D
|
from pina.model.block import FourierBlock1D, FourierBlock2D, FourierBlock3D
|
||||||
import torch
|
import torch
|
||||||
|
|
||||||
input_numb_fields = 3
|
input_numb_fields = 3
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import torch
|
import torch
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from pina.model.layers import LowRankBlock
|
from pina.model.block import LowRankBlock
|
||||||
from pina import LabelTensor
|
from pina import LabelTensor
|
||||||
|
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import torch
|
import torch
|
||||||
import pytest
|
import pytest
|
||||||
from pina.model.layers import OrthogonalBlock
|
from pina.model.block import OrthogonalBlock
|
||||||
|
|
||||||
torch.manual_seed(111)
|
torch.manual_seed(111)
|
||||||
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import torch
|
import torch
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from pina.model.layers.pod import PODBlock
|
from pina.model.block.pod import PODBlock
|
||||||
|
|
||||||
x = torch.linspace(-1, 1, 100)
|
x = torch.linspace(-1, 1, 100)
|
||||||
toy_snapshots = torch.vstack([torch.exp(-x**2)*c for c in torch.linspace(0, 1, 10)])
|
toy_snapshots = torch.vstack([torch.exp(-x**2)*c for c in torch.linspace(0, 1, 10)])
|
||||||
@@ -2,7 +2,7 @@ import torch
|
|||||||
import pytest
|
import pytest
|
||||||
import math
|
import math
|
||||||
|
|
||||||
from pina.model.layers.rbf_layer import RBFBlock
|
from pina.model.block.rbf_layer import RBFBlock
|
||||||
|
|
||||||
x = torch.linspace(-1, 1, 100)
|
x = torch.linspace(-1, 1, 100)
|
||||||
toy_params = torch.linspace(0, 1, 10).unsqueeze(1)
|
toy_params = torch.linspace(0, 1, 10).unsqueeze(1)
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
from pina.model.layers import ResidualBlock, EnhancedLinear
|
from pina.model.block import ResidualBlock, EnhancedLinear
|
||||||
import torch
|
import torch
|
||||||
import torch.nn as nn
|
import torch.nn as nn
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
from pina.model.layers import SpectralConvBlock1D, SpectralConvBlock2D, SpectralConvBlock3D
|
from pina.model.block import SpectralConvBlock1D, SpectralConvBlock2D, SpectralConvBlock3D
|
||||||
import torch
|
import torch
|
||||||
|
|
||||||
input_numb_fields = 3
|
input_numb_fields = 3
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
from pina.solvers import PINN
|
from pina.solver import PINN
|
||||||
from pina.trainer import Trainer
|
from pina.trainer import Trainer
|
||||||
from pina.model import FeedForward
|
from pina.model import FeedForward
|
||||||
from pina.problem.zoo import Poisson2DSquareProblem as Poisson
|
from pina.problem.zoo import Poisson2DSquareProblem as Poisson
|
||||||
from pina.callbacks import R3Refinement
|
from pina.callback import R3Refinement
|
||||||
|
|
||||||
|
|
||||||
# make the problem
|
# make the problem
|
||||||
@@ -25,7 +25,7 @@ solver = PINN(problem=poisson_problem, model=model)
|
|||||||
# def test_r3refinment_routine():
|
# def test_r3refinment_routine():
|
||||||
# # make the trainer
|
# # make the trainer
|
||||||
# trainer = Trainer(solver=solver,
|
# trainer = Trainer(solver=solver,
|
||||||
# callbacks=[R3Refinement(sample_every=1)],
|
# callback=[R3Refinement(sample_every=1)],
|
||||||
# accelerator='cpu',
|
# accelerator='cpu',
|
||||||
# max_epochs=5)
|
# max_epochs=5)
|
||||||
# trainer.train()
|
# trainer.train()
|
||||||
@@ -35,7 +35,7 @@ solver = PINN(problem=poisson_problem, model=model)
|
|||||||
# len(poisson_problem.output_variables))
|
# len(poisson_problem.output_variables))
|
||||||
# solver = PINN(problem=poisson_problem, model=model)
|
# solver = PINN(problem=poisson_problem, model=model)
|
||||||
# trainer = Trainer(solver=solver,
|
# trainer = Trainer(solver=solver,
|
||||||
# callbacks=[R3Refinement(sample_every=1)],
|
# callback=[R3Refinement(sample_every=1)],
|
||||||
# accelerator='cpu',
|
# accelerator='cpu',
|
||||||
# max_epochs=5)
|
# max_epochs=5)
|
||||||
# before_n_points = {loc : len(pts) for loc, pts in trainer.solver.problem.input_pts.items()}
|
# before_n_points = {loc : len(pts) for loc, pts in trainer.solver.problem.input_pts.items()}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
from pina.solvers import PINN
|
from pina.solver import PINN
|
||||||
from pina.trainer import Trainer
|
from pina.trainer import Trainer
|
||||||
from pina.model import FeedForward
|
from pina.model import FeedForward
|
||||||
from pina.callbacks import MetricTracker
|
from pina.callback import MetricTracker
|
||||||
from pina.problem.zoo import Poisson2DSquareProblem as Poisson
|
from pina.problem.zoo import Poisson2DSquareProblem as Poisson
|
||||||
|
|
||||||
|
|
||||||
@@ -24,14 +24,14 @@ def test_metric_tracker_constructor():
|
|||||||
# def test_metric_tracker_routine(): #TODO revert
|
# def test_metric_tracker_routine(): #TODO revert
|
||||||
# # make the trainer
|
# # make the trainer
|
||||||
# trainer = Trainer(solver=solver,
|
# trainer = Trainer(solver=solver,
|
||||||
# callbacks=[
|
# callback=[
|
||||||
# MetricTracker()
|
# MetricTracker()
|
||||||
# ],
|
# ],
|
||||||
# accelerator='cpu',
|
# accelerator='cpu',
|
||||||
# max_epochs=5)
|
# max_epochs=5)
|
||||||
# trainer.train()
|
# trainer.train()
|
||||||
# # get the tracked metrics
|
# # get the tracked metrics
|
||||||
# metrics = trainer.callbacks[0].metrics
|
# metrics = trainer.callback[0].metrics
|
||||||
# # assert the logged metrics are correct
|
# # assert the logged metrics are correct
|
||||||
# logged_metrics = sorted(list(metrics.keys()))
|
# logged_metrics = sorted(list(metrics.keys()))
|
||||||
# assert logged_metrics == ['train_loss_epoch', 'train_loss_step', 'val_loss']
|
# assert logged_metrics == ['train_loss_epoch', 'train_loss_step', 'val_loss']
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
from pina.callbacks import SwitchOptimizer
|
from pina.callback import SwitchOptimizer
|
||||||
import torch
|
import torch
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from pina.solvers import PINN
|
from pina.solver import PINN
|
||||||
from pina.trainer import Trainer
|
from pina.trainer import Trainer
|
||||||
from pina.model import FeedForward
|
from pina.model import FeedForward
|
||||||
from pina.problem.zoo import Poisson2DSquareProblem as Poisson
|
from pina.problem.zoo import Poisson2DSquareProblem as Poisson
|
||||||
@@ -31,7 +31,7 @@ def test_switch_optimizer_constructor():
|
|||||||
# # make the trainer
|
# # make the trainer
|
||||||
# switch_opt_callback = SwitchOptimizer(lbfgs_optimizer, epoch_switch=3)
|
# switch_opt_callback = SwitchOptimizer(lbfgs_optimizer, epoch_switch=3)
|
||||||
# trainer = Trainer(solver=solver,
|
# trainer = Trainer(solver=solver,
|
||||||
# callbacks=[switch_opt_callback],
|
# callback=[switch_opt_callback],
|
||||||
# accelerator='cpu',
|
# accelerator='cpu',
|
||||||
# max_epochs=5)
|
# max_epochs=5)
|
||||||
# trainer.train()
|
# trainer.train()
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
from pina.solvers import PINN
|
from pina.solver import PINN
|
||||||
from pina.trainer import Trainer
|
from pina.trainer import Trainer
|
||||||
from pina.model import FeedForward
|
from pina.model import FeedForward
|
||||||
from pina.callbacks.processing_callbacks import PINAProgressBar
|
from pina.callback.processing_callback import PINAProgressBar
|
||||||
from pina.problem.zoo import Poisson2DSquareProblem as Poisson
|
from pina.problem.zoo import Poisson2DSquareProblem as Poisson
|
||||||
|
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ from pina.problem.zoo import Poisson2DSquareProblem as Poisson
|
|||||||
# def test_progress_bar_routine():
|
# def test_progress_bar_routine():
|
||||||
# # make the trainer
|
# # make the trainer
|
||||||
# trainer = Trainer(solver=solver,
|
# trainer = Trainer(solver=solver,
|
||||||
# callbacks=[
|
# callback=[
|
||||||
# PINAProgressBar(['mean', 'laplace_D'])
|
# PINAProgressBar(['mean', 'laplace_D'])
|
||||||
# ],
|
# ],
|
||||||
# accelerator='cpu',
|
# accelerator='cpu',
|
||||||
@@ -7,7 +7,7 @@ from pina.problem import AbstractProblem, SpatialProblem
|
|||||||
from pina.domain import CartesianDomain
|
from pina.domain import CartesianDomain
|
||||||
from pina.equation.equation import Equation
|
from pina.equation.equation import Equation
|
||||||
from pina.equation.equation_factory import FixedValue
|
from pina.equation.equation_factory import FixedValue
|
||||||
from pina.operators import laplacian
|
from pina.operator import laplacian
|
||||||
from pina.collector import Collector
|
from pina.collector import Collector
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ from pina.problem.zoo import SupervisedProblem
|
|||||||
from pina.graph import RadiusGraph
|
from pina.graph import RadiusGraph
|
||||||
from pina.data.data_module import DummyDataloader
|
from pina.data.data_module import DummyDataloader
|
||||||
from pina import Trainer
|
from pina import Trainer
|
||||||
from pina.solvers import SupervisedSolver
|
from pina.solver import SupervisedSolver
|
||||||
from torch_geometric.data import Batch
|
from torch_geometric.data import Batch
|
||||||
from torch.utils.data import DataLoader
|
from torch.utils.data import DataLoader
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
from pina.equation import Equation
|
from pina.equation import Equation
|
||||||
from pina.operators import grad, laplacian
|
from pina.operator import grad, laplacian
|
||||||
from pina import LabelTensor
|
from pina import LabelTensor
|
||||||
import torch
|
import torch
|
||||||
import pytest
|
import pytest
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
from pina.equation import SystemEquation
|
from pina.equation import SystemEquation
|
||||||
from pina.operators import grad, laplacian
|
from pina.operator import grad, laplacian
|
||||||
from pina import LabelTensor
|
from pina import LabelTensor
|
||||||
import torch
|
import torch
|
||||||
import pytest
|
import pytest
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import torch
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from pina import LabelTensor
|
from pina import LabelTensor
|
||||||
from pina.operators import grad, div, laplacian
|
from pina.operator import grad, div, laplacian
|
||||||
|
|
||||||
|
|
||||||
def func_vector(x):
|
def func_vector(x):
|
||||||
@@ -3,7 +3,7 @@ import pytest
|
|||||||
|
|
||||||
from pina import LabelTensor, Condition
|
from pina import LabelTensor, Condition
|
||||||
from pina.problem import SpatialProblem
|
from pina.problem import SpatialProblem
|
||||||
from pina.solvers import CausalPINN
|
from pina.solver import CausalPINN
|
||||||
from pina.trainer import Trainer
|
from pina.trainer import Trainer
|
||||||
from pina.model import FeedForward
|
from pina.model import FeedForward
|
||||||
from pina.problem.zoo import (
|
from pina.problem.zoo import (
|
||||||
@@ -118,7 +118,7 @@ def test_solver_test(problem, batch_size, compile):
|
|||||||
|
|
||||||
@pytest.mark.parametrize("problem", [problem, inverse_problem])
|
@pytest.mark.parametrize("problem", [problem, inverse_problem])
|
||||||
def test_train_load_restore(problem):
|
def test_train_load_restore(problem):
|
||||||
dir = "tests/test_solvers/tmp"
|
dir = "tests/test_solver/tmp"
|
||||||
problem = problem
|
problem = problem
|
||||||
solver = CausalPINN(model=model, problem=problem)
|
solver = CausalPINN(model=model, problem=problem)
|
||||||
trainer = Trainer(solver=solver,
|
trainer = Trainer(solver=solver,
|
||||||
@@ -153,4 +153,4 @@ def test_train_load_restore(problem):
|
|||||||
|
|
||||||
# rm directories
|
# rm directories
|
||||||
import shutil
|
import shutil
|
||||||
shutil.rmtree('tests/test_solvers/tmp')
|
shutil.rmtree('tests/test_solver/tmp')
|
||||||
@@ -2,7 +2,7 @@ import torch
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from pina import LabelTensor, Condition
|
from pina import LabelTensor, Condition
|
||||||
from pina.solvers import CompetitivePINN as CompPINN
|
from pina.solver import CompetitivePINN as CompPINN
|
||||||
from pina.trainer import Trainer
|
from pina.trainer import Trainer
|
||||||
from pina.model import FeedForward
|
from pina.model import FeedForward
|
||||||
from pina.problem.zoo import (
|
from pina.problem.zoo import (
|
||||||
@@ -107,7 +107,7 @@ def test_solver_test(problem, batch_size, compile):
|
|||||||
|
|
||||||
@pytest.mark.parametrize("problem", [problem, inverse_problem])
|
@pytest.mark.parametrize("problem", [problem, inverse_problem])
|
||||||
def test_train_load_restore(problem):
|
def test_train_load_restore(problem):
|
||||||
dir = "tests/test_solvers/tmp"
|
dir = "tests/test_solver/tmp"
|
||||||
problem = problem
|
problem = problem
|
||||||
solver = CompPINN(problem=problem, model=model)
|
solver = CompPINN(problem=problem, model=model)
|
||||||
trainer = Trainer(solver=solver,
|
trainer = Trainer(solver=solver,
|
||||||
@@ -142,4 +142,4 @@ def test_train_load_restore(problem):
|
|||||||
|
|
||||||
# rm directories
|
# rm directories
|
||||||
import shutil
|
import shutil
|
||||||
shutil.rmtree('tests/test_solvers/tmp')
|
shutil.rmtree('tests/test_solver/tmp')
|
||||||
@@ -3,7 +3,7 @@ import torch.nn as nn
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from pina import Condition, LabelTensor
|
from pina import Condition, LabelTensor
|
||||||
from pina.solvers import GAROM
|
from pina.solver import GAROM
|
||||||
from pina.condition import InputOutputPointsCondition
|
from pina.condition import InputOutputPointsCondition
|
||||||
from pina.problem import AbstractProblem
|
from pina.problem import AbstractProblem
|
||||||
from pina.model import FeedForward
|
from pina.model import FeedForward
|
||||||
@@ -141,7 +141,7 @@ def test_solver_test(batch_size, compile):
|
|||||||
|
|
||||||
|
|
||||||
def test_train_load_restore():
|
def test_train_load_restore():
|
||||||
dir = "tests/test_solvers/tmp/"
|
dir = "tests/test_solver/tmp/"
|
||||||
problem = TensorProblem()
|
problem = TensorProblem()
|
||||||
solver = GAROM(problem=TensorProblem(),
|
solver = GAROM(problem=TensorProblem(),
|
||||||
generator=Generator(),
|
generator=Generator(),
|
||||||
@@ -174,4 +174,4 @@ def test_train_load_restore():
|
|||||||
|
|
||||||
# rm directories
|
# rm directories
|
||||||
import shutil
|
import shutil
|
||||||
shutil.rmtree('tests/test_solvers/tmp')
|
shutil.rmtree('tests/test_solver/tmp')
|
||||||
@@ -3,7 +3,7 @@ import torch
|
|||||||
|
|
||||||
from pina import LabelTensor, Condition
|
from pina import LabelTensor, Condition
|
||||||
from pina.problem import TimeDependentProblem
|
from pina.problem import TimeDependentProblem
|
||||||
from pina.solvers import GradientPINN
|
from pina.solver import GradientPINN
|
||||||
from pina.model import FeedForward
|
from pina.model import FeedForward
|
||||||
from pina.trainer import Trainer
|
from pina.trainer import Trainer
|
||||||
from pina.problem.zoo import (
|
from pina.problem.zoo import (
|
||||||
@@ -117,7 +117,7 @@ def test_solver_test(problem, batch_size, compile):
|
|||||||
|
|
||||||
@pytest.mark.parametrize("problem", [problem, inverse_problem])
|
@pytest.mark.parametrize("problem", [problem, inverse_problem])
|
||||||
def test_train_load_restore(problem):
|
def test_train_load_restore(problem):
|
||||||
dir = "tests/test_solvers/tmp"
|
dir = "tests/test_solver/tmp"
|
||||||
problem = problem
|
problem = problem
|
||||||
solver = GradientPINN(model=model, problem=problem)
|
solver = GradientPINN(model=model, problem=problem)
|
||||||
trainer = Trainer(solver=solver,
|
trainer = Trainer(solver=solver,
|
||||||
@@ -152,4 +152,4 @@ def test_train_load_restore(problem):
|
|||||||
|
|
||||||
# rm directories
|
# rm directories
|
||||||
import shutil
|
import shutil
|
||||||
shutil.rmtree('tests/test_solvers/tmp')
|
shutil.rmtree('tests/test_solver/tmp')
|
||||||
@@ -4,7 +4,7 @@ import torch
|
|||||||
from pina import LabelTensor, Condition
|
from pina import LabelTensor, Condition
|
||||||
from pina.model import FeedForward
|
from pina.model import FeedForward
|
||||||
from pina.trainer import Trainer
|
from pina.trainer import Trainer
|
||||||
from pina.solvers import PINN
|
from pina.solver import PINN
|
||||||
from pina.condition import (
|
from pina.condition import (
|
||||||
InputOutputPointsCondition,
|
InputOutputPointsCondition,
|
||||||
InputPointsEquationCondition,
|
InputPointsEquationCondition,
|
||||||
@@ -98,7 +98,7 @@ def test_solver_test(problem, batch_size, compile):
|
|||||||
|
|
||||||
@pytest.mark.parametrize("problem", [problem, inverse_problem])
|
@pytest.mark.parametrize("problem", [problem, inverse_problem])
|
||||||
def test_train_load_restore(problem):
|
def test_train_load_restore(problem):
|
||||||
dir = "tests/test_solvers/tmp"
|
dir = "tests/test_solver/tmp"
|
||||||
problem = problem
|
problem = problem
|
||||||
solver = PINN(model=model, problem=problem)
|
solver = PINN(model=model, problem=problem)
|
||||||
trainer = Trainer(solver=solver,
|
trainer = Trainer(solver=solver,
|
||||||
@@ -131,4 +131,4 @@ def test_train_load_restore(problem):
|
|||||||
|
|
||||||
# rm directories
|
# rm directories
|
||||||
import shutil
|
import shutil
|
||||||
shutil.rmtree('tests/test_solvers/tmp')
|
shutil.rmtree('tests/test_solver/tmp')
|
||||||
@@ -4,7 +4,7 @@ import torch
|
|||||||
from pina import LabelTensor, Condition
|
from pina import LabelTensor, Condition
|
||||||
from pina.model import FeedForward
|
from pina.model import FeedForward
|
||||||
from pina.trainer import Trainer
|
from pina.trainer import Trainer
|
||||||
from pina.solvers import RBAPINN
|
from pina.solver import RBAPINN
|
||||||
from pina.condition import (
|
from pina.condition import (
|
||||||
InputOutputPointsCondition,
|
InputOutputPointsCondition,
|
||||||
InputPointsEquationCondition,
|
InputPointsEquationCondition,
|
||||||
@@ -119,7 +119,7 @@ def test_solver_test(problem, compile):
|
|||||||
|
|
||||||
@pytest.mark.parametrize("problem", [problem, inverse_problem])
|
@pytest.mark.parametrize("problem", [problem, inverse_problem])
|
||||||
def test_train_load_restore(problem):
|
def test_train_load_restore(problem):
|
||||||
dir = "tests/test_solvers/tmp"
|
dir = "tests/test_solver/tmp"
|
||||||
problem = problem
|
problem = problem
|
||||||
solver = RBAPINN(model=model, problem=problem)
|
solver = RBAPINN(model=model, problem=problem)
|
||||||
trainer = Trainer(solver=solver,
|
trainer = Trainer(solver=solver,
|
||||||
@@ -154,4 +154,4 @@ def test_train_load_restore(problem):
|
|||||||
|
|
||||||
# rm directories
|
# rm directories
|
||||||
import shutil
|
import shutil
|
||||||
shutil.rmtree('tests/test_solvers/tmp')
|
shutil.rmtree('tests/test_solver/tmp')
|
||||||
@@ -4,7 +4,7 @@ import pytest
|
|||||||
from pina import Condition, LabelTensor
|
from pina import Condition, LabelTensor
|
||||||
from pina.problem import AbstractProblem
|
from pina.problem import AbstractProblem
|
||||||
from pina.condition import InputOutputPointsCondition
|
from pina.condition import InputOutputPointsCondition
|
||||||
from pina.solvers import ReducedOrderModelSolver
|
from pina.solver import ReducedOrderModelSolver
|
||||||
from pina.trainer import Trainer
|
from pina.trainer import Trainer
|
||||||
from pina.model import FeedForward
|
from pina.model import FeedForward
|
||||||
from pina.problem.zoo import Poisson2DSquareProblem
|
from pina.problem.zoo import Poisson2DSquareProblem
|
||||||
@@ -149,7 +149,7 @@ def test_solver_test(use_lt, compile):
|
|||||||
|
|
||||||
|
|
||||||
def test_train_load_restore():
|
def test_train_load_restore():
|
||||||
dir = "tests/test_solvers/tmp/"
|
dir = "tests/test_solver/tmp/"
|
||||||
problem = LabelTensorProblem()
|
problem = LabelTensorProblem()
|
||||||
solver = ReducedOrderModelSolver(problem=problem,
|
solver = ReducedOrderModelSolver(problem=problem,
|
||||||
|
|
||||||
@@ -184,4 +184,4 @@ def test_train_load_restore():
|
|||||||
solver.forward(test_pts))
|
solver.forward(test_pts))
|
||||||
# rm directories
|
# rm directories
|
||||||
import shutil
|
import shutil
|
||||||
shutil.rmtree('tests/test_solvers/tmp')
|
shutil.rmtree('tests/test_solver/tmp')
|
||||||
@@ -2,7 +2,7 @@ import torch
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from pina import LabelTensor, Condition
|
from pina import LabelTensor, Condition
|
||||||
from pina.solvers import SelfAdaptivePINN as SAPINN
|
from pina.solver import SelfAdaptivePINN as SAPINN
|
||||||
from pina.trainer import Trainer
|
from pina.trainer import Trainer
|
||||||
from pina.model import FeedForward
|
from pina.model import FeedForward
|
||||||
from pina.problem.zoo import (
|
from pina.problem.zoo import (
|
||||||
@@ -122,7 +122,7 @@ def test_solver_test(problem, compile):
|
|||||||
|
|
||||||
@pytest.mark.parametrize("problem", [problem, inverse_problem])
|
@pytest.mark.parametrize("problem", [problem, inverse_problem])
|
||||||
def test_train_load_restore(problem):
|
def test_train_load_restore(problem):
|
||||||
dir = "tests/test_solvers/tmp"
|
dir = "tests/test_solver/tmp"
|
||||||
problem = problem
|
problem = problem
|
||||||
solver = SAPINN(model=model, problem=problem)
|
solver = SAPINN(model=model, problem=problem)
|
||||||
trainer = Trainer(solver=solver,
|
trainer = Trainer(solver=solver,
|
||||||
@@ -156,4 +156,4 @@ def test_train_load_restore(problem):
|
|||||||
|
|
||||||
# rm directories
|
# rm directories
|
||||||
import shutil
|
import shutil
|
||||||
shutil.rmtree('tests/test_solvers/tmp')
|
shutil.rmtree('tests/test_solver/tmp')
|
||||||
@@ -3,7 +3,7 @@ import pytest
|
|||||||
from pina import Condition, LabelTensor
|
from pina import Condition, LabelTensor
|
||||||
from pina.condition import InputOutputPointsCondition
|
from pina.condition import InputOutputPointsCondition
|
||||||
from pina.problem import AbstractProblem
|
from pina.problem import AbstractProblem
|
||||||
from pina.solvers import SupervisedSolver
|
from pina.solver import SupervisedSolver
|
||||||
from pina.model import FeedForward
|
from pina.model import FeedForward
|
||||||
from pina.trainer import Trainer
|
from pina.trainer import Trainer
|
||||||
from torch._dynamo.eval_frame import OptimizedModule
|
from torch._dynamo.eval_frame import OptimizedModule
|
||||||
@@ -97,7 +97,7 @@ def test_solver_test(use_lt, compile):
|
|||||||
|
|
||||||
|
|
||||||
def test_train_load_restore():
|
def test_train_load_restore():
|
||||||
dir = "tests/test_solvers/tmp/"
|
dir = "tests/test_solver/tmp/"
|
||||||
problem = LabelTensorProblem()
|
problem = LabelTensorProblem()
|
||||||
solver = SupervisedSolver(problem=problem, model=model)
|
solver = SupervisedSolver(problem=problem, model=model)
|
||||||
trainer = Trainer(solver=solver,
|
trainer = Trainer(solver=solver,
|
||||||
@@ -130,4 +130,4 @@ def test_train_load_restore():
|
|||||||
|
|
||||||
# rm directories
|
# rm directories
|
||||||
import shutil
|
import shutil
|
||||||
shutil.rmtree('tests/test_solvers/tmp')
|
shutil.rmtree('tests/test_solver/tmp')
|
||||||
@@ -2,7 +2,7 @@ import pytest
|
|||||||
import torch
|
import torch
|
||||||
|
|
||||||
from pina import Trainer
|
from pina import Trainer
|
||||||
from pina.solvers import PINN
|
from pina.solver import PINN
|
||||||
from pina.model import FeedForward
|
from pina.model import FeedForward
|
||||||
from pina.problem.zoo import Poisson2DSquareProblem
|
from pina.problem.zoo import Poisson2DSquareProblem
|
||||||
from pina.loss import ScalarWeighting
|
from pina.loss import ScalarWeighting
|
||||||
|
|||||||
Reference in New Issue
Block a user