adding graph timeseries#807
Conversation
dario-coscia
left a comment
There was a problem hiding this comment.
Minor comment on an extra feature, but overall looks great. Be aware that tests are failing
| residuals = [] | ||
|
|
||
| # Iterate over the time steps | ||
| for step in range(1, batch["input"].shape[2]): |
There was a problem hiding this comment.
@GiovanniCanali what do you think to add the pushforward trick here as well? Is it a condition thing or solver thing? Having it is very easy (we just need the no grad option)
There was a problem hiding this comment.
This is definitely a condition-level concern, since gradient computation must be enabled or disabled when evaluating the residual between the model prediction and the target. As you noted, the implementation should be straightforward. Since the forward method is inherited from TimeSeriesCondition, we should consider implementing it directly there.
GiovanniCanali
left a comment
There was a problem hiding this comment.
I know this is still a work in progress, but I have added a few comments below.
@ndem0, please remember to add the appropriate mapping to the Condition factory so that the software automatically dispatches graph time-series conditions and standard time-series conditions to the correct classes.
|
|
||
| return _DataManager(input=graph) | ||
|
|
||
| def evaluate(self, batch, solver): |
There was a problem hiding this comment.
This method appears to be identical to the one defined in TimeSeriesCondition and should therefore be inherited without modification.
There was a problem hiding this comment.
now some small differences in accessing the node data, I would keep it otherwise several if are needed in the TimeSerieCondition
| return torch.stack(residuals).as_subclass(torch.Tensor) | ||
|
|
||
| @property | ||
| def input(self): |
There was a problem hiding this comment.
This method appears to be identical to the one defined in TimeSeriesCondition and should therefore be inherited without modification.
| residuals = [] | ||
|
|
||
| # Iterate over the time steps | ||
| for step in range(1, batch["input"].shape[2]): |
There was a problem hiding this comment.
This is definitely a condition-level concern, since gradient computation must be enabled or disabled when evaluating the residual between the model prediction and the target. As you noted, the implementation should be straightforward. Since the forward method is inherited from TimeSeriesCondition, we should consider implementing it directly there.
Code Coverage SummaryResults for commit: 07b8b60 Minimum allowed coverage is ♻️ This comment has been updated with latest results |
GiovanniCanali
left a comment
There was a problem hiding this comment.
Everything looks great! My only remaining doubt concerns the bypassed check in core/graph.py. Once that is addressed, you have the green light from my side.
| if "x" in kwargs: | ||
| x = kwargs["x"] | ||
| self._check_x_consistency(x, pos) | ||
| # self._check_x_consistency(x, pos) |
There was a problem hiding this comment.
Why is this check bypassed?
There was a problem hiding this comment.
For time-series, you typically have 3D tensor: n_nodes, n_timestep, n_features (even more sometimes...)
There was a problem hiding this comment.
Should we delete the _check_x_consistency method then?
| expected_shape = torch.Size([n_nodes, n_windows, unroll_length, 2]) | ||
| assert item.input.x.shape == expected_shape | ||
|
|
||
| # TODO: Why this test? |
There was a problem hiding this comment.
Remove this if it is no longer tested. This was originally added to test_time_series_condition to verify that temporal sequentiality is preserved when sequences are not randomized.
There was a problem hiding this comment.
I would keep them, but I was not able to find where the batches are actually built. For the moment I just commented it.
| Condition <condition/condition.rst> | ||
| Data Condition <condition/data_condition.rst> | ||
| Domain Equation Condition <condition/domain_equation_condition.rst> | ||
| Graph Time Series Condition <condition/graph_time_series_condition.rst> |
There was a problem hiding this comment.
I noticed there is neither a rst file for Time Series Condition nor a reference in the _code.rst file. Is it possibile to add it in this PR, instead of opening a new one?
|
Also, remember to run the black formatter before merging! Two files to be fixed |
Description
Added the graph time series condition.
Checklist