Giter VIP home page Giter VIP logo

Comments (3)

Noisyntrain avatar Noisyntrain commented on May 30, 2024

Hi gaoshan, thank you for using paddlehelix! As for the model inference, you can refer to the
Part III: Downstream Inference of the pretrained_compound tutorial. Hope this can be helpful to you.

from paddlehelix.

gaoshan2006 avatar gaoshan2006 commented on May 30, 2024

Hi gaoshan, thank you for using paddlehelix! As for the model inference, you can refer to the Part III: Downstream Inference of the pretrained_compound tutorial. Hope this can be helpful to you.

Thanks! I will try

from paddlehelix.

gaoshan2006 avatar gaoshan2006 commented on May 30, 2024

I refer to the above tutorial pointed by @Noisyntrain to run an inference case for a finetuned qm7 model, However , it looks the tutorial code does not work for qm7 model. Here is my code , just a few slight changes from the tutorial example ,

All the json config file of inference is same with that of model training

def main(args):
compound_encoder_config = load_json_config( './model_configs/geognn_l8.json')
task_type = 'regr'
dataset_name = 'qm7'
task_names = get_downstream_task_names(dataset_name, './chemrl_downstream_datasets/qm7')

model_config = load_json_config( 'model_configs/down_mlp3.json' )
model_config['task_type'] = task_type
model_config['num_tasks'] = len(task_names)

compound_encoder = GeoGNNModel(compound_encoder_config)
model = DownstreamModel(model_config, compound_encoder)
model.set_state_dict(paddle.load( './model/model.pdparams' ))  <- this model is trained by the same config file
transform_fn = DownstreamTransformFn(is_inference=True )

collate_fn = DownstreamCollateFn(
        atom_names=compound_encoder_config['atom_names'], 
        bond_names=compound_encoder_config['bond_names'],
        bond_float_names=compound_encoder_config['bond_float_names'],
        bond_angle_float_names=compound_encoder_config['bond_angle_float_names'],
        is_inference=True,
        task_type=task_type)

SMILES="Cc1c(O)nc2ccccn2c1=O"

graph=collate_fn([transform_fn({'smiles':SMILES})])
preds=model(graph.tensor()).numpy()[0]

print('SMILES:%s' % SMILES)
print('Predictions:')
print(str(preds))
for name,prob in zip(task_names.preds):
     print(" %s:\t%s" % (name, prob))

Then I got the following errors:

Traceback (most recent call last):
File "inference_regr.py", line 206, in
main(args)
File "inference_regr.py", line 177, in main
preds=model(graph.tensor()).numpy()[0]
AttributeError: 'tuple' object has no attribute 'tensor'

I do not understand what differences between 'qm7' model and the tutorial model ? It looks the tutorial should be applicable to all the finetune models here, right? Could you give me some hints please? Thanks in advance

from paddlehelix.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.