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

[Example] Add AI4Chem example IFM(nips2023) #1002

Open
wants to merge 22 commits into
base: develop
Choose a base branch
from

Conversation

huhaohao525
Copy link

PR types

New features

PR changes

Others : Add new AI4Chem example.

Describe

Add new AI4Chem example including code and docs.

Copy link

paddle-bot bot commented Oct 10, 2024

Thanks for your contribution!

@CLAassistant
Copy link

CLAassistant commented Oct 10, 2024

CLA assistant check
All committers have signed the CLA.

Copy link
Collaborator

@HydrogenSulfate HydrogenSulfate left a comment

Choose a reason for hiding this comment

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

感谢提交PR,有一些修改建议如下

Comment on lines 1 to 21
hydra:
run:
# dynamic output directory according to running time and override name
dir: outputs_ifm/doc_metric #${now:%Y-%m-%d}/${now:%H-%M-%S}/${hydra.job.override_dirname}
job:
name: ${mode} # name of logfile
chdir: false # keep current working directory unchanged
config:
override_dirname:
exclude_keys:
- TRAIN.checkpoint_path
- TRAIN.pretrained_model_path
- EVAL.pretrained_model_path
- mode
- output_dir
- log_freq
sweep:
# output directory for multirun
dir: ${hydra.run.dir}
subdir: ./

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
hydra:
run:
# dynamic output directory according to running time and override name
dir: outputs_ifm/doc_metric #${now:%Y-%m-%d}/${now:%H-%M-%S}/${hydra.job.override_dirname}
job:
name: ${mode} # name of logfile
chdir: false # keep current working directory unchanged
config:
override_dirname:
exclude_keys:
- TRAIN.checkpoint_path
- TRAIN.pretrained_model_path
- EVAL.pretrained_model_path
- mode
- output_dir
- log_freq
sweep:
# output directory for multirun
dir: ${hydra.run.dir}
subdir: ./
defaults:
- ppsci_default
- TRAIN: train_default
- TRAIN/ema: ema_default
- TRAIN/swa: swa_default
- EVAL: eval_default
- INFER: infer_default
- hydra/job/config/override_dirname/exclude_keys: exclude_keys_default
- _self_
hydra:
run:
# dynamic output directory according to running time and override name
dir: outputs_ifm/doc_metric #${now:%Y-%m-%d}/${now:%H-%M-%S}/${hydra.job.override_dirname}
job:
name: ${mode} # name of logfile
chdir: false # keep current working directory unchanged
sweep:
# output directory for multirun
dir: ${hydra.run.dir}
subdir: ./



class IFMMoeDataset(io.Dataset):
"""Dataset for `MeshAirfoil`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

此处不是MeshAirfoil

return (num_indices - num_pos) / num_pos


class IFMMoeDataset(io.Dataset):
Copy link
Collaborator

Choose a reason for hiding this comment

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

请删除IFMMoeDataset内有关MeshAirfoil的文本,MeshAirfoil是翼型数据集,与化学无关

Comment on lines 314 to 315
# super().__init__()
pass
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
# super().__init__()
pass
super().__init__()

self.mask = ~np.isnan(Ys) * 1.0

def __len__(self):
pass
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
pass

return tn, fp, fn, tp, se, sp, acc, mcc, auc_prc, auc_roc


class Meter(object):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
class Meter(object):
class Meter:

return self.mcc()


class MyDataset(object):
Copy link
Collaborator

Choose a reason for hiding this comment

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

这个类有用到吗?

Comment on lines 262 to 277
def collate_fn(data_batch):
Xs, Ys, masks = map(list, zip(*data_batch))

Xs = paddle.stack(Xs, axis=0)
Ys = paddle.stack(Ys, axis=0)
masks = paddle.stack(masks, axis=0)

return Xs, Ys, masks


def set_random_seed(seed=0):
random.seed(seed)
np.random.seed(seed)
paddle.manual_seed(seed) # 为CPU设置种子用于生成随机数
if paddle.cuda.is_available():
paddle.cuda.manual_seed(seed) # 为当前GPU设置随机种子
Copy link
Collaborator

Choose a reason for hiding this comment

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

这两个函数是否与其他文件中的重复了?

Copy link
Collaborator

Choose a reason for hiding this comment

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

本文件是否可以删除?看起来每个函数在其他文件中都有实现

model,
output_dir=cfg.output_dir,
log_freq=cfg.log_freq,
seed=cfg.seed,
Copy link
Collaborator

Choose a reason for hiding this comment

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

seed设置这行可以删除

@HydrogenSulfate HydrogenSulfate changed the title add AI4Chem example IFM(nips2023) [Example] Add AI4Chem example IFM(nips2023) Oct 15, 2024
Comment on lines 409 to 415
inputs (int): Input dim.
hidden_units (List[int]): Units num in hidden layers.
outputs (int): Output dim.
dp_ratio (float): Dropout ratio.
first_omega_0 (float): Frequency factor used in first layer.
hidden_omega_0 (float): Frequency factor used in hidden layer.
reg (bool): Regularization flag.
Copy link
Collaborator

Choose a reason for hiding this comment

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

参数相比Args,要增加四个空格的缩进

Comment on lines 28 to 33
def init_parameter_uniform(
parameter: paddle.base.framework.EagerParamBase, n: int
) -> None:
ppsci.utils.initializer.uniform_(parameter, -1 / np.sqrt(n), 1 / np.sqrt(n))


Copy link
Collaborator

@HydrogenSulfate HydrogenSulfate Oct 24, 2024

Choose a reason for hiding this comment

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

examples/ifm/ednn_utils.py里的init_parameter_uniform函数是不是可以删除,另一个文件有这个函数,并且ednn_utils.py里的函数并没有被使用。

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