chemprop.nn.predictors
#
Module Contents#
Classes#
A |
|
A |
|
A |
|
A |
|
A |
|
A |
|
A |
|
A |
|
A |
|
A |
Attributes#
- class chemprop.nn.predictors.Predictor(*args, **kwargs)[source]#
Bases:
torch.nn.Module
,chemprop.nn.hparams.HasHParams
A
Predictor
is a protocol that defines a differentiable function \(f\) : mathbb R^d mapsto mathbb R^o- input_dim: int#
the input dimension
- output_dim: int#
the output dimension
- n_tasks: int#
the number of tasks t to predict for each input
- n_targets: int#
the number of targets s to predict for each task t
- criterion: chemprop.nn.loss.LossFunction#
the loss function to use for training
- task_weights: torch.Tensor#
the weights to apply to each task when calculating the loss
- output_transform: chemprop.nn.transforms.UnscaleTransform#
the transform to apply to the output of the predictor
- abstract encode(Z, i)[source]#
Calculate the
i
-th hidden representation- Parameters:
Z (Tensor) – a tensor of shape
n x d
containing the input data to encode, whered
is the input dimensionality.i (int) –
The stop index of slice of the MLP used to encode the input. That is, use all layers in the MLP _up to_
i
(i.e.,MLP[:i]
). This can be any integer value, and the behavior of this function is dependent on the underlying list slicing behavior. For example:i=0
: use a 0-layer MLP (i.e., a no-op)i=1
: use only the first blocki=-1
: use _up to_ the final block
- Returns:
a tensor of shape
n x h
containing thei
-th hidden representation, whereh
is the number of neurons in thei
-th hidden layer.- Return type:
Tensor
- chemprop.nn.predictors.PredictorRegistry#
- class chemprop.nn.predictors.RegressionFFN(n_tasks=1, input_dim=DEFAULT_HIDDEN_DIM, hidden_dim=300, n_layers=1, dropout=0.0, activation='relu', criterion=None, task_weights=None, threshold=None, output_transform=None)[source]#
Bases:
_FFNPredictorBase
A
_FFNPredictorBase
is the base class for allPredictor
s that use an underlyingSimpleFFN
to map the learned fingerprint to the desired output.- Parameters:
n_tasks (int)
input_dim (int)
hidden_dim (int)
n_layers (int)
dropout (float)
activation (str)
criterion (chemprop.nn.loss.LossFunction | None)
task_weights (torch.Tensor | None)
threshold (float | None)
output_transform (chemprop.nn.transforms.UnscaleTransform | None)
- n_targets = 1#
- class chemprop.nn.predictors.MveFFN(n_tasks=1, input_dim=DEFAULT_HIDDEN_DIM, hidden_dim=300, n_layers=1, dropout=0.0, activation='relu', criterion=None, task_weights=None, threshold=None, output_transform=None)[source]#
Bases:
RegressionFFN
A
_FFNPredictorBase
is the base class for allPredictor
s that use an underlyingSimpleFFN
to map the learned fingerprint to the desired output.- Parameters:
n_tasks (int)
input_dim (int)
hidden_dim (int)
n_layers (int)
dropout (float)
activation (str)
criterion (chemprop.nn.loss.LossFunction | None)
task_weights (torch.Tensor | None)
threshold (float | None)
output_transform (chemprop.nn.transforms.UnscaleTransform | None)
- n_targets = 2#
- class chemprop.nn.predictors.EvidentialFFN(n_tasks=1, input_dim=DEFAULT_HIDDEN_DIM, hidden_dim=300, n_layers=1, dropout=0.0, activation='relu', criterion=None, task_weights=None, threshold=None, output_transform=None)[source]#
Bases:
RegressionFFN
A
_FFNPredictorBase
is the base class for allPredictor
s that use an underlyingSimpleFFN
to map the learned fingerprint to the desired output.- Parameters:
n_tasks (int)
input_dim (int)
hidden_dim (int)
n_layers (int)
dropout (float)
activation (str)
criterion (chemprop.nn.loss.LossFunction | None)
task_weights (torch.Tensor | None)
threshold (float | None)
output_transform (chemprop.nn.transforms.UnscaleTransform | None)
- n_targets = 4#
- class chemprop.nn.predictors.BinaryClassificationFFNBase(n_tasks=1, input_dim=DEFAULT_HIDDEN_DIM, hidden_dim=300, n_layers=1, dropout=0.0, activation='relu', criterion=None, task_weights=None, threshold=None, output_transform=None)[source]#
Bases:
_FFNPredictorBase
A
_FFNPredictorBase
is the base class for allPredictor
s that use an underlyingSimpleFFN
to map the learned fingerprint to the desired output.- Parameters:
n_tasks (int)
input_dim (int)
hidden_dim (int)
n_layers (int)
dropout (float)
activation (str)
criterion (chemprop.nn.loss.LossFunction | None)
task_weights (torch.Tensor | None)
threshold (float | None)
output_transform (chemprop.nn.transforms.UnscaleTransform | None)
- class chemprop.nn.predictors.BinaryClassificationFFN(n_tasks=1, input_dim=DEFAULT_HIDDEN_DIM, hidden_dim=300, n_layers=1, dropout=0.0, activation='relu', criterion=None, task_weights=None, threshold=None, output_transform=None)[source]#
Bases:
BinaryClassificationFFNBase
A
_FFNPredictorBase
is the base class for allPredictor
s that use an underlyingSimpleFFN
to map the learned fingerprint to the desired output.- Parameters:
n_tasks (int)
input_dim (int)
hidden_dim (int)
n_layers (int)
dropout (float)
activation (str)
criterion (chemprop.nn.loss.LossFunction | None)
task_weights (torch.Tensor | None)
threshold (float | None)
output_transform (chemprop.nn.transforms.UnscaleTransform | None)
- n_targets = 1#
- class chemprop.nn.predictors.BinaryDirichletFFN(n_tasks=1, input_dim=DEFAULT_HIDDEN_DIM, hidden_dim=300, n_layers=1, dropout=0.0, activation='relu', criterion=None, task_weights=None, threshold=None, output_transform=None)[source]#
Bases:
BinaryClassificationFFNBase
A
_FFNPredictorBase
is the base class for allPredictor
s that use an underlyingSimpleFFN
to map the learned fingerprint to the desired output.- Parameters:
n_tasks (int)
input_dim (int)
hidden_dim (int)
n_layers (int)
dropout (float)
activation (str)
criterion (chemprop.nn.loss.LossFunction | None)
task_weights (torch.Tensor | None)
threshold (float | None)
output_transform (chemprop.nn.transforms.UnscaleTransform | None)
- n_targets = 2#
- class chemprop.nn.predictors.MulticlassClassificationFFN(n_classes, n_tasks=1, input_dim=DEFAULT_HIDDEN_DIM, hidden_dim=300, n_layers=1, dropout=0.0, activation='relu', criterion=None, task_weights=None, threshold=None, output_transform=None)[source]#
Bases:
_FFNPredictorBase
A
_FFNPredictorBase
is the base class for allPredictor
s that use an underlyingSimpleFFN
to map the learned fingerprint to the desired output.- Parameters:
n_classes (int)
n_tasks (int)
input_dim (int)
hidden_dim (int)
n_layers (int)
dropout (float)
activation (str)
criterion (chemprop.nn.loss.LossFunction | None)
task_weights (torch.Tensor | None)
threshold (float | None)
output_transform (chemprop.nn.transforms.UnscaleTransform | None)
- n_targets = 1#
- class chemprop.nn.predictors.MulticlassDirichletFFN(n_classes, n_tasks=1, input_dim=DEFAULT_HIDDEN_DIM, hidden_dim=300, n_layers=1, dropout=0.0, activation='relu', criterion=None, task_weights=None, threshold=None, output_transform=None)[source]#
Bases:
MulticlassClassificationFFN
A
_FFNPredictorBase
is the base class for allPredictor
s that use an underlyingSimpleFFN
to map the learned fingerprint to the desired output.- Parameters:
n_classes (int)
n_tasks (int)
input_dim (int)
hidden_dim (int)
n_layers (int)
dropout (float)
activation (str)
criterion (chemprop.nn.loss.LossFunction | None)
task_weights (torch.Tensor | None)
threshold (float | None)
output_transform (chemprop.nn.transforms.UnscaleTransform | None)
- class chemprop.nn.predictors.SpectralFFN(*args, spectral_activation='softplus', **kwargs)[source]#
Bases:
_FFNPredictorBase
A
_FFNPredictorBase
is the base class for allPredictor
s that use an underlyingSimpleFFN
to map the learned fingerprint to the desired output.- Parameters:
spectral_activation (str | None)
- n_targets = 1#
- train_step#