FGN (Functional Generative Networks) was proposed by Google DeepMind and is the probabilistic global weather forecasting model in the WeatherNext series (WeatherNext2). FGN uses the fair continuous ranked probability score (fair CRPS) of the marginal distribution as its training objective. It models aleatoric uncertainty by injecting a global noise vector into conditional normalization layers and epistemic uncertainty through an ensemble of independently trained models. In this way, it captures the joint spatial structure of ensemble forecasts while optimizing only pointwise marginal objectives, and surpasses GenCast and ECMWF ENS across 15-day medium-range forecasts.
Paper:Skilful joint probabilistic weather forecasting from marginals
FGN uses a GNN encoder-processor-decoder architecture consistent with the GenCast denoiser: a sparse GNN encoder maps latitude-longitude grid inputs to a latent space on a six-times-subdivided icosahedral grid, a graph-transformer processor advances the atmospheric state on that grid, and a GNN decoder maps the latent grid back to the output grid. Each forecast samples a 32-dimensional global noise vector, embeds it with a single matrix multiplication, and injects it into all conditional LayerNorm layers (equivalent to applying a learned functional perturbation to the network parameters) as the source of ensemble spread. Under a second-order Markov assumption (using the two previous frames), the model generates forecasts autoregressively at 6-hour intervals. This repository is a minimal reproduction based on the paper and is integrated with the OneScience data loading and training workflow.
Use Cases
Scenario
Description
Probabilistic/ensemble medium-range weather forecasting research
Learn pointwise marginal distributions with CRPS and generate joint ensemble forecasts.
Uncertainty modeling research
Reproducible parameter-space noise injection (conditional normalization) and deep ensemble mechanisms.
Graph + Transformer latent-space model research
Encoder-processor-decoder architecture and fair CRPS objective.
Local quick validation
Use synthetic data to check data loading, training, inference, and result scripts.
ModelScope/OneCode execution
Download the model package, install dependencies, and run the scripts directly.
Multi-card training
Launch multi-process training with torchrun.
Usage
1. OneCode Usage
Use the OneCode online environment for intelligent one-click AI4S programming:
The OneScience community provides ERA5 data for training (the current repository contains complete data slices subject to data-file size limits). Download it with the command below and confirm that the data path in conf/config.yaml is correct:
For a quick workflow validation, run the synthetic data script first:
python scripts/fake_data.py
Note: scripts/fake_data.py generates [T, C, H, W] data from second-order Markov inputs, forecast steps, batch size, and grid_shape. The current small configuration uses 6 channels and a 32×32 grid.
The weight/ folder is reserved for model weights. Pretrained weights are not provided by default; users may train the model using the paper configuration. The paper model (per-seed latent dimension 768, 24 processor layers, an ensemble of 4 model seeds, and approximately 490 TPU-days of total computation) has no publicly released weights.
Inference
Inference reads data/checkpoints/model_bak.pth by default, generates num_members ensemble members for each initialization time (independently sampling global noise for each), and uses the member mean as the deterministic forecast output:
python scripts/inference.py
Prediction results are written frame by frame to:
result/output/
Evaluation and Visualization
python scripts/result.py
Outputs include:
result/rmse.npy
result/acc.npy
result/loss.png
Forecast comparison plots for the specified date and variables
Differences from the paper (due to the OneScience gridded data pipeline and connectivity-validation scale): the paper uses a six-times-subdivided icosahedral latent grid (approximately 40k nodes) and a 0.25° (1440×721) output grid, with approximately 180M parameters per seed. This reproduction uses a fixed regular 8-neighbor latent grid (mesh_shape), ERA5 gridded h5 channels as input placeholders, and a default latent dimension of 64. The number of latent-grid nodes and edge features are determined by the mesh_shape and channel_weights configurations.
The following details are not disclosed in the paper and are assumptions in this reproduction:the specific projection from noise to each layer's scale/shift in conditional LayerNorm (currently implemented with per-layer linear projections initialized to zero so the initial behavior is standard LayerNorm); per-channel weights for the multi-task loss (currently all 1 by default); and the evaluation convention of using the ensemble mean as the deterministic forecast for probabilistic output.
Paper-level reproduction requires the four-stage training procedure in the paper (ERA5 1°12h → 1°6h → 0.25°6h → HRES-fc0 0.25° AR fine-tuning); conf/config.yaml uses a small configuration for connectivity validation by default.
This repository is an independent FGN (WeatherNext2) reproduction (the model code is an original minimal implementation), with the architecture design based on the paper by Alet et al. (2025).
Please cite:Alet, F., Price, I., El-Kadi, A., Masters, D., Markou, S., Andersson, T. R., Stott, J., Lam, R., Willson, M., Sanchez-Gonzalez, A. and Battaglia, P. Skilful joint probabilistic weather forecasting from marginals. arXiv:2506.14285, 2025.