Skip to content

Instantly share code, notes, and snippets.

@galenseilis
Created October 17, 2022 01:08
Show Gist options
  • Select an option

  • Save galenseilis/6c89707f42c46853cf7adfd11640730b to your computer and use it in GitHub Desktop.

Select an option

Save galenseilis/6c89707f42c46853cf7adfd11640730b to your computer and use it in GitHub Desktop.
Computes a "minor" of a tensor.
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