-
Notifications
You must be signed in to change notification settings - Fork 204
【Hackathon 8th No.17】FuXi 论文复现 #1145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
Thanks for your contribution! |
docs/zh/examples/fuxi.md
Outdated
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改。
examples/fuxi/conf/fuxi.yaml
Outdated
# inference settings | ||
INFER: | ||
pretrained_model_path: null | ||
export_path: inference/fengwu_v2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fengwu?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改。
README.md
Outdated
@@ -118,6 +118,7 @@ PaddleScience 是一个基于深度学习框架 PaddlePaddle 开发的科学计 | |||
| 天气预报 | [NowCastNet 气象预报](https://paddlescience-docs.readthedocs.io/zh-cn/latest/zh/examples/nowcastnet) | 数据驱动 | GAN | 监督学习 | [MRMS](https://app.globus.org/file-manager?origin_id=945b3c9e-0f8c-11ed-8daf-9f359c660fbd&origin_path=%2F~%2Fdata%2F) | [Paper](https://www.nature.com/articles/s41586-023-06184-4) | | |||
| 天气预报 | [GraphCast 气象预报](https://paddlescience-docs.readthedocs.io/zh-cn/latest/zh/examples/graphcast) | 数据驱动 | GNN | 监督学习 | - | [Paper](https://arxiv.org/abs/2212.12794) | | |||
| 天气预报 | [GenCast 气象预报](https://paddlescience-docs.readthedocs.io/zh-cn/latest/zh/examples/gencast) | 数据驱动 | Diffusion+Graph transformer | 监督学习 | [Gencast](https://console.cloud.google.com/storage/browser/dm_graphcast) | [Paper](https://arxiv.org/abs/2312.15796) | | |||
| 天气预报 | [Fuxi 气象预报](./zh/examples/fuxi.md) | 数据驱动 | Transformer | 监督学习 | - | [Paper](https://arxiv.org/abs/2304.02948) | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
paper的链接不对,打开是FengWu,不是FuXi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改。
docs/index.md
Outdated
@@ -151,6 +151,7 @@ | |||
| 天气预报 | [NowCastNet 气象预报](./zh/examples/nowcastnet.md) | 数据驱动 | GAN | 监督学习 | [MRMS](https://app.globus.org/file-manager?origin_id=945b3c9e-0f8c-11ed-8daf-9f359c660fbd&origin_path=%2F~%2Fdata%2F) | [Paper](https://www.nature.com/articles/s41586-023-06184-4) | | |||
| 天气预报 | [GraphCast 气象预报](./zh/examples/graphcast.md) | 数据驱动 | GNN | 监督学习 | - | [Paper](https://arxiv.org/abs/2212.12794) | | |||
| 天气预报 | [GenCast 气象预报](./zh/examples/gencast.md) | 数据驱动 | Diffusion+Graph transformer | 监督学习 | [Gencast](https://console.cloud.google.com/storage/browser/dm_graphcast) | [Paper](https://arxiv.org/abs/2312.15796) | | |||
| 天气预报 | [Fuxi 气象预报](./zh/examples/fuxi.md) | 数据驱动 | Transformer | 监督学习 | - | [Paper](https://arxiv.org/abs/2304.02948) | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
paper的链接不对,打开是FengWu,不是FuXi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改。
docs/zh/examples/fuxi.md
Outdated
|
||
## 1. 背景简介 | ||
|
||
FuXi 是阿里巴巴达摩院开发的一款级联机器学习天气预报系统,其目标是提供长达15天的全球天气预报。尽管现有先进的机器学习模型在10天预测中已展现出超越传统数值预报系统的性能,但长期预测中误差累积仍然是一个挑战。FuXi 的研发旨在克服这一难题,力求在15天的预测中达到与顶尖数值预报系统(如 ECMWF)整体平均水平相当的精度,其开发基于长达39年的 ECMWF ERA5 再分析数据集。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- FuXi 是阿里巴巴达摩院开发的参考依据是啥?文章的作者是复旦大学的
- 背景简介可以稍微丰富一些
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改。
docs/zh/examples/fuxi.md
Outdated
|
||
## 2. 模型原理 | ||
|
||
FuXi 采用级联模型结构,针对三个连续的预测时间段(0-5天、5-10天和10-15天)分别进行了优化。这种设计旨在减缓长期预测中的误差累积。此外,FuXi 还发展出 FuXi-Extreme 模型,该模型在标准的 FuXi 基础上融入了去噪扩散概率模型 (DDPM), 用于增强前5天地表预报数据的细节和质量。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 模型原理部分过于简单,模型架构、如何使用FuXi生成 15 天预测、损失函数及评估方法等都需要详细介绍一下,可以完全按照文章中的相关部分翻译一下
- 需要对使用的数据进行简单介绍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改。
docs/zh/examples/fuxi.md
Outdated
|
||
## 6. 结果展示 | ||
|
||
example中展示了15天全球天气预报,具体指标可以使用 ncvue 查看。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
需要上传一张可视化的结果图
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改。
docs/zh/examples/fuxi.md
Outdated
|
||
``` py linenums="74" title="examples/fuxi/predict.py" | ||
--8<-- | ||
examples/fuxi/predict.py:46:131 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
代码显示不对应
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改。
examples/fuxi/conf/fuxi.yaml
Outdated
max_batch_size: 1 | ||
num_cpu_threads: 10 | ||
batch_size: 1 | ||
input_file: './data/input1.npy' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
./data/input1.npy是什么数据?好像并没有用到
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已删除,代码中不需要。
examples/fuxi/predict.py
Outdated
|
||
# output_data_list.append(output_data) | ||
print( | ||
f"global_step: {global_step+1:02d}, output: {input_data.min():.2f} {input_data.max():.2f}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
原代码打印的是output.min,output.max,请与原代码保持一致
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改。
) | ||
|
||
if step > total_step: | ||
break |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
请添加对模型输出结果保存及可视化的代码,可参考fengwu或pangu_weather案例
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改。
examples/fuxi/requirementx.txt
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
requirements.txt,文件名写错啦
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改。
docs/zh/examples/fuxi.md
Outdated
|
||
## 4. 结果可视化 | ||
|
||
使用 `examples/fuxi/predict.py` 进行画图,进行结果可视化。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
应该是visualize.py吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改。
docs/zh/examples/fuxi.md
Outdated
|
||
模型推理结果包含 60 个 NetCDF 文件,表示从预测时间点开始,未来 15 天内每个模型20个时间步的气象数据。 | ||
|
||
使用 `examples/fuxi/predict.py` 进行画图,进行结果可视化。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
应该是visualize.py吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改。
examples/fuxi/util.py
Outdated
def visualize(save_name, vars=[], titles=[], vmin=None, vmax=None): | ||
import cartopy.crs as ccrs | ||
import matplotlib.pyplot as plt | ||
|
||
fig, ax = plt.subplots( | ||
len(vars), 1, figsize=(8, 6), subplot_kw={"projection": ccrs.PlateCarree()} | ||
) | ||
|
||
def plot(ax, v, title): | ||
v.plot( | ||
ax=ax, | ||
x="lon", | ||
y="lat", | ||
vmin=vmin, | ||
vmax=vmax, | ||
transform=ccrs.PlateCarree(), | ||
add_colorbar=False, | ||
) | ||
# ax.coastlines() | ||
ax.set_title(title) | ||
gl = ax.gridlines(draw_labels=True, linewidth=0.5) | ||
gl.top_labels = False | ||
gl.right_labels = False | ||
|
||
for i, v in enumerate(vars): | ||
if len(vars) == 1: | ||
plot(ax, v, titles[i]) | ||
else: | ||
plot(ax[i], v, titles[i]) | ||
|
||
plt.savefig( | ||
save_name, bbox_inches="tight", pad_inches=0.1, transparent="true", dpi=200 | ||
) | ||
plt.close() | ||
|
||
|
||
def test_visualize(step, data_dir): | ||
src_name = os.path.join(data_dir, f"{step:03d}.nc") | ||
ds = xr.open_dataarray(src_name).isel(time=0) | ||
ds = ds.sel(lon=slice(90, 150), lat=slice(50, 0)) | ||
print(ds) | ||
u850 = ds.sel(level="U850", step=step) | ||
v850 = ds.sel(level="V850", step=step) | ||
ws850 = np.sqrt(u850**2 + v850**2) | ||
visualize( | ||
f"ws850/{step:03d}.jpg", [ws850], [f"20230725-18+{step:03d}h"], vmin=0, vmax=30 | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这部分代码和examples/fuxi/visualize.py重复了,可以删掉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已删除。
README.md
Outdated
@@ -118,6 +118,7 @@ PaddleScience 是一个基于深度学习框架 PaddlePaddle 开发的科学计 | |||
| 天气预报 | [NowCastNet 气象预报](https://paddlescience-docs.readthedocs.io/zh-cn/latest/zh/examples/nowcastnet) | 数据驱动 | GAN | 监督学习 | [MRMS](https://app.globus.org/file-manager?origin_id=945b3c9e-0f8c-11ed-8daf-9f359c660fbd&origin_path=%2F~%2Fdata%2F) | [Paper](https://www.nature.com/articles/s41586-023-06184-4) | | |||
| 天气预报 | [GraphCast 气象预报](https://paddlescience-docs.readthedocs.io/zh-cn/latest/zh/examples/graphcast) | 数据驱动 | GNN | 监督学习 | - | [Paper](https://arxiv.org/abs/2212.12794) | | |||
| 天气预报 | [GenCast 气象预报](https://paddlescience-docs.readthedocs.io/zh-cn/latest/zh/examples/gencast) | 数据驱动 | Diffusion+Graph transformer | 监督学习 | [Gencast](https://console.cloud.google.com/storage/browser/dm_graphcast) | [Paper](https://arxiv.org/abs/2312.15796) | | |||
| 天气预报 | [Fuxi 气象预报](./zh/examples/fuxi.md) | 数据驱动 | Transformer | 监督学习 | - | [Paper](https://arxiv.org/abs/2306.12873) | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改。
examples/fuxi/visualize.py
Outdated
visualize( | ||
f"{save_dir}/{step:03d}.jpg", | ||
[ws850], | ||
[f"Weather forecasting in 20230725-18+{step:03d}h"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
850 hPa Wind Speed Forecasting (m/s) in 20231012-00+{step:03d}h
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改。
docs/zh/examples/fuxi.md
Outdated
使用 `examples/fuxi/predict.py` 进行画图,进行结果可视化。 | ||
|
||
```python | ||
python3.10 visualize.py --data_dir outputs_fuxi_pd/ --save_dir outputs_fuxi_pd/ --step 6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
路径需要和yaml文件中一致,yaml中并没有outputs_fuxi_pd/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改。
|
||
def predict( | ||
self, input_data, tembs, global_step, stage, num_step, data, batch_size: int = 1 | ||
): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
返回值加上type hint
Args: | ||
input_data_prev(np.ndarray): Atomospheric data at the first time moment. | ||
input_data_next(np.ndarray): Atmospheric data six later. | ||
batch_size (int, optional): Batch size, now only support 1. Defaults to 1. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Args下的参数描述和实际函数参数对不上
v850 = ds.sel(level="V850", step=step) | ||
ws850 = np.sqrt(u850**2 + v850**2) | ||
visualize( | ||
f"{save_dir}/{step:03d}.jpg", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f"{save_dir}/{step:03d}.jpg", | |
os.path.join(save_dir, f"{step:03d}.jpg") |
|
||
在该案例中,实现了 FuXiPredictor用于ONNX模型的推理: | ||
|
||
``` py linenums="74" title="examples/fuxi/predict.py" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
``` py linenums="74" title="examples/fuxi/predict.py" | |
``` py linenums="44" title="examples/fuxi/predict.py" |
PR types
New Features
PR changes
Others
Describe
support FuXi inference