-
Notifications
You must be signed in to change notification settings - Fork 234
9.30 Project #1223
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
9.30 Project #1223
Conversation
|
Thanks for your contribution! |
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.
tofix
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.
需要按照代码规范进行修改:
- 整理相关requirements
- 修改ipynb为py文件,进行代码的整理
- 使用pre-commit进行代码清理
- 补充文档,暂时放在当前文件夹
https://paddlescience-docs.readthedocs.io/zh-cn/latest/zh/development/#4
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/下面,然后使用这种方法注册到ppsci.data里,可以给XXXConstraint初始化时使用
## examples/era5_land_dataset.py
from ppsci.data import register_to_dataset
class ToyTwoModalDataset(Dataset):
pass
register_to_dataset(ToyTwoModalDataset) # hereThere 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.
to fix
| import paddle.nn as nn | ||
|
|
||
|
|
||
| # ========================= |
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 NLinear(nn.Layer): | ||
| """PackedEnsemble: K 份 Linear 打包 → 输入 (B,K,D), 权重 (K, I, O)""" |
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().__init__() | ||
| self.k, self.in_f, self.out_f = k, in_f, out_f | ||
| self.weight = self.create_parameter(shape=[in_f, out_f]) # 共享权重 |
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 self.min_adapter is not None: | ||
| x = self.min_adapter(x) | ||
| feats = self.backbone(x) # (B,K,H) | ||
| return feats.mean(axis=1) if self.reduce else feats # (B,H) 或 (B,K,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.
同上
ppsci/loss/bce.py
Outdated
| return losses | ||
|
|
||
|
|
||
| # ------------------------------------------------------------ |
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.
此处注释删掉
| return y.squeeze(1), aux | ||
|
|
||
|
|
||
| # ====================== Self-Attention Transformer(可 MoE) ====================== |
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.
同上
| return x, aux_total | ||
|
|
||
|
|
||
| # ====================== AFNO(1D) + MoE FFN ====================== |
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 AFNO1DLayer(nn.Layer): | ||
| """ | ||
| 自适应傅里叶算子(时间 1D 版): | ||
| - 对 (B,T,D) 沿 T 做 rFFT → (B,D,F) |
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 __getitem__(self, idx: int): | ||
| ###返回三个字典 | ||
| return {"video": self.video[idx], "vec": self.vec[idx]}, {"y": self.y[idx]}, {} | ||
| # return self.video[idx], self.vec[idx], self.y[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.
删除无用注释
| def __len__(self): | ||
| return self.n | ||
|
|
||
| ###在这个基础上加constraint,构建已有约束,Loss Focal BCE,valid_dataloader_cfg,加input和label |
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.
to fix
ppsci/loss/bce.py
Outdated
| self, output_dict, label_dict, weight_dict=None | ||
| ) -> Dict[str, "paddle.Tensor"]: | ||
| losses: Dict[str, paddle.Tensor] = {} | ||
| # print(label_dict) |
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
ppsci/loss/bce.py
Outdated
| # final global/per-key weighting like in L2Loss | ||
|
|
||
| losses[key] = loss | ||
| print(losses) |
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
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.
尽快用pre-commit过一下代码规范CI
PR types
PR changes
Describe