* multiple functions for version 0.0 * lightining update * minor changes * data pinn loss added --------- Co-authored-by: Nicola Demo <demo.nicola@gmail.com> Co-authored-by: Dario Coscia <dariocoscia@cli-10-110-3-125.WIFIeduroamSTUD.units.it> Co-authored-by: Dario Coscia <dariocoscia@Dario-Coscia.station> Co-authored-by: Dario Coscia <dariocoscia@Dario-Coscia.local> Co-authored-by: Dario Coscia <dariocoscia@192.168.1.38>
32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
""" Solver module. """
|
|
|
|
import lightning.pytorch as pl
|
|
from .utils import check_consistency
|
|
from .dataset import DummyLoader
|
|
from .solver import SolverInterface
|
|
|
|
class Trainer(pl.Trainer):
|
|
|
|
def __init__(self, solver, kwargs={}):
|
|
super().__init__(**kwargs)
|
|
|
|
# check inheritance consistency for solver
|
|
check_consistency(solver, SolverInterface, 'Solver model')
|
|
self._model = solver
|
|
|
|
# create dataloader
|
|
if solver.problem.have_sampled_points is False:
|
|
raise RuntimeError(f'Input points in {solver.problem.not_sampled_points} '
|
|
'training are None. Please '
|
|
'sample points in your problem by calling '
|
|
'discretise_domain function before train '
|
|
'in the provided locations.')
|
|
|
|
# TODO: make a better dataloader for train
|
|
self._loader = DummyLoader(solver.problem.input_pts)
|
|
|
|
|
|
def train(self): # TODO add kwargs and lightining capabilities
|
|
return super().fit(self._model, self._loader)
|
|
|