Created
April 11, 2018 10:37
-
-
Save darden1/78e5aa82ed0839b29299977d8cec258e to your computer and use it in GitHub Desktop.
onehot_matrix_check.py
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 | |
| n = 3 | |
| m = 3 | |
| B = np.random.rand(n,m) | |
| Y = np.zeros_like(B) | |
| for i in range(Y.shape[0]): | |
| Y[i, np.random.choice(np.arange(Y.shape[1]), 1)] = 1 | |
| dLdB = Y/B | |
| print("-"*40) | |
| print("B:") | |
| print(B) | |
| print("-"*40) | |
| print("Y:") | |
| print(Y) | |
| print("-"*40) | |
| print("dLdB:") | |
| print(dLdB) | |
| print("-"*40) | |
| print("np.dot(dLdB, B.T):") | |
| print(np.dot(dLdB, B.T)) | |
| print("-"*40) | |
| print("np.diag(np.dot(dLdB, B.T)):") | |
| print(np.diag(np.dot(dLdB, B.T))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment