chemprop.nn.predictors#
Attributes#
Classes#
A |
|
A |
|
A |
|
A |
|
A |
|
A |
|
A |
|
A |
|
A |
|
A |
Module Contents#
- class chemprop.nn.predictors.Predictor(*args, **kwargs)[source]#
Bases:
torch.nn.Module,chemprop.nn.hparams.HasHParamsA
Predictoris a protocol that defines a differentiable function \(f\) : mathbb R^d mapsto mathbb R^o- Parameters:
args (Any)
kwargs (Any)
- 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.metrics.ChempropMetric#
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
- abstractmethod encode(Z, i)[source]#
Calculate the
i-th hidden representation- Parameters:
Z (Tensor) – a tensor of shape
n x dcontaining the input data to encode, wheredis 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 hcontaining thei-th hidden representation, wherehis 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:
_FFNPredictorBaseA
_FFNPredictorBaseis the base class for allPredictors that use an underlyingMLPto map the learned fingerprint to the desired output.- Parameters:
n_tasks (int)
input_dim (int)
hidden_dim (int | Sequence[int])
n_layers (int)
dropout (float)
activation (str | torch.nn.Module)
criterion (chemprop.nn.metrics.ChempropMetric | None)
task_weights (torch.Tensor | None)
threshold (float | None)
output_transform (chemprop.nn.transforms.UnscaleTransform | None)
- n_targets = 1#
the number of targets s to predict for each task t
- train_step#
- 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:
RegressionFFNA
_FFNPredictorBaseis the base class for allPredictors that use an underlyingMLPto map the learned fingerprint to the desired output.- Parameters:
n_tasks (int)
input_dim (int)
hidden_dim (int | Sequence[int])
n_layers (int)
dropout (float)
activation (str | torch.nn.Module)
criterion (chemprop.nn.metrics.ChempropMetric | None)
task_weights (torch.Tensor | None)
threshold (float | None)
output_transform (chemprop.nn.transforms.UnscaleTransform | None)
- n_targets = 2#
the number of targets s to predict for each task t
- train_step#
- 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:
RegressionFFNA
_FFNPredictorBaseis the base class for allPredictors that use an underlyingMLPto map the learned fingerprint to the desired output.- Parameters:
n_tasks (int)
input_dim (int)
hidden_dim (int | Sequence[int])
n_layers (int)
dropout (float)
activation (str | torch.nn.Module)
criterion (chemprop.nn.metrics.ChempropMetric | None)
task_weights (torch.Tensor | None)
threshold (float | None)
output_transform (chemprop.nn.transforms.UnscaleTransform | None)
- n_targets = 4#
the number of targets s to predict for each task t
- train_step#
- 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:
_FFNPredictorBaseA
_FFNPredictorBaseis the base class for allPredictors that use an underlyingMLPto map the learned fingerprint to the desired output.- Parameters:
n_tasks (int)
input_dim (int)
hidden_dim (int | Sequence[int])
n_layers (int)
dropout (float)
activation (str | torch.nn.Module)
criterion (chemprop.nn.metrics.ChempropMetric | 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:
BinaryClassificationFFNBaseA
_FFNPredictorBaseis the base class for allPredictors that use an underlyingMLPto map the learned fingerprint to the desired output.- Parameters:
n_tasks (int)
input_dim (int)
hidden_dim (int | Sequence[int])
n_layers (int)
dropout (float)
activation (str | torch.nn.Module)
criterion (chemprop.nn.metrics.ChempropMetric | None)
task_weights (torch.Tensor | None)
threshold (float | None)
output_transform (chemprop.nn.transforms.UnscaleTransform | None)
- n_targets = 1#
the number of targets s to predict for each task t
- 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:
BinaryClassificationFFNBaseA
_FFNPredictorBaseis the base class for allPredictors that use an underlyingMLPto map the learned fingerprint to the desired output.- Parameters:
n_tasks (int)
input_dim (int)
hidden_dim (int | Sequence[int])
n_layers (int)
dropout (float)
activation (str | torch.nn.Module)
criterion (chemprop.nn.metrics.ChempropMetric | None)
task_weights (torch.Tensor | None)
threshold (float | None)
output_transform (chemprop.nn.transforms.UnscaleTransform | None)
- n_targets = 2#
the number of targets s to predict for each task t
- 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:
_FFNPredictorBaseA
_FFNPredictorBaseis the base class for allPredictors that use an underlyingMLPto map the learned fingerprint to the desired output.- Parameters:
n_classes (int)
n_tasks (int)
input_dim (int)
hidden_dim (int | Sequence[int])
n_layers (int)
dropout (float)
activation (str | torch.nn.Module)
criterion (chemprop.nn.metrics.ChempropMetric | None)
task_weights (torch.Tensor | None)
threshold (float | None)
output_transform (chemprop.nn.transforms.UnscaleTransform | None)
- n_targets = 1#
the number of targets s to predict for each task t
- n_classes#
- property n_tasks: int#
the number of tasks t to predict for each input
- Return type:
int
- 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:
MulticlassClassificationFFNA
_FFNPredictorBaseis the base class for allPredictors that use an underlyingMLPto map the learned fingerprint to the desired output.- Parameters:
n_classes (int)
n_tasks (int)
input_dim (int)
hidden_dim (int | Sequence[int])
n_layers (int)
dropout (float)
activation (str | torch.nn.Module)
criterion (chemprop.nn.metrics.ChempropMetric | 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:
_FFNPredictorBaseA
_FFNPredictorBaseis the base class for allPredictors that use an underlyingMLPto map the learned fingerprint to the desired output.- Parameters:
spectral_activation (str | None)
- n_targets = 1#
the number of targets s to predict for each task t
- train_step#