Open havardhhaugen opened 1 week ago
I updated the implementation based on your feedback. The base class behavior is now to load weights from the graph with a fall-back of calculating area-weights on the fly. Similiarly ReweightedGraphNodeAttribute will also attempt to load the weights from the graph and then re-weights.
I also changed the re-weighting implementation slightly to be more in line with https://github.com/ecmwf/anemoi-training/blob/feature/limited_area/src/anemoi/training/train/forecaster.py. In aifs-mono we scaled the limited area nodes to be a fraction of the global (unmasked) sum, but since the function is now more generic it makes more sense to use a fraction of the total (masked + unmasked).
I didn't actually test if the code works as expected yet, will do that when we are happy with the intended behaviour.
It's looking very good, I like the overall implementation, and think it will become very useful in the future. I've left a few initial comments to start with.
Fixed the issues addressed in the comments and made sure the weights are loaded correctly in training for the four cases: load from graph (+fallback) and reweight (+fallback).
Made docstrings and changed the try-except. Should I remove node_loss_weight: area_weight
from the model config files as part of this pr?
If it is not used anywhere else, yes
Desctiption of functionality Adds functionality to change the area weighting of nodes in the limited area of a stretched grid graph. Adds two new classes to scaling.py:
Adds staticmethod get_node_weights to GraphForecaster which uses the new scaling methods if they are set in the config.
Configuration options Specified in config.training.loss_scaling.spatial, for instance:
Further comments
Thanks to Magnus Ingstad, Jasper Wijnands and Sophie Buurman and Mario Santa Cruz for their contributions to this PR.