kinoml.ml.torch_models
¶
Module Contents¶
- class kinoml.ml.torch_models._BaseModule¶
Bases:
torch.nn.Module
- needs_input_shape = True¶
- static estimate_input_shape(input_sample)¶
This static method takes the same input as
.forward()
would and estimates the incoming shape so the layers can be initialized properly.Most of the time,
input_sample
would be a Tensor, in which the first dimension corresponds to systems, and the second is the input shape we need.If your
.forward()
method takes something else than a Tensor, please adapt this method accordingly.
- class kinoml.ml.torch_models.NeuralNetworkRegression(input_shape, hidden_shape=100, output_shape=1, activation=F.relu)¶
Bases:
_BaseModule
Builds a vanilla neural network and a feed-forward pass for a ligand setting.
- Parameters
input_shape (int) – Dimension of the input vector.
hidden_shape (int, default=100) – Number of units in the hidden layer.
output_shape (int, default=1) – Size of the last unit, representing delta_g_over_kt in our setting.
_activation (torch function, default: relu) – The activation function used in the hidden (only!) layer of the network.
- forward(system)¶
Defines the foward pass for a system, which contains the featurized molecular components and the associated measurement/label. Since only the featurized system is needed, the first element is retrieved. In this case, the ligand is a 1D array of shape (length of fingerprint).
Notes
More information about how featurization are stored can be found at https://github.com/openkinome/experiments-binding-affinity/blob/master/features/featurize-template.ipynb .
- class kinoml.ml.torch_models.ListOfTupleNeuralNetworkregression(input_shape, hidden_shape=100, output_shape=1, activation=F.relu)¶
Bases:
NeuralNetworkRegression
This example model does not take a Tensor in, but a tuple of tensors. Each tensor has shape (n_systems, n_features).
As a result, one needs to concatenate the results before passing it to the parent
.forward()
method.- static estimate_input_shape(input_sample)¶
This static method takes the same input as
.forward()
would and estimates the incoming shape so the layers can be initialized properly.Most of the time,
input_sample
would be a Tensor, in which the first dimension corresponds to systems, and the second is the input shape we need.If your
.forward()
method takes something else than a Tensor, please adapt this method accordingly.
- forward(x)¶
Defines the foward pass for a system, which contains the featurized molecular components and the associated measurement/label. Since only the featurized system is needed, the first element is retrieved. In this case, the ligand is a 1D array of shape (length of fingerprint).
Notes
More information about how featurization are stored can be found at https://github.com/openkinome/experiments-binding-affinity/blob/master/features/featurize-template.ipynb .
- class kinoml.ml.torch_models.DenseNeuralNetworkRegression(input_shape, hidden_shape=(350, 200, 100, 50, 16), output_shape=1, dropout_percentage=0.4, activation=F.relu)¶
Bases:
_BaseModule
Builds a Dense Neural Network and a feed-forward pass.
- Parameters
input_shape (int) – Dimension of the input vector.
hidden_shape (list) – Number of units in each of the hidden layers.
output_shape (int, default=1) – Size of the last unit, representing delta_g_over_kt in our setting.
dropout_percentage (float) – The percentage of hidden to by dropped at random.
_activation (torch function, default=relu) – The activation function used in the hidden (only!) layer of the network.
- forward(x)¶
Defines the foward pass for a given input ‘x’
- class kinoml.ml.torch_models.ConvolutionNeuralNetworkRegression(input_shape, embedding_shape=300, kernel_shape=10, hidden_shape=100, output_shape=1, activation=F.relu)¶
Bases:
_BaseModule
Builds a Convolutional Neural Network and a feed-forward pass for a ligand setting.
- Parameters
input_shape (int) – Dimension of the input of the system.
embedding_shape (int, default=200) – Dimension of the embedding after convolution.
kernel_shape (int, default=10) – Size of the kernel for the convolution.
hidden_shape (int, default=100) – Number of units in the hidden layer.
output_shape (int, default=1) – Size of the last unit, representing delta_g_over_kt in our setting.
activation (torch function, default=relu) – The activation function used in the hidden (only!) layer of the network.
- forward(system)¶
Defines the foward pass for a system, which contains the featurized molecular components and the associated measurement/label. Since only the featurized system is needed, the first element is retrieved. In this case, the ligand is a 2D array of shape (nb of character, length of smiles).
Notes
More information about how featurization are stored can be found at https://github.com/openkinome/experiments-binding-affinity/blob/master/features/featurize-template.ipynb .
- class kinoml.ml.torch_models.ConvolutionNeuralNetworkRegressionProteinInformed(input_shape, embedding_shape=300, kernel_shape=10, hidden_shape=100, output_shape=1, activation=F.relu)¶
Bases:
_BaseModule
Builds a Convolutional Neural Network and a feed-forward pass for a protein-ligand setting.
- Parameters
input_shape (tuple) – Dimension of input tensors, for the ligand and the protein.
embedding_shape (int, default=200) – Dimension of the embedding after convolution.
kernel_shape (int, default=10) – Size of the kernel for the convolution.
hidden_shape (int, default=100) – Number of units in the hidden layer.
output_shape (int, default=1) – Size of the last unit, representing delta_g_over_kt in our setting.
activation (torch function, default=relu) – The activation function used in the hidden (only!) layer of the network.
- forward(system)¶
Defines the foward pass for given a system, which contains the featurized molecular components and the associated measurement/label. In this case, the input is composed of two entities: ligand and protein, so the two first elements are retrieved. In this case, the ligand is a 2D array of shape (nb of character, length of smiles) and the protein a 2D array of shape (nb of residues, length of sequence)
Notes
More information about how featurization are stored can be found at https://github.com/openkinome/experiments-binding-affinity/blob/master/features/featurize-template.ipynb .
- class kinoml.ml.torch_models.NeuralNetworkRegressionProteinInformed(input_shape, embedding_shape_ligand=300, embedding_shape_protein=10, kernel_shape=10, hidden_shape=100, output_shape=1, activation=F.relu)¶
Bases:
_BaseModule
Builds a Neural Network and a feed-forward pass for a protein-ligand setting.
- Parameters
input_shape (tuple) – Dimension of input tensors, for the ligand and the protein.
embedding_shape_ligand (int, default=300) – Dimension of the embedding for the ligand.
embedding_shape_protein (int, default=10) – Dimension of the embedding for the protein.
kernel_shape (int, default=10) – Size of the kernel for the convolution.
hidden_shape (int, default=100) – Number of units in the hidden layer.
output_shape (int, default=1) – Size of the last unit, representing delta_g_over_kt in our setting.
activation (torch function, default=relu) – The activation function used in the hidden (only!) layer of the network.
- forward(system)¶
Defines the foward pass for given a system, which contains the featurized molecular components and the associated measurement/label. In this case, the input is composed of two entities: ligand and protein, so the two first elements are retrieved. In this case, the ligand is a 1D array of shape (length of fingerprint), and the protein a 1D array of shape (length of sequence composition).
Notes
More information about how featurization are stored can be found at https://github.com/openkinome/experiments-binding-affinity/blob/master/features/featurize-template.ipynb .