W-MAE
Model Introduction
W-MAE (Weather Masked AutoEncoder) is a pretraining model for multivariable weather forecasting.
Paper: W-MAE: Pre-trained weather model with masked autoencoder for multi-variable weather forecasting
https://arxiv.org/abs/2304.08754
Model Description
W-MAE first learns spatial relationships among weather variables through masked reconstruction, then learns temporal dependencies by fine-tuning on a forecasting task.
Use Cases
| Scenario | Description |
|---|---|
| Masked weather-field pretraining | Train the W-MAE reconstruction model with ERA5 HDF5 data that follows this project's protocol. |
| Local quick validation | Use synthetic HDF5 data to check loading, training, inference, and visualization of inference results. |
| ModelScope / OneCode execution | Download the standalone model package, configure data, and run the scripts directly. |
| Multi-GPU training | Launch PyTorch DistributedDataParallel with torchrun. |
Usage Guide
1. OneCode Usage
Experience intelligent one-click AI4S programming through the OneCode online environment:
Click to Experience Intelligent One-Click AI4S Programming
2. Manual Installation and Usage
Hardware Requirements
- A GPU or DCU is recommended.
- CPU can be used for import and small-scale connectivity verification; full training and inference will be slow.
- DCU users must install DTK in advance. DTK 25.04.2 or above, or the OneScience recommended version matching your cluster, is recommended.
Download the Model Package
hf download OneScience-Group/W-MAE --local-dir ./W-MAE
cd W-MAE
Install the Runtime Environment
DCU Environment
# Please activate DTK and CONDA first
conda create -n onescience311 python=3.11 -y
conda activate onescience311
# uv installation is supported
pip install onescience[earth-dcu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai
GPU Environment
# Please activate CONDA first
conda create -n onescience311 python=3.11 -y libstdcxx-ng=12 libgcc-ng=12 gcc_linux-64=12 gxx_linux-64=12
conda activate onescience311
# uv installation is supported
pip install onescience[earth-gpu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai
Training Data Introduction
The OneScience community provides an ERA5 data slice for training. Download it to the directory configured by data.dataset_dir in conf/config.yaml:
hf download --repo-type dataset OneScience-Group/ERA5 --local-dir ./data/era5
The W-MAE adapter expects yearly HDF5 files under data/era5/data/. Each file must contain a fields dataset, an ordered list of 20 channel names, six-hour time steps, and normalization statistics. Verify the physical ERA5 variable order before scientific training.
Generate Synthetic Data
When real ERA5 data is unavailable, generate protocol-compatible files for pipeline checks:
python scripts/fake_data.py
The synthetic files use placeholder channel names and must not be used for scientific evaluation.
Training
Single GPU:
python scripts/train.py
Multi-GPU:
torchrun --nproc_per_node=8 scripts/train.py
Training starts from random initialization and saves data/checkpoint/model_bak.pth by default. A compatible checkpoint can be supplied explicitly when continuing training.
Training Weights
This repository provides a weight/ directory for W-MAE checkpoints. The weight files will be uploaded soon and are expected to be available in the near future.
Inference
Inference reads data/checkpoint/model_bak.pth by default and writes compressed reconstruction samples to outputs/inference/:
python scripts/inference.py
Evaluation and Visualization
python scripts/result.py
The result script validates reconstruction files and writes diagnostic figures under outputs/inference/diagnostics/.
Official OneScience Resources
| Platform | OneScience Main Repository | Skills Repository |
|---|---|---|
| Gitee | https://gitee.com/onescience-ai/onescience | https://gitee.com/onescience-ai/oneskills |
| GitHub | https://github.com/onescience-ai/OneScience | https://github.com/onescience-ai/oneskills |
Citation and License
- This repository is an independent reproduction of the original W-MAE paper.
中文说明
模型简介
W-MAE(Weather Masked AutoEncoder)是面向多变量天气预报(weather forecasting)的预训练模型。
论文《W-MAE:使用掩码自编码器进行多变量天气预报的预训练天气模型》
https://arxiv.org/abs/2304.08754
模型描述
W-MAE 首先通过掩码重建学习气象变量之间的空间关系,再通过在预报任务上微调(fine-tuning)学习时间依赖关系。
使用场景
| 场景 | 说明 |
|---|---|
| 掩码气象场预训练 | 使用符合本项目协议的 ERA5 HDF5 数据训练 W-MAE 重建模型。 |
| 本地快速验证 | 使用合成 HDF5 数据检查加载、训练、推理(inference)和推理结果可视化。 |
| ModelScope / OneCode 运行 | 下载独立模型包、配置数据并直接运行脚本。 |
| 多 GPU 训练 | 通过 torchrun 启动 PyTorch DistributedDataParallel。 |
使用指南
1. OneCode 使用方法
通过 OneCode 在线环境体验智能一键 AI4S 编程。
2. 手动安装与使用
硬件要求
- 建议使用 GPU 或 DCU。
- 可使用 CPU 进行导入和小规模连通性验证,完整训练和推理速度较慢。
- DCU 用户必须提前安装 DTK。建议使用 DTK 25.04.2 或更高版本,或使用 OneScience 推荐的与所在集群匹配的版本。
下载模型包
hf download OneScience-Group/W-MAE --local-dir ./W-MAE
cd W-MAE
安装运行环境
DCU 环境
# Please activate DTK and CONDA first
conda create -n onescience311 python=3.11 -y
conda activate onescience311
# uv installation is supported
pip install onescience[earth-dcu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai
GPU 环境
# Please activate CONDA first
conda create -n onescience311 python=3.11 -y libstdcxx-ng=12 libgcc-ng=12 gcc_linux-64=12 gxx_linux-64=12
conda activate onescience311
# uv installation is supported
pip install onescience[earth-gpu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai
训练数据简介
OneScience 社区提供用于训练的 ERA5 数据切片。请将其下载到 data.dataset_dir(位于 conf/config.yaml 中)配置的目录。
hf download --repo-type dataset OneScience-Group/ERA5 --local-dir ./data/era5
W-MAE 适配器要求将年度 HDF5 文件放在 data/era5/data/ 下。每个文件必须包含一个 fields 数据集、20 个通道名的有序列表、六小时时间步长和归一化统计量。正式科研训练前,请核验 ERA5 物理变量顺序。
生成合成数据
真实 ERA5 数据不可用时,请生成协议兼容的文件以检查流程。
python scripts/fake_data.py
合成文件使用占位通道名,不得用于科学评估。
训练
单 GPU
python scripts/train.py
多 GPU
torchrun --nproc_per_node=8 scripts/train.py
训练从随机初始化开始,默认保存 data/checkpoint/model_bak.pth。继续训练时可显式提供兼容的模型权重(检查点)(checkpoint)。
训练权重
本仓库提供用于存放 W-MAE 模型权重(检查点)的 weight/ 目录。权重文件即将上传,预计近期可用。
推理
推理默认读取 data/checkpoint/model_bak.pth,并将压缩后的重建样本写入 outputs/inference/。
python scripts/inference.py
评估与可视化
python scripts/result.py
结果脚本验证重建文件,并将诊断图写入 outputs/inference/diagnostics/ 下。
OneScience 官方资源
| 平台 | OneScience 主仓库 | Skills 仓库 |
|---|---|---|
| Gitee | https://gitee.com/onescience-ai/onescience | https://gitee.com/onescience-ai/oneskills |
| GitHub | https://github.com/onescience-ai/OneScience | https://github.com/onescience-ai/oneskills |
引用与许可证
- 本仓库是对 W-MAE 原始论文的独立复现。
- Downloads last month
- 9