Skip to content

Commit

Permalink
helpful assert
Browse files Browse the repository at this point in the history
  • Loading branch information
lucidrains committed Feb 7, 2023
1 parent 846740c commit 6d45461
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions musiclm_pytorch/musiclm_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,8 @@ def __init__(
self.token_emb = nn.Embedding(num_tokens, dim)
self.pos_emb = nn.Embedding(max_seq_len, dim)

self.max_seq_len = max_seq_len

self.cls_token = nn.Parameter(torch.randn(dim))

self.transformer = Transformer(
Expand Down Expand Up @@ -405,6 +407,9 @@ def forward(
# token embedding + positional embedding

x = self.token_emb(x)

assert n <= self.max_seq_len, f'text sequence length {n} must be less than {self.max_seq_len}'

x = x + self.pos_emb(torch.arange(n, device = device))

# cls tokens, as in bert
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
setup(
name = 'musiclm-pytorch',
packages = find_packages(exclude=[]),
version = '0.0.14',
version = '0.0.15',
license='MIT',
description = 'MusicLM - AudioLM + Audio CLIP to text to music synthesis',
author = 'Phil Wang',
Expand Down

0 comments on commit 6d45461

Please sign in to comment.