graphnet-team / graphnet

A Deep learning library for neutrino telescopes
https://graphnet-team.github.io/graphnet/
Apache License 2.0
85 stars 86 forks source link

Task refactor #639

Closed RasmusOrsoe closed 7 months ago

RasmusOrsoe commented 7 months ago

This PR is the first in a series of smaller PRs that introduces normalizing flows to graphnet.

In this first PR, the aim is to introduce new flexibility in the generic Task to allow for easier domain/ML paradigm -specific implementations.

The main constraints of our current Task is:

This PR does the following:

I've included a quick illustration that shows this new subclassing structure.

image

RasmusOrsoe commented 7 months ago

This looks good.

I'm not sure if we will be able to guarantee that StandardModel will be compatible with all tasks in the future. In particular, I could imagine that the predict/predict_as_dataframe, might not work with all imagineable tasks in the future. Perhaps we should restrict the tasks provided to StandardModel to be StandardLearnedTask?

You are absolutely right. The next few PRs in the normalizing flow series introduce a few extra lines of code that makes .fit and .predict compatible with this new FlowTask. I have also just now introduced a check in this PR to make sure all tasks are StandardLearnedTask.

Now that we are going about refactoring tasks I think that the aggregation parts of the GNN's might be better placed in the task section. The reason would be that the GNN's would now only be responsible for feature learning, and it would be easier to do transfer-learning between various tasks, where you might have one tasks which predicts on an entire pulsemap and another task, which does regression/classification.

In particular I think we could introduce an Aggregation module, which will take in a variable length pulsemap and return a "fixed length" tensor. This Module would then act as the "link" between the feature-pulsemap in a GNN and the MLP in the StandardLearnedTask, but would be omitted when doing per-node reconstructions.

Perhaps - but I do think it makes a lot of sense to allow models to have aggregation in them. To me it sounds like you're describing ensemble functionality, but perhaps we can discuss this on Tuesday's meeting.