Skip to content

Commit

Permalink
stable reinmax
Browse files Browse the repository at this point in the history
  • Loading branch information
lucidrains committed May 24, 2023
1 parent 66b573b commit 5ddeecf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions dalle_pytorch/dalle_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def inner(model, *args, **kwargs):
# sampling helpers

def log(t, eps = 1e-20):
return torch.log(t + eps)
return torch.log(t.clamp(min = eps))

def gumbel_noise(t):
noise = torch.zeros_like(t).uniform_(0, 1)
Expand Down Expand Up @@ -239,7 +239,7 @@ def forward(
one_hot = one_hot.detach()
π0 = logits.softmax(dim = 1)
π1 = (one_hot + (logits / temp).softmax(dim = 1)) / 2
π1 = ((π1.log() - logits).detach() + logits).softmax(dim = 1)
π1 = ((log(π1) - logits).detach() + logits).softmax(dim = 1)
π2 = 2 * π1 - 0.5 * π0
one_hot = π2 - π2.detach() + one_hot

Expand Down
2 changes: 1 addition & 1 deletion dalle_pytorch/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.6.5'
__version__ = '1.6.6'

0 comments on commit 5ddeecf

Please sign in to comment.