terminator.models.layers.condense.EdgeFeatures¶
- class terminator.models.layers.condense.EdgeFeatures(hparams, in_dim, hidden_dim, feature_mode='shared_learned', compress='project')[source]¶
Bases:
ModuleModule which computes edge features for TERMs
- Variables:
embedding (nn.Embedding or equivalent, conditionally present) – Layer to embed TERM match residue identities
lin (nn.Linear, conditionally present) – Input embedding layer
cnn (Conv2DResNet, conditionally present) – CNN that generates 2D features by convolution over matches
W (nn.Linear or nn.Sequential(nn.Linear, nn.ReLU, nn.Linear)) – Output layer
- __init__(hparams, in_dim, hidden_dim, feature_mode='shared_learned', compress='project')[source]¶
- Parameters:
hparams (dict) – Dictionary of model hparams (see
~/scripts/models/train/default_hparams.jsonfor more info)in_dim (int) – Dimensionality of input feature vectors
hidden_dim (int) – Hidden dimension
feature_mode (string from
['shared_learned', 'all_raw', 'aa_learned', 'aa_count']) –- Generate initial covariation matrix by computing covariation on
'shared_learned': inputted match features without preprocessing'all_raw': raw counts as well as inputted match features'aa_learned': features in learned embedding for residue identity'aa_count': raw residue identity counts
compress (string from [‘project’, ‘ffn’, ‘ablate’]) –
- Method to compress covariance matrix to vector. Flatten, then
'project': project to proper dimensionality with a linear layer'ffn': use a 2 layer FFN with proper output dimensionality'ablate': return a zero vector of proper dimensionality
Methods
__init__(hparams, in_dim, hidden_dim[, ...])- Parameters:
hparams (dict) -- Dictionary of model hparams (see
~/scripts/models/train/default_hparams.jsonfor more info)
forward(matches, term_lens, rmsds, mask[, ...])Generate embeddings for weighted covariation features between TERM residues
Attributes
T_destinationalias of TypeVar('T_destination', bound=
Mapping[str,Tensor])dump_patchesThis allows better BC support for
load_state_dict().- forward(matches, term_lens, rmsds, mask, features=None)[source]¶
Generate embeddings for weighted covariation features between TERM residues
- Parameters:
matches (torch.Tensor) – Matches, either as ints representing TERM match residue identities, or featurized matches Shape: n_batches x sum_term_len (x n_in if already featurized)
term_lens (list of (list of int)) – Length of TERMs per protein
rmsds (torch.Tensor) – RMSD associated with each match Shape: n_batches x sum_term_len
mask (torch.ByteTensor) – Mask for TERM residues Shape: n_batches x sum_term_len
- Returns:
cov_features – Embeddings for covariance matrices between TERM residues Shape: n_batches x n_terms x max_term_len x max_term_len x n_hidden
- Return type:
torch.Tensor