Skip to content

Commit

Permalink
dnsm-experiments-1 #39 supporting PR (#87)
Browse files Browse the repository at this point in the history
Adds output_dim to `single` model for matching output dimensions expected by DASM. Supporting PR for matsengrp/dnsm-experiments-1#41
  • Loading branch information
willdumm authored Nov 16, 2024
1 parent f418d62 commit a6f02a2
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions netam/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,18 +706,23 @@ def predict(self, representation: Tensor):
class SingleValueBinarySelectionModel(AbstractBinarySelectionModel):
"""A one parameter selection model as a baseline."""

def __init__(self):
def __init__(self, output_dim: int = 1):
super().__init__()
self.single_value = nn.Parameter(torch.tensor(0.0))
self.output_dim = output_dim

@property
def hyperparameters(self):
return {}
return {"output_dim": self.output_dim}

def forward(self, amino_acid_indices: Tensor, mask: Tensor) -> Tensor:
"""Build a binary log selection matrix from an index-encoded parent sequence."""
replicated_value = self.single_value.expand_as(amino_acid_indices)
return replicated_value
if self.output_dim == 1:
return self.single_value.expand(amino_acid_indices.shape)
else:
return self.single_value.expand(
amino_acid_indices.shape + (self.output_dim,)
)


class HitClassModel(nn.Module):
Expand Down

0 comments on commit a6f02a2

Please sign in to comment.