MCPcopy Create free account
hub / github.com/MotrixLab/MotionDiffuse / positional_encoding

Function positional_encoding

text2motion/datasets/evaluator_models.py:43–51  ·  view source on GitHub ↗
(batch_size, dim, pos)

Source from the content-addressed store, hash-verified

41# batch_size, dimension and position
42# output: (batch_size, dim)
43def positional_encoding(batch_size, dim, pos):
44 assert batch_size == pos.shape[0]
45 positions_enc = np.array([
46 [pos[j] / np.power(10000, (i-i%2)/dim) for i in range(dim)]
47 for j in range(batch_size)
48 ], dtype=np.float32)
49 positions_enc[:, 0::2] = np.sin(positions_enc[:, 0::2])
50 positions_enc[:, 1::2] = np.cos(positions_enc[:, 1::2])
51 return torch.from_numpy(positions_enc).float()
52
53
54def get_padding_mask(batch_size, seq_len, cap_lens):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected