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 torch | |
from torch import nn | |
from torch.nn import Parameter, functional as F | |
class Convolution2DEnergyTemporalBasis(nn.Module): | |
def __init__(self, n_input_channels, | |
n_filters_simple, | |
n_filters_complex, | |
n_filters_temporal, |
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
def kcca_dual_coef(K1, K2, gamma, n_coefs=None, reduced_problem=False): | |
eigen_shape = tuple(np.array(K1.shape) * 2) | |
eigen_matrix1 = np.zeros(eigen_shape) | |
em_view = eigen_matrix1.view() | |
em_view.shape = 2, eigen_shape[0] // 2, 2, eigen_shape[1] // 2 | |
em_view = em_view.transpose(0, 2, 1, 3) | |
eigen_matrix2 = np.zeros(eigen_shape) | |
em_view2 = eigen_matrix2.view() |
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
"""testing skcuda fft in 3 dimensions""" | |
import pycuda.autoinit | |
import pycuda.gpuarray as gpuarray | |
import numpy as np | |
#from scipy import fftpack as fft | |
from pyfftw.interfaces import numpy_fft as fft | |
import skcuda.fft as cu_fft |
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
# Code for periodizing a signal in Fourier (corresponds to subsampling in signal space) | |
def periodize_1d(array, axis, downsampling): | |
axis_shape = array.shape[axis] | |
before_shape = array.shape[:axis] | |
after_shape = array.shape[axis + 1:] | |
new_shape = before_shape + (downsampling, -1) + after_shape | |
return array.reshape(new_shape).mean(axis) |
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
# Author: Michael Eickenberg | |
# License: BSD 3-clause | |
# This is a rapidly written proof of concept. There may remain big bugs. I find it overfits quite quickly atm | |
import numpy as np | |
import theano | |
theano.config.floatX = 'float32' | |
import theano.tensor as T | |
from theano.sandbox.rng_mrg import MRG_RandomStreams as RandomStreams |
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
# Disclaimer: This doesn't seem to work 100% yet, but almost ;) | |
# Convolutional ZCA | |
# When images are too large in amount of pixels to be able to determine the | |
# principal components of an image batch, one can suppose translation | |
# invariance of the eigen-structure and do the ZCA in a convolutional manner | |
import theano | |
import theano.tensor as T | |
import numpy as np |
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
# Author Michael Eickenberg <[email protected]>, Fabian Pedregosa | |
# Coded in 2012, another era, pure python, no guarantees for 1000% correctness or speed | |
""" | |
This module implements the Lowess function for nonparametric regression. | |
Functions: | |
lowess Fit a smooth nonparametric regression curve to a scatterplot. | |
For more information, see |
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
# Author Michael Eickenberg <[email protected]>, Fabian Pedregosa | |
# Coded in 2012, another era, pure python, no guarantees for 1000% correctness or speed | |
# requires loess.py | |
import numpy as np | |
from loess import lowess | |
VERBOSE = 100 |
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 theano | |
import theano.tensor as T | |
import numpy as np | |
# 0 and some arbitrarily small positive and negative numbers | |
test_vector = np.array( | |
[0., 1., -1., .1, -.1, 10., -10., 1e-8, -1e-8, | |
1e-10, -1e-10, 1e-16, -1e-16]).astype(np.float32) |
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
# Maxpooling with arbitrary pooling strides and pooling shapes | |
# Based on theano.tensor.signal.downsample.max_pool_2d. This | |
# operation is repeated the minimum necessary times to account for | |
# all stride steps. | |
#Author: Michael Eickenberg, [email protected] | |
import theano | |
import numpy as np |
NewerOlder