(distribution, temperature)
| 191 | |
| 192 | |
| 193 | def softmax(distribution, temperature): |
| 194 | denom = sum(np.exp(np.array(list(distribution.values())) / temperature)) |
| 195 | for token in distribution: |
| 196 | distribution[token] = np.exp(distribution[token] / temperature) / denom |
| 197 | return distribution |
| 198 | |
| 199 | |
| 200 | def normalize(distribution): |
nothing calls this directly
no outgoing calls
no test coverage detected