GithubHelp home page GithubHelp logo

nfp's Introduction

Build Status PyPI version DOI

Neural fingerprint (nfp)

Keras layers for end-to-end learning on molecular structure. Based on Keras, Tensorflow, and RDKit. Source code used in the study Message-passing neural networks for high-throughput polymer screening

Related Work

  1. Convolutional Networks on Graphs for Learning Molecular Fingerprints
  2. Neural Message Passing for Quantum Chemistry
  3. Relational inductive biases, deep learning, and graph networks
  4. Neural Message Passing with Edge Updates for Predicting Properties of Molecules and Materials

(Main) Requirements

Getting started

This library extends Keras with additional layers for handling molecular structures (i.e., graph-based inputs). There a strong familiarity with Keras is recommended.

An overview of how to build a model is shown in examples/solubility_test_graph_output.ipynb. Models can optionally include 3D molecular geometry; a simple example of a network using 3D geometry is found in examples/model_3d_coordinates.ipynb.

The current state-of-the-art architecture on QM9 (published in [4]) is included in examples/schnet_edgeupdate.py. This script requires qm9 preprocessing to be run before the model is evaluated with examples/preprocess_qm9.py.

nfp's People

Contributors

pstjohn avatar shreesowndarya avatar wardlt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

nfp's Issues

YSI data availability

Can you please share the YSI example data referenced in the example nb? I can't find the table in the referenced publication. The paper text refers to the supplemental but there is none linked? I'm trying to understand what shape I need to put my data into. Thanks in advance for any help.

solubility_test_new_message.ipynb ValueError: All input arrays (x) should have the same number of samples.

Hi! I met an error in solubility_test_new_message.ipynb.

---Error section -----
with warnings.catch_warnings():
warnings.simplefilter("ignore")

hist = model.fit_generator(train_generator,validation_data=test_generator,epochs=50, verbose=2)

----Error output----
Epoch 1/50

ValueError Traceback (most recent call last)
in
2 warnings.simplefilter("ignore")
3
----> 4 hist = model.fit_generator(train_generator,validation_data=test_generator,epochs=50, verbose=1)

/anaconda3/lib/python3.6/site-packages/keras/legacy/interfaces.py in wrapper(*args, **kwargs)
89 warnings.warn('Update your ' + object_name + ' call to the ' +
90 'Keras 2 API: ' + signature, stacklevel=2)
---> 91 return func(*args, **kwargs)
92 wrapper._original_function = func
93 return wrapper

/anaconda3/lib/python3.6/site-packages/keras/engine/training.py in fit_generator(self, generator, steps_per_epoch, epochs, verbose, callbacks, validation_data, validation_steps, class_weight, max_queue_size, workers, use_multiprocessing, shuffle, initial_epoch)
1416 use_multiprocessing=use_multiprocessing,
1417 shuffle=shuffle,
-> 1418 initial_epoch=initial_epoch)
1419
1420 @interfaces.legacy_generator_methods_support

/anaconda3/lib/python3.6/site-packages/keras/engine/training_generator.py in fit_generator(model, generator, steps_per_epoch, epochs, verbose, callbacks, validation_data, validation_steps, class_weight, max_queue_size, workers, use_multiprocessing, shuffle, initial_epoch)
215 outs = model.train_on_batch(x, y,
216 sample_weight=sample_weight,
--> 217 class_weight=class_weight)
218
219 outs = to_list(outs)

/anaconda3/lib/python3.6/site-packages/keras/engine/training.py in train_on_batch(self, x, y, sample_weight, class_weight)
1209 x, y,
1210 sample_weight=sample_weight,
-> 1211 class_weight=class_weight)
1212 if self._uses_dynamic_learning_phase():
1213 ins = x + y + sample_weights + [1.]

/anaconda3/lib/python3.6/site-packages/nfp/models/models.py in _standardize_user_data(self, *args, **kwargs)
10 def _standardize_user_data(self, *args, **kwargs):
11 kwargs['check_array_lengths'] = False
---> 12 return super(GraphModel, self)._standardize_user_data(*args, **kwargs)

/anaconda3/lib/python3.6/site-packages/keras/engine/training.py in _standardize_user_data(self, x, y, sample_weight, class_weight, check_array_lengths, batch_size)
802 ]
803 # Check that all arrays have the same length.
--> 804 check_array_length_consistency(x, y, sample_weights)
805 if self._is_graph_network:
806 # Additional checks to avoid users mistakenly

/anaconda3/lib/python3.6/site-packages/keras/engine/training_utils.py in check_array_length_consistency(inputs, targets, weights)
226 raise ValueError('All input arrays (x) should have '
227 'the same number of samples. Got array shapes: ' +
--> 228 str([x.shape for x in inputs]))
229 if len(set_y) > 1:
230 raise ValueError('All target arrays (y) should have '

ValueError: All input arrays (x) should have the same number of samples. Got array shapes: [(657, 1), (657, 1), (1350, 1), (1350, 2)]

training not smooth

I'm training a regression task that is very noisy in loss with my network tacked onto the end of the message passing part. The same training has very smooth loss with standard 1024-bit extended connectivity fingerprint and dense network with a couple hidden layers.

In your paper you describe transfer learning to apply this network to related problems where less data is available. Can you please share that model and weights? Alternatively, is there a way to freeze the early layers after they learn a chemical representation and then tune the bottom dense layers? any other ideas about how to make the loss more smooth?
loss

"None values not supported." error in example

I've been trying to run the example code, but running cell #10 ("Define the keras model") gives me ValueError: Tried to convert 'input' to a tensor and failed. Error: None values not supported..

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-12-c064f7512961> in <module>
     25 for _ in range(3):  # Do the message passing
     26     bond_state = nfp.EdgeUpdate()([atom_state, bond_state, connectivity, global_state])
---> 27     atom_state = nfp.NodeUpdate()([atom_state, bond_state, connectivity, global_state])
     28     global_state = nfp.GlobalUpdate(units=8, num_heads=1)(
     29         [atom_state, bond_state, connectivity, global_state]) 

~\anaconda3\envs\Python 37\lib\site-packages\tensorflow\python\keras\engine\base_layer.py in __call__(self, *args, **kwargs)
    950     if _in_functional_construction_mode(self, inputs, args, kwargs, input_list):
    951       return self._functional_construction_call(inputs, args, kwargs,
--> 952                                                 input_list)
    953 
    954     # Maintains info about the `Layer.call` stack.

~\anaconda3\envs\Python 37\lib\site-packages\tensorflow\python\keras\engine\base_layer.py in _functional_construction_call(self, inputs, args, kwargs, input_list)
   1089         # Check input assumptions set after layer building, e.g. input shape.
   1090         outputs = self._keras_tensor_symbolic_call(
-> 1091             inputs, input_masks, args, kwargs)
   1092 
   1093         if outputs is None:

~\anaconda3\envs\Python 37\lib\site-packages\tensorflow\python\keras\engine\base_layer.py in _keras_tensor_symbolic_call(self, inputs, input_masks, args, kwargs)
    820       return nest.map_structure(keras_tensor.KerasTensor, output_signature)
    821     else:
--> 822       return self._infer_output_signature(inputs, args, kwargs, input_masks)
    823 
    824   def _infer_output_signature(self, inputs, args, kwargs, input_masks):

~\anaconda3\envs\Python 37\lib\site-packages\tensorflow\python\keras\engine\base_layer.py in _infer_output_signature(self, inputs, args, kwargs, input_masks)
    861           # TODO(kaftan): do we maybe_build here, or have we already done it?
    862           self._maybe_build(inputs)
--> 863           outputs = call_fn(inputs, *args, **kwargs)
    864 
    865         self._handle_activity_regularization(inputs, outputs)

~\anaconda3\envs\Python 37\lib\site-packages\tensorflow\python\autograph\impl\api.py in wrapper(*args, **kwargs)
    668       except Exception as e:  # pylint:disable=broad-except
    669         if hasattr(e, 'ag_error_metadata'):
--> 670           raise e.ag_error_metadata.to_exception(e)
    671         else:
    672           raise

ValueError: in user code:

    C:\Users\Benjamin\anaconda3\envs\Python 37\lib\site-packages\nfp\layers\graph_layers.py:109 call  *
        messages = tf.where(tf.expand_dims(mask[1], axis=-1),
    C:\Users\Benjamin\anaconda3\envs\Python 37\lib\site-packages\tensorflow\python\util\dispatch.py:201 wrapper  **
        return target(*args, **kwargs)
    C:\Users\Benjamin\anaconda3\envs\Python 37\lib\site-packages\tensorflow\python\ops\array_ops.py:435 expand_dims_v2
        return gen_array_ops.expand_dims(input, axis, name)
    C:\Users\Benjamin\anaconda3\envs\Python 37\lib\site-packages\tensorflow\python\ops\gen_array_ops.py:2278 expand_dims
        "ExpandDims", input=input, dim=axis, name=name)
    C:\Users\Benjamin\anaconda3\envs\Python 37\lib\site-packages\tensorflow\python\framework\op_def_library.py:540 _apply_op_helper
        (input_name, err))

    ValueError: Tried to convert 'input' to a tensor and failed. Error: None values not supported.

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.