Created
December 17, 2014 04:55
-
-
Save jbornschein/3df7833ae75d9c5cbced to your computer and use it in GitHub Desktop.
Create an (semi-) orthogonal matrix
This file contains 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
def orthogonal_matrix(n_lower, n_upper): | |
""" | |
Creates and returns an orthogonal weight matrix. | |
For non square matrices this will just ignire some degrees of freedom. | |
""" | |
R_lower, _ = np.linalg.qr( np.random.normal(size=(n_lower, n_lower)) ) | |
R_upper, _ = np.linalg.qr( np.random.normal(size=(n_upper, n_upper)) ) | |
n_min = min(n_lower, n_upper) | |
W = gain * np.dot(R_out[:,:n_min], R_in[:n_min,:]) | |
return W |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment