This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| def run_trial(): | |
| # Hidden Variables | |
| a = np.random.rand() | |
| b = np.random.rand() | |
| c = np.random.rand() | |
| # Create 3 variables sampled from normal distributions | |
| var1 = np.random.normal(loc=a, scale=1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| def naive_softmax(logits): | |
| ''' | |
| Failure modes: | |
| * If any entry is very large, exp overflows | |
| * if all entries are very negative, all exps underflow | |
| ''' | |
| exp_logits = np.exp(logits) | |
| return exp_logits / np.sum(exp_logits) |