projects
/
culture.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Update.
[culture.git]
/
mygpt.py
diff --git
a/mygpt.py
b/mygpt.py
index
ab4ccbc
..
809f790
100755
(executable)
--- a/
mygpt.py
+++ b/
mygpt.py
@@
-279,7
+279,7
@@
class MyGPT(nn.Module):
self,
input,
ar_mask,
self,
input,
ar_mask,
- s
ummed_logits
,
+ s
eq_logproba
,
temperature=1.0,
deterministic_synthesis=False,
forbidden_tokens=None,
temperature=1.0,
deterministic_synthesis=False,
forbidden_tokens=None,
@@
-309,10
+309,10
@@
class MyGPT(nn.Module):
else:
dist = torch.distributions.categorical.Categorical(logits=logits)
t_next = dist.sample()
else:
dist = torch.distributions.categorical.Categorical(logits=logits)
t_next = dist.sample()
- if summed_logits is not None:
- summed_logits += logits[torch.arange(t_next.size(0)), t_next].sum(
- dim=-1
-
)
+
+ if seq_logproba is not None:
+ all_t = torch.arange(t_next.size(0))
+
seq_logproba += logits[all_t, t_next].sum(dim=-1
)
input[:, s] = ar_mask[:, s] * t_next + (1 - ar_mask[:, s]) * input[:, s]
input[:, s] = ar_mask[:, s] * t_next + (1 - ar_mask[:, s]) * input[:, s]