-
Notifications
You must be signed in to change notification settings - Fork 184
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
Dgmr #813
Dgmr #813
Conversation
Thanks for your contribution! |
- mode | ||
- output_dir | ||
- log_freq | ||
sweep: |
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.
参考其他配置文件,加上callback字段
examples/dgmr/conf/dgmr.yaml
Outdated
split: validation # train or validation | ||
NUM_INPUT_FRAMES: 4 | ||
NUM_TARGET_FRAMES: 18 | ||
dataset_path: /workspace/workspace/skillful_nowcasting/openclimatefix/nimrod-uk-1km |
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/dgmr/conf/dgmr.yaml
Outdated
DATALOADER: | ||
batch_size: 1 | ||
shuffle: False | ||
num_workers: 1 | ||
drop_last: True |
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.
dataloader配置放py文件,不需要写在这里
input_keys: ['input_frames'] | ||
output_keys: ['future_images'] |
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/dgmr/dgmr.py
Outdated
|
||
|
||
def train(cfg: DictConfig): | ||
print("Not supported.") |
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.
print("Not supported.") | |
raise NotImplementedError( | |
"Training of DGMR is not supported now." | |
) |
ppsci/arch/dgmr.py
Outdated
""" | ||
|
||
Args: | ||
x: tensor on the correct device, to move over the latent distribution | ||
|
||
Returns: | ||
|
||
""" |
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.
删多余空行
ppsci/arch/dgmr.py
Outdated
def __init__( | ||
self, input_channels: int, output_channels: int, ratio_kq=8, ratio_v=8 | ||
): | ||
super(AttentionLayer, self).__init__() |
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.
将super(XXX, self).__init__()
的写法全部改为super().__init__()
ppsci/data/dataset/dgmr_dataset.py
Outdated
NUM_INPUT_FRAMES: int = 4, | ||
NUM_TARGET_FRAMES: int = 18, |
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.
参数变量名小写
ppsci/data/dataset/dgmr_dataset.py
Outdated
self.NUM_INPUT_FRAMES = NUM_INPUT_FRAMES | ||
self.NUM_TARGET_FRAMES = NUM_TARGET_FRAMES |
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.
小写
ppsci/data/dataset/dgmr_dataset.py
Outdated
def __len__(self): | ||
return self.number | ||
|
||
def __getitem__(self, item): |
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.
item==>idx
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.
所有paddle.nn.xxx的调用方式改为nn.xxx
ppsci/arch/dgmr.py
Outdated
""" | ||
Spatial discriminator from Skillful Nowcasting, see https://arxiv.org/pdf/2104.00954.pdf | ||
|
||
Args: | ||
input_channels: Number of input channels per timestep | ||
num_timesteps: Number of timesteps to use, in the paper 8/18 timesteps were chosen | ||
num_layers: Number of intermediate DBlock layers to use | ||
conv_type: Type of 2d convolutions to use, see satflow/models/utils.py for options | ||
""" |
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.
__init__
方法的 docstring 移动到SpatialDiscriminator
下方
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.
class的__init__
方法的 docstring 移动到class的下方
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.
docstring格式不规范,重新用vscode插件生成下
ppsci/arch/dgmr.py
Outdated
raise ModuleNotFoundError( | ||
"Please install einops with 'pip install einops'" | ||
" before exporting DGMR model." | ||
) |
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.
不需要抛出异常,改为pass即可
ppsci/arch/dgmr.py
Outdated
""" | ||
Temporal Discriminator from the Skillful Nowcasting, see https://arxiv.org/pdf/2104.00954.pdf | ||
|
||
Args: | ||
input_channels: Number of channels per timestep | ||
crop_size: Size of the crop, in the paper half the width of the input images | ||
num_layers: Number of intermediate DBlock layers to use | ||
conv_type: Type of 2d convolutions to use, see satflow/models/utils.py for options | ||
""" |
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.
python类的__init__
的docstring,统一放到类下方,而不是__init__
下方
ppsci/arch/dgmr.py
Outdated
|
||
def forward(self, x: paddle.Tensor) -> paddle.Tensor: | ||
""" | ||
|
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.
删除空行
ppsci/data/dataset/dgmr_dataset.py
Outdated
|
||
import numpy as np | ||
import paddle | ||
from datasets import load_dataset |
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.
不要从模块中直接导入方法,而是通过导入模块再调用,改为像einops一样用try导入 import datasets
ppsci/data/dataset/dgmr_dataset.py
Outdated
self.num_input_frames = num_input_frames | ||
self.num_target_frames = num_target_frames | ||
self.number = number | ||
self.reader = load_dataset( |
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.
datasets.load_dataset
docs/zh/examples/dgmr.md
Outdated
=== "模型训练命令" | ||
|
||
``` sh | ||
python dgmr.py | ||
``` | ||
|
||
=== "模型评估命令" | ||
|
||
``` sh | ||
python dgmr.py mode=eval EVAL.pretrained_model_path=https://paddle-org.bj.bcebos.com/paddlescience/models/dgmr/dgmr_pretrained.pdparams | ||
``` |
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.
) | ||
plt.subplots_adjust(hspace=0.1, wspace=0.1) | ||
plt.savefig(osp.join(output_dir, f"Generated_Image_Frame_{batch_idx}.png")) | ||
|
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.
末尾加一行plt.close()
examples/dgmr/dgmr.py
Outdated
cfg: DictConfig, | ||
solver: ppsci.solver.Solver, | ||
batch: tuple, | ||
batch_idx: int, |
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/dgmr/dgmr.py
Outdated
def validation( | ||
cfg: DictConfig, | ||
solver: ppsci.solver.Solver, | ||
batch: tuple, |
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.
- 使用Tuple而不是tuple
- 写清楚Tuple里的内容
examples/dgmr/dgmr.py
Outdated
Args: | ||
cfg (DictConfig): Configuration object. | ||
solver (ppsci.solver.Solver): Solver object containing the model and related components. | ||
batch (tuple): Input batch consisting of images and corresponding future images. |
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.
同batch修改
ppsci/data/dataset/dgmr_dataset.py
Outdated
try: | ||
row = next(self.iter_reader) | ||
except Exception: | ||
rng = default_rng() |
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.
这里得固定下seed,不然会有随机
ppsci/data/dataset/dgmr_dataset.py
Outdated
|
||
Examples: | ||
>>> import ppsci | ||
>>> dataset = ppsci.data.dataset.DGMRDataset(("input", ), ("output", )) |
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.
45行末尾加上: # doctest: +SKIP
ppsci/arch/dgmr.py
Outdated
>>> output_dict = model(input_dict) | ||
>>> print(output_dict["output"].shape) |
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.
末尾加上: # doctest: +SKIP
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.
LGTM
* add bubble datafile test=develop * add bubble code test=develop * add bubble code test=develop * add bubble code test=develop * add bubble code * add bubble data * add bubble code * add some code for chip * add some code for DGMR * add some code for DGMR * add some code for DGMR * add some dgmr code * add some dgmr code * add some dgmr code * add some dgmr code * add some dgmr code * add some dgmr code * add some dgmr code * add some dgmr code * add some dgmr code * add some dgmr code * add some dgmr code * add some dgmr code * add some dgmr code * add some dgmr code * add some dgmr code * add some dgmr code * add some dgmr code * add some dgmr code * add some dgmr code * add some dgmr code * add some dgmr code
PR types
One of dgmr eval code
PR changes
One of APIs
Describe
dgmr eval code