Skip to content
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

ddpm #915

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft

ddpm #915

wants to merge 1 commit into from

Conversation

zhaojiameng
Copy link

PR types

new feature

PR changes

new ddpm.py in ppsci.arch;new ddpm folder in example folder.

Describe

Copy link

paddle-bot bot commented May 30, 2024

Thanks for your contribution!

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@lijialin03
Copy link
Contributor

git 提交之前需要先用pre-commit进行检查,可参考https://zhuanlan.zhihu.com/p/590275006等,安装pre-commit

Copy link
Contributor

@lijialin03 lijialin03 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

辛苦提交代码~请注意:

  1. 修改所有注释为英文半角,删除不必要的注释
  2. 为重要的函数和类写hints
  3. 修改含义不明的变量,变量名有意义,但不要太长
  4. 注意文件中的代码排布,尽量将同类功能的代码放在同个文件或同个部分,如plot相关的代码放一起
  5. 删除冗余代码,如没有用到的函数或变量赋值
  6. 修改代码实现格式
  7. 重新提交时使用pre-commit进行检查
    谢谢

@@ -0,0 +1,64 @@
mode: train
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

config文件格式请参考其他案例(如aneurysm)修改,增加hydra部分,剩余参数分为MODEL/TRAIN/EVAL和其他,并精简删除没有用到的参数

resume_training: false
data:
dataset: "kolmogorov flow"
data_dir: "/home/aistudio/data/data264003/train_data.npy"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

修改路径为ddpm下的相对路径,之后yaml文件中的其他路径也是

@@ -0,0 +1,50 @@
log_dir: "./experiments/kmflow_re1000_rs256_ddim_recons_conditional_log"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上一个文件

@@ -0,0 +1,201 @@
import paddle
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

请删除函数中的注释(除了特别需要解释的部分),复杂函数开头写上hint,注释需要使用英文、半角,修改后请使用pre-commit检查代码格式

dx_func = kwargs.get("dx_func", None)
clamp_func = kwargs.get("clamp_func", None)
cache = kwargs.get("cache", False)
logger = kwargs.get("logger", None)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

请参考paddlescience格式修改:

  1. 此处是否可以删除某些变量的设置,如logger
  2. kwargs.get试图获取“ dx_func”对应的变量,如果没有就设置dx_func=None,请参考其他example将这种写法修改为def ddim_steps(dx_func:xxtype(如int)=None)

def transform_out(outputs):
loss = (outputs[1] - outputs[0]).square().sum(axis=(1, 2, 3)).mean(axis=0)

return {"loss": loss}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为什么输出为loss?

Returns:
paddle.Tensor: Loss value.
"""
return result_dict["loss"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个函数似乎没有必要?是还没写完吗

return x


def voriticity_residual_train(w, re=1000.0, dt=1 / 32):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这部分和functions中的有重复吗?如果有的话需要提取和整理,尽量避免重复代码



def get_beta_schedule_train(
beta_schedule, *, beta_start, beta_end, num_diffusion_timesteps
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个*的写法尽量修改

return betas


class EMAHelper(object):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个类是做什么的?也没在其他代码中找到

@HydrogenSulfate HydrogenSulfate marked this pull request as draft July 15, 2024 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants