Created
October 17, 2022 01:08
-
-
Save galenseilis/6c89707f42c46853cf7adfd11640730b to your computer and use it in GitHub Desktop.
Computes a "minor" of a tensor.
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 multiminor(arr, I): | |
| modes = len(arr.shape) | |
| assert modes == len(I) | |
| result = arr.copy() | |
| for mode in range(modes): | |
| result = np.delete(result, I[mode], axis=mode) | |
| return result | |
| X = np.arange(9**3).reshape((9,)*3) | |
| I = (3, 4, 5) | |
| print(multiminor(X, I)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment