计算数据预训练后再用实验数据微调,预测 logD7.4,代码:PCFE-GNNs,原文:Improved GNNs for Log D7.4 Prediction by Transferring Knowledge from Low-Fidelity Data,代码解析继续downstream_task。模型框架如下:
文章目录
- 1.pretrain.py
1.pretrain.py
if __name__ == "__main__":
import argparse
import os
from configure import get_exp_configure
parser = argparse.ArgumentParser(description='Regression model')
parser.add_argument('-m', '--model', type=str,
choices=['GCN','GAT','Weave','AttentiveFP','MPNN', 'SchNet', 'MGCN'],
default='GCN',
help='Model to use')
parser.add_argument('-mt', '--metric_name', type=str, default='R2',
help='Meter')
parser.add_argument('-t', '--task', type=str, default='caco2',
help='data path')
args = parser.parse_args().__dict__
args['task'] = r'chembl_CXlogD_1711398.csv'
args['model'] = 'AttentiveFP'
args['weights_path'] = 'weights/AttentiveFP_chembl-CX_pretraining_weights.pth'
args['smiles_columns'] = 'Smiles'
args['task_names'] = ['CX LogD']
args['exp'] = args['model']
args.update(get_exp_configure(args['exp']))
args['mode'] = 'higher'
args['n_tasks'] = 1
args['metric_name'] = 'R2'
args['random_seed'] = 7
os.environ["CUDA_VISIBLE_DEVICES"] = '0'
args['device'] = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
if torch.cuda.is_available():
print('GPU: ', os.environ["CUDA_VISIBLE_DEVICES"],
torch.cuda.get_device_properties(torch.cuda.current_device()))
print(args['task'], '\t',args['model'], '\t', args['random_seed'])
test_score, mse_score, mae_score = main(args)
print('best R2:',test_score)
print('best mse:',mse_score)
print('best mae:',mae_score)