def identity(shape, scale=1):
    if len(shape) != 2 or shape[0] != shape[1]:
        raise Exception(
            "Identity matrix initialization can only be used for 2D square matrices"
        )
    else:
        return sharedX(scale * np.identity(shape[0]))
def orthogonal(shape, scale=1.1):
    ''' From Lasagne
    '''
    flat_shape = (shape[0], np.prod(shape[1:]))
    a = np.random.normal(0.0, 1.0, flat_shape)
    u, _, v = np.linalg.svd(a, full_matrices=False)
    # pick the one with the correct shape
    q = u if u.shape == flat_shape else v
    q = q.reshape(shape)
    return sharedX(scale * q[:shape[0], :shape[1]])
def normal(shape, scale=0.02):
    return sharedX(np.random.randn(*shape) * scale)
def uniform(shape, scale=0.1):
    return sharedX(np.random.uniform(low=-scale, high=scale, size=shape))