Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add dataset and dataloader for sample points #195

Merged
merged 8 commits into from
Nov 7, 2023
Merged

add dataset and dataloader for sample points #195

merged 8 commits into from
Nov 7, 2023

Conversation

ndem0
Copy link
Member

@ndem0 ndem0 commented Oct 25, 2023

TODO list:

  • dataloader has to support data condition (GAROM is not working)
  • test for dataset and loader
  • dataloader has to work for GPU training

@dario-coscia dario-coscia added pr-to-fix Label for PR that needs modification v0.2 implementation in v0.2 labels Oct 25, 2023
@ndem0 ndem0 marked this pull request as ready for review November 2, 2023 15:08
@ndem0 ndem0 added pr-to-review Label for PR that are ready to been reviewed and removed pr-to-fix Label for PR that needs modification labels Nov 2, 2023
@@ -135,8 +148,8 @@ def training_step(self, batch, batch_idx):
total_loss = sum(condition_losses)

self.log('mean_loss', float(total_loss / len(condition_losses)), prog_bar=True, logger=True)
for condition_loss, loss in zip(condition_names, condition_losses):
self.log(condition_loss + '_loss', float(loss), prog_bar=True, logger=True)
# for condition_loss, loss in zip(condition_names, condition_losses):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did we remove these loggers?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depending on the batch, you may not have all conditions at any iterations. It is something to fix once we clean the training structure

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, we can log at each full dataloader iteration by taking the mean fo the batches losses. Let's fix it later

ground_truth = batch['output'][condition_idx == condition_id]
loss = self._loss_data(samples, ground_truth)
else:
raise ValueError("Batch size not supported")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure what is going on here. Can you give me more details? Do you think we can make it easier so someone who is building a solver doesn't have to play with len(batch). Maybe a function in the utility, idk...

condition = self.problem.conditions[condition_name]
pts = batch['pts']
out = batch['output']
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as PINN, I do not understand very well what is going on..

@dario-coscia
Copy link
Collaborator

dario-coscia commented Nov 2, 2023

Overall the batching mechanism is very clever, I understood that the iterator in the dataloader returns two or three values, depending on whether data are there. I am concerned for a new user who wants to build a solver, the training_step is not that easy to understand, especially for a new user.... Finally, some tests are failing. Have you checked GPU training?

@dario-coscia dario-coscia added pr-to-fix Label for PR that needs modification and removed pr-to-review Label for PR that are ready to been reviewed labels Nov 2, 2023
@ndem0
Copy link
Member Author

ndem0 commented Nov 3, 2023

Since the solvers are running, I would merge it now and open an issue in order to fix it once in 0.1

@dario-coscia
Copy link
Collaborator

dario-coscia commented Nov 3, 2023

Since the solvers are running, I would merge it now and open an issue in order to fix it once in 0.1

Ok, but let us fix the tests that are not running first, and check that GPU training is ok.

@@ -97,6 +97,15 @@ def configure_optimizers(self):
"""
return self.optimizers, [self.scheduler]

def _loss_data(self, input, output):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also _loss_data and _loss_phys I would make it public. In such a way if the user wants to define a new PINN (e.g. gradient-PINN, weak-PINN, ...) he needs just to overwrite those functions.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Private and public methods can be redefined in child classes!
Private methods/attributes just identify what shouldn't be called from external classes

@ndem0 ndem0 merged commit 9353834 into v0.1 Nov 7, 2023
10 of 14 checks passed
@ndem0 ndem0 deleted the dataloader branch November 7, 2023 10:38
ndem0 added a commit that referenced this pull request Nov 17, 2023
* add dataset and dataloader for sample points
* unittests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-to-fix Label for PR that needs modification v0.2 implementation in v0.2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants