Skip to content

Commit

Permalink
small refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Aske-Rosted committed Feb 16, 2024
1 parent db5eb2c commit 8696992
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/graphnet/models/components/embedding.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ class SinusoidalPosEmb(torch.nn.Module):
digitization of the input data
"""

def __init__(self, dim: int = 16, m: int = 10000) -> None:
def __init__(self, dim: int = 16, n_freq: int = 10000) -> None:
"""Construct `SinusoidalPosEmb`.
Args:
dim: Embedding dimension.
m: Number of frequencies.
n_freq: Number of frequencies.
"""
super().__init__()
self.dim = dim
self.m = m
self.n_freq = n_freq

def forward(self, x: torch.Tensor) -> torch.Tensor:
"""Apply learnable forward pass to the layer."""
device = x.device
half_dim = self.dim // 2
emb = torch.log(torch.tensor(self.m, device=device)) / half_dim
emb = torch.log(torch.tensor(self.n_freq, device=device)) / half_dim
emb = torch.exp(torch.arange(half_dim, device=device) * (-emb))
emb = x[..., None] * emb[None, ...]
emb = torch.cat((emb.sin(), emb.cos()), dim=-1)
Expand Down
2 changes: 1 addition & 1 deletion src/graphnet/models/rnn/node_rnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Node_RNN(GNN):
The model takes as input the typical DOM data format and transforms it into
a time series of DOM activations pr. DOM. before applying a RNN layer and
outputting the an RNN output for each DOM. This model is in it's current
outputting the an RNN output for each DOM. This model is in its current
state not intended to be used as a standalone model. Furthermore, it needs
to be used with a time-series dataset and a "cutter" (see
NodeAsDOMTimeSeries), which is not standard in the graphnet framework.
Expand Down

0 comments on commit 8696992

Please sign in to comment.