Skip to content

Instantly share code, notes, and snippets.

View aeftimia's full-sized avatar

Alex Eftimiades aeftimia

View GitHub Profile
@aeftimia
aeftimia / emd.py
Created August 24, 2020 20:48
Earth Mover Distance
import numpy
import scipy
import scipy.spatial
import scipy.optimize
def constraint(alen, blen):
return numpy.eye(alen)[..., numpy.newaxis] * numpy.ones(blen)[numpy.newaxis, numpy.newaxis]
def emd(a, b, a_weights=None, b_weights=None):
if a_weights is None:
@aeftimia
aeftimia / convtree.py
Last active September 19, 2019 17:50
Convolutional Decision Tree
import numpy
from keras.datasets import cifar10
from sklearn import preprocessing
from sklearn.tree import DecisionTreeClassifier
(X_train, y_train), (X_test, y_test) = cifar10.load_data()
X_train = X_train.astype('float32')
X_test = X_test.astype('float32')
@aeftimia
aeftimia / orthogonalize.py
Last active July 24, 2023 16:00
Tensorflow function to orthogonalize incident weight vectors on hidden units
import numpy
import tensorflow
from tensorflow.linalg import expm
def orthogonalize(w, axis=None, orthonormal=False):
"""Orthogonal weight constraint.
Constrains the weights incident to each hidden unit
to be orthogonal when there are more inputs than hidden units.
@aeftimia
aeftimia / orthogonality_constraint.py
Created January 24, 2019 17:40
Keras style orthogonality constraint
import numpy
import tensorflow
from keras.constraints import Constraint
from tensorflow.linalg import expm
class Orthogonal(Constraint):
"""Orthogonal weight constraint.
Constrains the weights incident to each hidden unit
Verifying my Blockstack ID is secured with the address 1JZXzQS1q1KJ1qVu5SWoHCi2RmeQxbgAwQ

Keybase proof

I hereby claim:

  • I am aeftimia on github.
  • I am aeftimia (https://keybase.io/aeftimia) on keybase.
  • I have a public key whose fingerprint is 59D0 61B3 4E9E A994 4370 AD00 A3F8 514D 5563 3C57

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am aeftimia on github.
  • I am aeftimia (https://keybase.io/aeftimia) on keybase.
  • I have a public key whose fingerprint is 4D49 0581 C078 51D8 61C6 5214 5B2B 8E5D 30B9 A0F2

To claim this, I am signing this object: