예제 #1
0
 def test_remove_rows_means(self):
     print ('Preprocessing -> Performing remove_rows_means test ...')
     sys.stdout.flush()
     data = numx.random.randn(100, 1000)
     dataMean = numx.mean(data, axis=1).reshape(100, 1)
     MFdata, meanF = remove_rows_means(data, return_means=True)
     assert numx.all(numx.abs(dataMean - meanF) < self.epsilon)
     zeroMean = numx.mean(MFdata, axis=1)
     assert numx.all(numx.abs(zeroMean) < self.epsilon ** 2)
     print('successfully passed!')
     sys.stdout.flush()
예제 #2
0
import pydeep.misc.visualization as vis

# Model imports: RBM estimator, model and trainer module
import pydeep.rbm.estimator as estimator
import pydeep.rbm.model as model
import pydeep.rbm.trainer as trainer

# Set random seed (optional)
# (optional, if stochastic processes are involved we get the same results)
numx.random.seed(42)

# Load data (download is not existing)
data = io.load_natural_image_patches('NaturalImage.mat')

# Remove the mean of ech image patch separately (also works without)
data = pre.remove_rows_means(data)

# Set input/output dimensions
v1 = 14
v2 = 14
h1 = 14
h2 = 14

# Whiten data using ZCA
zca = pre.ZCA(v1 * v2)
zca.train(data)
data = zca.project(data)

# Split into training/test data
train_data = data[0:40000]
test_data = data[40000:70000]