models

openchem_model

class models.openchem_model.OpenChemModel(params)[source]

Bases: torch.nn.modules.module.Module

Base class for all OpenChem models. Function :func:’forward’ and :func:’cast’ inputs must be overridden for every class, that inherits from OpenChemModel.

static cast_inputs(sample, task, use_cuda)[source]
forward(inp, eval=False)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

static get_optional_params()[source]
static get_required_params()[source]
load_model(path)[source]
save_model(path)[source]
training: bool
models.openchem_model.build_training(model, params)[source]
models.openchem_model.evaluate(model, data_loader, criterion=None, epoch=None)[source]
models.openchem_model.fit(model, scheduler, train_loader, optimizer, criterion, params, eval=False, val_loader=None, cur_epoch=0)[source]
models.openchem_model.predict(model, data_loader, eval=True)[source]
models.openchem_model.reduce_tensor(tensor, world_size)[source]

Reduces input ‘’tensor’’ across all processes in such a way that everyone gets the sum of ‘’tensor’’ from all of the processes. :param tensor: data to be reduced. :type tensor: Tensor :param world_size: number of processes. :type world_size: int

models.openchem_model.train_step(model, optimizer, criterion, inp, target)[source]

Smiles2Label

class models.Smiles2Label.Smiles2Label(params)[source]

Bases: openchem.models.openchem_model.OpenChemModel

Creates a model that predicts one or multiple labels given string of characters as input. Embeddings for input sequences are extracted with Embedding layer, followed by encoder (could be RNN or CNN encoder). Last layer of the model is multi-layer perceptron.

Parameters

params (dict) – dictionary describing model architecture.

static cast_inputs(sample, task, use_cuda, for_prediction=False)[source]
forward(inp, eval=False)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool

Graph2Label

class models.Graph2Label.Graph2Label(params)[source]

Bases: openchem.models.openchem_model.OpenChemModel

Creates a model that predicts one or multiple labels given object of class graph as input. Consists of ‘graph convolution neural network encoder’__, followed by ‘graph max pooling layer’__ and multilayer perceptron.

__https://arxiv.org/abs/1609.02907 __https://pubs.acs.org/doi/full/10.1021/acscentsci.6b00367

Parameters

params (dict) – dictionary of parameters describing the model architecture.

static cast_inputs(sample, task, use_cuda, for_prediction=False)[source]
forward(inp, eval=False)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool

MoleculeProtein2Label

class models.MoleculeProtein2Label.MoleculeProtein2Label(params)[source]

Bases: openchem.models.openchem_model.OpenChemModel

Creates a model that predicts one or multiple labels given two sequences as input. Embeddings for each input are extracted separately with Embedding layer, followed by encoder (could be RNN or CNN encoder) and then merged together. Last layer of the model is multi-layer perceptron.

Parameters

params (dict) – dictionary describing model architecture.

cast_inputs(sample)[source]
forward(inp, eval=False)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool

vanilla_model