chainer / chainer-chemistry

Chainer Chemistry: A Library for Deep Learning in Biology and Chemistry
MIT License
629 stars 131 forks source link

about transfer learning #420

Open rookiecoder-chen opened 4 years ago

rookiecoder-chen commented 4 years ago

Is it right for me to do this? The code works, but I don't know if this is the right process...

Set up the regressor.

device = chainer.get_device(args.device)
model_path = os.path.join(args.in_dir, args.model_filename)
metrics_fun = {'mae': F.mean_absolute_error, 'rmse': rmse}
regressor = Regressor.load_pickle('result/pretrain_qm9.pkl', device=device)
mlp = MLP(out_dim=class_num, hidden_dim=args.unit_num)
predictor = regressor.predictor
new_predictor = GraphConvPredictor(predictor, mlp=mlp)
new_regressor = Regressor(new_predictor,lossfun=F.mean_squared_error,
                      metrics_fun=metrics_fun, device=device)

print('Training...')
run_train(new_regressor, dataset, valid=None, batch_size=args.batchsize, epoch=args.epoch, out=args.out,
          device=device, converter=megnet_converter, resume_path=None,
          extensions_list=[extensions.PlotReport(['main/loss', 'validation/main/loss'], 'epoch',
                                                 filename='-trans-megnet-full-loss.svg', marker='None'),
                           extensions.PlotReport(['main/rmse', 'validation/main/rmse'], 'epoch',
                                                 filename='trans-megnet-full-rmse.svg', marker='None'),
                           extensions.PlotReport(['main/mae', 'validation/main/mae'], 'epoch',
                                                 filename='trans-megnet-full-mae.svg', marker='None')])
corochann commented 4 years ago

I think it's okay if you want to start from the pre-trained weight of predictor while want to train mlp part from scratch!

rookiecoder-chen commented 4 years ago

I want to use megnet to pre train a qm9 model, and then use the weight of this model to continue to train my own data, because my data set is very small, but I don't seem to know if transfer learning is used in this way?

corochann commented 4 years ago

I think this is okay to start trying transfer learning in this way.

rookiecoder-chen commented 4 years ago

But the experimental results are very poor. I just want to use the weight of megnet part and how to set my new_predictor and new_megnet model?