MCPcopy Create free account
hub / github.com/DeepGraphLearning/DiffPack / GaussianFourierEmbedding

Class GaussianFourierEmbedding

diffpack/layer.py:64–75  ·  view source on GitHub ↗

Code adapted from https://github.com/yang-song/score_sde_pytorch/blob /1618ddea340f3e4a2ed7852a0694a809775cf8d0/models/layerspp.py#L32

Source from the content-addressed store, hash-verified

62
63
64class GaussianFourierEmbedding(nn.Module):
65 """ Code adapted from https://github.com/yang-song/score_sde_pytorch/blob
66 /1618ddea340f3e4a2ed7852a0694a809775cf8d0/models/layerspp.py#L32 """
67
68 def __init__(self, embedding_size=256, scale=1.0):
69 super().__init__()
70 self.W = nn.Parameter(torch.randn(embedding_size // 2) * scale, requires_grad=False)
71
72 def forward(self, x):
73 x *= self.W[None, :] * 2 * np.pi
74 emb = torch.cat([torch.sin(x), torch.cos(x)], dim=-1)
75 return emb
76
77
78def get_timestep_embedding(embedding_type, embedding_dim, embedding_scale=10000):

Callers 1

get_timestep_embeddingFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected