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 | |
import numba | |
@numba.jit(nopython=True, parallel=True) #parallel speeds up computation only over very large matrices | |
# M is a mxn matrix binary matrix | |
# all elements in M should be uint8 | |
def gf2elim(M): | |
m,n = M.shape |
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 tensorflow as tf | |
def p_inv(matrix): | |
"""Returns the Moore-Penrose pseudo-inverse""" | |
s, u, v = tf.svd(matrix) | |
threshold = tf.reduce_max(s) * 1e-5 |
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 tensorflow as tf | |
from keras.datasets import mnist | |
import numpy as np | |
tf.enable_eager_execution() | |
assert tf.executing_eagerly() |