THUNLP-MT / PS-VAE

This repo contains the codes for our paper: Molecule Generation by Principal Subgraph Mining and Assembling.
https://arxiv.org/abs/2106.15098
MIT License
32 stars 8 forks source link

Errors in property iteration #12

Open lajictw opened 1 year ago

lajictw commented 1 year ago

Dear author,

Hi. When running train.py for qm9 dataset, I met the following errors.

Traceback (most recent call last): File "D:\PaperCode\PS-VAE\src\train.py", line 133, in config = {common_config(args), encoder_config(args, vocab), **predictor_config(args)} File "D:\PaperCode\PS-VAE\src\utils\nn_utils.py", line 148, in common_config 'selected_properties': map_prop_to_idx(args.props) File "D:\PaperCode\PS-VAE\src\evaluation\utils.py", line 129, in map_prop_to_idx for p in props: TypeError: 'NoneType' object is not iterable

I run the command as shown below。

python train.py --train_set ..\data\qm9\train.txt --valid_set ..\data\qm9\valid.txt --test_set ..\data\qm9\test.txt --vocab ..\ckpts\qm9\qm9_guaca_goal\qm9_bpe_101.txt --batch_size 32 --shuffle --alpha 0.1 --beta 0 --max_beta 0.01 --step_beta 0.002 --save_dir qm9_exps\ckpt\mine

I'm not sure if my input is legit because I'm not sure if the file selected for my vocab entry is correct. At your convenience can you add instructions for the folders qm9_guaca_dist and qm9_guaca_dist. This would help us to try to reproduce the results you have achieved on the qm9 dataset. Thanks! A screenshot is attached below. image

kxz18 commented 1 year ago

Hi, sorry for the ambiguity in the instructions. The distribution learning shares the same procedure as in property prediction. The dataset and the vocab entry you are using is correct. I noticed that the error occurred because of the missing argument "props", so I've added a default value for the argument. Now it should be fine to first train the model and then validate it on the guacamol distribution learning benchmark.

lajictw commented 1 year ago

Thanks for your help! I have a further question. Are all parameters required when run the train.py or only parameters with require mark are required

kxz18 commented 1 year ago

I've just updated the default parameters. Now it should be fine to only specify the arguments with require mark.

lajictw commented 1 year ago

First, thanks for your help, But, actually, I mean the gpus parameter. If I leave it blank, it reports

AttributeError: 'NoneType' object has no attribute 'split'

If I set it equal to zero, as my cuda is available, it reports

TypeError: init() got an unexpected keyword argument 'gpus'

But in yout example script for training, you have the gpus parameters. This makes me really confuse. Screenshot for your example script, my result with leaving parameter gpus blank, and result with setting it equal to zero is attached below. image image image

A screenshot showing cuda is available is also attached below. image

kxz18 commented 1 year ago

May I ask the version of pytorch-lightning you are using? The API of pytorch-lightning is changing. In version 1.5.7 which is specified in the requirements.txt, the trainer has an argument named "gpus" (see here). However, in latest versions, the argument has been changed to "accelerator" and "devices" (see here). Therefore I suspect the problem you encountered when setting "--gpus 0" is because of the incompatible version of pytorch-lightning.

lajictw commented 11 months ago

Thank you! The information you provided was really helpful. Can you please facilitate the training setup data for the QM9 dataset. Because I see that the README document only provides training data for the ZINC dataset. And I couldn't find the ckpt document mentioned in your documentation.

kxz18 commented 11 months ago

Training data for QM9 is here, and checkpoints are provided here. "ckpts/{dataset}/{dataset}_guaca_dist/epoch{n}.ckpt" is used for guacamol distribution learning benchmark, where dataset can be qm9 or zinc250k. Similarly, the checkpoint in "{dataset}_guaca_goal" is used for guacamol goal-directed benchmark.

lajictw commented 11 months ago

Thank you for your response! But what I would prefer to know, if possible, is the individual parameters of the QM9 training. For example learning rate, epoch value etc. thanks!

kxz18 commented 11 months ago

I just looked into the checkpoint directory and found what appeared to be the parameter settings as follows:

python train.py \ --train_set ../data/qm9/train.txt \ --valid_set ../data/qm9/valid.txt \ --test_set ../data/qm9/test.txt \ --vocab ../ckpts/qm9/qm9_guaca_dist/qm9_bpe_101.txt \ --batch_size 32 \ --shuffle \ --alpha 0.1 \ --beta 0 \ --max_beta 0.01 \ --step_beta 0.002 \ --kl_anneal_iter 1000 \ --kl_warmup 0 \ --lr 1e-3 \ --save_dir zinc_exps/ckpt/yours \ --grad_clip 10.0 \ --epochs 6 \ --gpus 0 \ --props qed logp \ --latent_dim 56 \ --node_hidden_dim 300 \ --graph_embedding_dim 400 \ --patience 3