dscript.models¶
dscript.models.embedding¶
-
class
dscript.models.embedding.
FullyConnectedEmbed
(nin, nout, dropout=0.5, activation=ReLU())[source]¶ Bases:
torch.nn.modules.module.Module
Protein Projection Module. Takes embedding from language model and outputs low-dimensional interaction aware projection.
- Parameters
nin (int) – Size of language model output
nout (int) – Dimension of projection
dropout (float) – Proportion of weights to drop out [default: 0.5]
activation (torch.nn.Module) – Activation for linear projection model
-
class
dscript.models.embedding.
IdentityEmbed
[source]¶ Bases:
torch.nn.modules.module.Module
Does not reduce the dimension of the language model embeddings, just passes them through to the contact model.
-
class
dscript.models.embedding.
LSTMEmbed
(nout, activation='ReLU', sparse=False, p=0.5)[source]¶ Bases:
torch.nn.modules.module.Module
-
forward
(x)[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.
-
-
class
dscript.models.embedding.
SkipLSTM
(nin, nout, hidden_dim, num_layers, dropout=0, bidirectional=True)[source]¶ Bases:
torch.nn.modules.module.Module
Language model from Bepler & Berger.
Loaded with pre-trained weights in embedding function.
- Parameters
nin (int) – Input dimension of amino acid one-hot [default: 21]
nout (int) – Output dimension of final layer [default: 100]
hidden_dim (int) – Size of hidden dimension [default: 1024]
num_layers (int) – Number of stacked LSTM models [default: 3]
dropout (float) – Proportion of weights to drop out [default: 0]
bidirectional (bool) – Whether to use biLSTM vs. LSTM
dscript.models.contact¶
-
class
dscript.models.contact.
ContactCNN
(embed_dim, hidden_dim=50, width=7, activation=Sigmoid())[source]¶ Bases:
torch.nn.modules.module.Module
Residue Contact Prediction Module. Takes embeddings from Projection module and produces contact map, output of Contact module.
- Parameters
embed_dim (int) –
Output dimension of dscript.models.embedding model \(d\) [default: 100]
hidden_dim (int) – Hidden dimension \(h\) [default: 50]
width (int) – Width of convolutional filter \(2w+1\) [default: 7]
activation (torch.nn.Module) – Activation function for final contact map [default: torch.nn.Sigmoid()]
-
cmap
(z0, z1)[source]¶ Calls dscript.models.contact.FullyConnected.
- Parameters
z0 (torch.Tensor) – Projection module embedding \((b \times N \times d)\)
z1 (torch.Tensor) – Projection module embedding \((b \times M \times d)\)
- Returns
Predicted contact broadcast tensor \((b \times N \times M \times h)\)
- Return type
torch.Tensor
-
class
dscript.models.contact.
FullyConnected
(embed_dim, hidden_dim, activation=ReLU())[source]¶ Bases:
torch.nn.modules.module.Module
Performs part 1 of Contact Prediction Module. Takes embeddings from Projection module and produces broadcast tensor.
Input embeddings of dimension \(d\) are combined into a \(2d\) length MLP input \(z_{cat}\), where \(z_{cat} = [z_0 \ominus z_1 | z_0 \odot z_1]\)
- Parameters
embed_dim (int) –
Output dimension of dscript.models.embedding model \(d\) [default: 100]
hidden_dim (int) – Hidden dimension \(h\) [default: 50]
activation (torch.nn.Module) – Activation function for broadcast tensor [default: torch.nn.ReLU()]
dscript.models.interaction¶
-
class
dscript.models.interaction.
LogisticActivation
(x0=0, k=1, train=False)[source]¶ Bases:
torch.nn.modules.module.Module
Implementation of Generalized Sigmoid Applies the element-wise function:
\(\sigma(x) = \frac{1}{1 + \exp(-k(x-x_0))}\)
- Parameters
x0 (float) – The value of the sigmoid midpoint
k (float) – The slope of the sigmoid - trainable - \(k \geq 0\)
train (bool) – Whether \(k\) is a trainable parameter
-
class
dscript.models.interaction.
ModelInteraction
(embedding, contact, use_cuda, do_pool=True, pool_size=9, theta_init=1, lambda_init=0, gamma_init=0, do_w=True, do_sigmoid=False)[source]¶ Bases:
torch.nn.modules.module.Module
-
cpred
(z0, z1)[source]¶ Project down input language model embeddings into low dimension using projection module
- Parameters
z0 (torch.Tensor) – Language model embedding \((b \times N \times d_0)\)
z1 (torch.Tensor) – Language model embedding \((b \times N \times d_0)\)
- Returns
Predicted contact map \((b \times N \times M)\)
- Return type
torch.Tensor
-
embed
(x)[source]¶ Project down input language model embeddings into low dimension using projection module
- Parameters
z (torch.Tensor) – Language model embedding \((b \times N \times d_0)\)
- Returns
D-SCRIPT projection \((b \times N \times d)\)
- Return type
torch.Tensor
-
map_predict
(z0, z1)[source]¶ Project down input language model embeddings into low dimension using projection module
- Parameters
z0 (torch.Tensor) – Language model embedding \((b \times N \times d_0)\)
z1 (torch.Tensor) – Language model embedding \((b \times N \times d_0)\)
- Returns
Predicted contact map, predicted probability of interaction \((b \times N \times d_0), (1)\)
- Return type
torch.Tensor, torch.Tensor
-
predict
(z0, z1)[source]¶ Project down input language model embeddings into low dimension using projection module
- Parameters
z0 (torch.Tensor) – Language model embedding \((b \times N \times d_0)\)
z1 (torch.Tensor) – Language model embedding \((b \times N \times d_0)\)
- Returns
Predicted probability of interaction
- Return type
torch.Tensor, torch.Tensor
-