src/core/layer.py
def Orthonorm(x, name=None):
    '''
    Builds keras layer that handles orthogonalization of x

    x:      an n x d input matrix
    name:   name of the keras layer

    returns:    a keras layer instance. during evaluation, the instance returns an n x d orthogonal matrix
                if x is full rank and not singular
    '''
    # get dimensionality of x
    d = x.get_shape().as_list()[-1]
    # compute orthogonalizing matrix
    ortho_weights = orthonorm_op(x)
    # create variable that holds this matrix
    ortho_weights_store = K.variable(np.zeros((d,d)))
    # create op that saves matrix into variable
    ortho_weights_update = tf.assign(ortho_weights_store, ortho_weights, name='ortho_weights_update')
    # switch between stored and calculated weights based on training or validation
    l = Lambda(lambda x: K.in_train_phase(K.dot(x, ortho_weights), K.dot(x, ortho_weights_store)), name=name)

    l.add_update(ortho_weights_update)
    return l

    Builds keras layer that handles orthogonalization of x

    x:      an n x d input matrix
    name:   name of the keras layer

    returns:    a keras layer instance. during evaluation, the instance returns an n x d orthogonal matrix
                if x is full rank and not singular
    
Builds keras layer that handles orthogonalization of x
x:      an n x d input matrix
name:   name of the keras layer

a keras layer instance. during evaluation, the instance returns an n x d orthogonal matrix
if x is full rank and not singular
Builds keras layer that handles orthogonalization of x x : an n x d input matrix name : name of the keras layer a keras layer instance . during evaluation the instance returns an n x d orthogonal matrix if x is full rank and not singular
def Orthonorm(x, name=None):
    d = x.get_shape().as_list()[-1]
    ortho_weights = orthonorm_op(x)
    ortho_weights_store = K.variable(np.zeros((d,d)))
    ortho_weights_update = tf.assign(ortho_weights_store, ortho_weights, name='ortho_weights_update')
    l = Lambda(lambda x: K.in_train_phase(K.dot(x, ortho_weights), K.dot(x, ortho_weights_store)), name=name)
    l.add_update(ortho_weights_update)
    return l
def Orthonorm ( x , name = None ) : d = x . get_shape ( ) . as_list ( ) [ - 1 ] ortho_weights = orthonorm_op ( x ) ortho_weights_store = K . variable ( np . zeros ( ( d , d ) ) ) ortho_weights_update = tf . assign ( ortho_weights_store , ortho_weights , name = 'ortho_weights_update' ) l = Lambda ( lambda x : K . in_train_phase ( K . dot ( x , ortho_weights ) , K . dot ( x , ortho_weights_store ) ) , name = name ) l . add_update ( ortho_weights_update ) return l
Builds keras layer that handles orthogonalization of x
x:      an n x d input matrix
name:   name of the keras layer
Builds keras layer that handles orthogonalization of x x : an n x d input matrix name : name of the keras layer
'''
    Builds keras layer that handles orthogonalization of x

    x:      an n x d input matrix
    name:   name of the keras layer

    returns:    a keras layer instance. during evaluation, the instance returns an n x d orthogonal matrix
                if x is full rank and not singular
    ''' # get dimensionality of x # compute orthogonalizing matrix # create variable that holds this matrix # create op that saves matrix into variable # switch between stored and calculated weights based on training or validation
x
name