MCPcopy Create free account
hub / github.com/AtlasAnalyticsLab/AdaFisher / sinusoidal_embedding

Function sinusoidal_embedding

Image_Classification/src/models/cct.py:80–85  ·  view source on GitHub ↗
(n_channels, dim)

Source from the content-addressed store, hash-verified

78# positional
79
80def sinusoidal_embedding(n_channels, dim):
81 pe = torch.FloatTensor([[p / (10000 ** (2 * (i // 2) / dim)) for i in range(dim)]
82 for p in range(n_channels)])
83 pe[:, 0::2] = torch.sin(pe[:, 0::2])
84 pe[:, 1::2] = torch.cos(pe[:, 1::2])
85 return rearrange(pe, '... -> 1 ...')
86
87
88# modules

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected