Esempio n. 1
0
def main():
    useSimpleShapes = True

    if useSimpleShapes:
        labels = None
        #data = loadFromPklGz('../data/simple3DShapes/poisson_train_500.pkl.gz')
        #data = loadFromPklGz('../data/simple3DShapes/poisson_train_5000.pkl.gz')
        data = loadFromPklGz(
            '../data/simple3DShapes/poisson_train_50000.pkl.gz')
        data = data[:25000, :]
        #data = loadFromPklGz('../data/simple3DShapes/poisson_train_50000.pkl.gz')
    else:
        #labels, data = loadFromPklGz('../data/endlessforms/train_bool_50_0.pkl.gz')
        #labels, data = loadFromPklGz('../data/endlessforms/train_bool_50000_0.pkl.gz')
        labels, data = loadFromPklGz(
            '../data/endlessforms/train_real_5000_0.pkl.gz')
        #labels, data = loadFromPklGz('../data/endlessforms/train_real_50000_0.pkl.gz')
        #labels, data = loadFromPklGz('../data/endlessforms/train_real_50_0.pkl.gz')

    size = (10, 10, 20)

    FAST_HACK = False
    if FAST_HACK:
        data = data[:, :400]
        size = (10, 10, 4)
def main():
    resman.start('junk', diary = False)

    #l1tica  = loadFromPklGz('results/130402_033310_44cc757_master_psearchTica_UP/00022_data/tica.pkl.gz')
    l1tica  = loadFromPklGz('results/130406_184751_3d90386_rapidhacks_upson3_1c_l1/tica.pkl.gz')   # 1c Upson3
    #layer1Whitener = loadFromPklGz('../data/upson_rovio_2/white/train_10_50000_1c.whitener.pkl.gz')
    layer1Whitener = loadFromPklGz('../data/upson_rovio_3/white/train_10_50000_1c.whitener.pkl.gz')

    layerSizePlan = [10, 15, 23, 35, 53, 80, 120, 180]

    stackedTica = StackedTICA(l1tica, layer1Whitener, '../data/upson_rovio_3/imgfiles/',
                              layerSizePlan = layerSizePlan,
                              isColor = False,
                              saveDir = resman.rundir)

    if False:
        print 'JUST DEBUG...'

        pdb.set_trace()
        
        tica = stackedTica.ticas[0]
        pdb.set_trace()
        return
    #data,labels,strings = loadUpsonData3('../data/upson_rovio_3/train_10_50000_1c.pkl.gz')
    #data = loadFromPklGz('../data/upson_rovio_3/white/train_10_50000_1c.white.pkl.gz')
    #stackedTica.plotResults(resman.rundir, stackedTica.ticas[0], data, (10,10), (15,15))
    
    #pdb.set_trace()

    params = {}
    params['hiddenISize'] = 15
    params['hiddenJSize'] = params['hiddenISize']
    params['neighborhoodSize'] = 1.0
    params['lambd'] = .026
    params['randSeed'] = 0
    #params['dataWidth'] = 10
    #params['nColors'] = 1
    #params['isColor'] = (params['nColors'] == 3)
    #params['imgShape'] = ((params['dataWidth'], params['dataWidth'], 3)
    #                      if params['isColor'] else
    #                      (params['dataWidth'], params['dataWidth']))
    params['maxFuncCalls'] = 3
    #params['whiten'] = True    # Just false for Space Invaders dataset...
    params['dataCrop'] = None       # Set to None to not crop data...
    #params['dataCrop'] = 10000       # Set to None to not crop data...

    stackedTica.learnNextLayer(params)
    #print 'HACK FOR DEBUG'
    saveToFile(os.path.join(resman.rundir, 'stackedTica.pkl.gz'), stackedTica)    # save learned model
    
    resman.stop()
Esempio n. 3
0
def testTica():
    data = loadFromPklGz('../data/rica_hyv_patches_16.pkl.gz')
    data = data[:25, :500]  # take just a small slice of data

    #pdb.set_trace()

    random.seed(0)
    tica = TICA(imgShape=(5, 5),
                hiddenLayerShape=(4, 5),
                shrink=0,
                lambd=.05,
                epsilon=1e-5)
    normData = True
    if normData:
        # Project each patch to the unit ball
        patchNorms = sqrt(sum(data**2, 0) + (1e-8))
        data = data / patchNorms

    # Initialize weights WW
    WW = random.randn(4 * 5, 5 * 5)
    WW = (WW.T / sqrt(sum(WW**2, 1))).T
    #loadedWW = loadtxt('../octave-randTheta')
    #WW = loadedWW
    WW = WW.flatten()

    cost, sGrad = tica.cost(WW, data)
    print 'Current cost is:', cost
    print 'Gradient (symbolic) is:', sGrad

    nGradFn = Gradient(lambda w: tica.cost(w, data)[0])
    nGrad = nGradFn(WW)
    print 'Gradient (finite diff) is:', nGrad
    print 'diff is', sGrad - nGrad

    pdb.set_trace()
def main():
    parser = argparse.ArgumentParser(description='Visualizes a trained StackedLayers model.')
    parser.add_argument('--name', type = str, default = 'junk',
                        help = 'Name for GitResultsManager results directory (default: junk)')
    #parser.add_argument('--quick', action='store_true', help = 'Enable quick mode (default: off)')
    parser.add_argument('--nodiary', action='store_true', help = 'Disable diary (default: diary is on)')
    parser.add_argument('stackedLayersFilename', type = str,
                        help = 'File where a StackedLayers model was stored, something like stackedLayers.pkl.gz')
    parser.add_argument('command', type = str, default = 'embed', choices = ['visall', 'embed'], nargs='?',
                        help = 'What to do: one of {visall (save all plots), embed (drop into shell)}. Default: embed.')

    args = parser.parse_args()

    resman.start(args.name, diary = not args.nodiary)
    saveDir = resman.rundir

    print 'Loading StackedLayers from %s' % args.stackedLayersFilename
    sl = loadFromPklGz(args.stackedLayersFilename)

    print 'Loaded these StackedLayers:'
    sl.printStatus()

    if args.command == 'embed':
        embed()
    elif args.command == 'visall':
        sl.visAll(saveDir)
    else:
        print 'Unknown command:', args.command

    resman.stop()
def main():
    resman.start('junk', diary = False)

    stica = loadFromPklGz('results/130407_132841_76b6586_rapidhacks_upson3_1c_l2_first/stackedTica_mod.pkl.gz')
    layer1Whitener = loadFromPklGz('../data/upson_rovio_3/white/train_10_50000_1c.whitener.pkl.gz')
    
    layerSizePlan = [10, 15, 23, 35, 53, 80, 120, 180]

    visLayer = 1

    largeSampleMatrix, labelMatrix, labelStrings = cached(randomSampleMatrixWithLabels, trainFilter,
                                                          seed = 0, color = False,
                                                          Nw = layerSizePlan[visLayer], Nsamples = 50000)

    seed = 0
    Nw = layerSizePlan[visLayer-1]             # e.g. 10
    Nwbig = layerSizePlan[visLayer]            # e.g. 15
    Nwshift = Nwbig - Nw                       # e.g. 15 - 10 = 5
    Nsamples = 1000
    temp = getBigAndSmallerSamples(trainFilter, layer1Whitener, seed, False, Nw, Nwshift, Nsamples)
    largeSampleMatrix, stackedSmall, stackedSmallWhite, labelMatrix, labelStrings = temp

    pooled = stica.getRepresentation(largeSampleMatrix)
    
    plotTopActivations(pooled, largeSampleMatrix, (Nwbig,Nwbig), resman.rundir, nActivations = 50, nSamples = 20)

    pl = (pooled.T - pooled.mean(1)).T
    for ii in range(len(labelStrings)):
        print 'finding top for', labelStrings[ii]
        if labelMatrix[ii,:].sum() == 0:
            print '  skipping, no examples'
            continue
        avgActivationForClass = (pl * labelMatrix[ii,:]).mean(1)
        sortIdx = argsort(avgActivationForClass)
        topNeurons = sortIdx[-1:-(50+1):-1]
        plotTopActivations(pooled[topNeurons,:], largeSampleMatrix, (Nwbig,Nwbig), resman.rundir,
                           nActivations = 50, nSamples = 20, prefix = 'topfor_%s' % labelStrings[ii])
        
    resman.stop()
def main():
    useSimpleShapes = True

    if useSimpleShapes:
        labels = None
        #data = loadFromPklGz('../data/simple3DShapes/poisson_train_500.pkl.gz')
        #data = loadFromPklGz('../data/simple3DShapes/poisson_train_5000.pkl.gz')
        data = loadFromPklGz('../data/simple3DShapes/poisson_train_50000.pkl.gz'); data = data[:25000,:]
        #data = loadFromPklGz('../data/simple3DShapes/poisson_train_50000.pkl.gz')
    else:
        #labels, data = loadFromPklGz('../data/endlessforms/train_bool_50_0.pkl.gz')
        #labels, data = loadFromPklGz('../data/endlessforms/train_bool_50000_0.pkl.gz')
        labels, data = loadFromPklGz('../data/endlessforms/train_real_5000_0.pkl.gz')
        #labels, data = loadFromPklGz('../data/endlessforms/train_real_50000_0.pkl.gz')
        #labels, data = loadFromPklGz('../data/endlessforms/train_real_50_0.pkl.gz')

    size = (10,10,20)

    FAST_HACK = False
    if FAST_HACK:
        data = data[:,:400]
        size = (10,10,4)
def main():
    parser = argparse.ArgumentParser(
        description='Visualizes a trained StackedLayers model.')
    parser.add_argument(
        '--name',
        type=str,
        default='junk',
        help='Name for GitResultsManager results directory (default: junk)')
    #parser.add_argument('--quick', action='store_true', help = 'Enable quick mode (default: off)')
    parser.add_argument('--nodiary',
                        action='store_true',
                        help='Disable diary (default: diary is on)')
    parser.add_argument(
        'stackedLayersFilename',
        type=str,
        help=
        'File where a StackedLayers model was stored, something like stackedLayers.pkl.gz'
    )
    parser.add_argument(
        'command',
        type=str,
        default='embed',
        choices=['visall', 'embed'],
        nargs='?',
        help=
        'What to do: one of {visall (save all plots), embed (drop into shell)}. Default: embed.'
    )

    args = parser.parse_args()

    resman.start(args.name, diary=not args.nodiary)
    saveDir = resman.rundir

    print 'Loading StackedLayers from %s' % args.stackedLayersFilename
    sl = loadFromPklGz(args.stackedLayersFilename)

    print 'Loaded these StackedLayers:'
    sl.printStatus()

    if args.command == 'embed':
        embed()
    elif args.command == 'visall':
        sl.visAll(saveDir)
    else:
        print 'Unknown command:', args.command

    resman.stop()
def ricaRun(randSeed, resman):
    testfn('rica')

    data = loadFromPklGz('../data/atari/mspacmantrain_15_50000_3c.pkl.gz')
    data = data.T   # Make into one example per column

    print 'randSeed is', randSeed
    random.seed(randSeed)
    print 'making dirs'
    thisdir = os.path.join(resman.rundir, 'seed-%03d' % randSeed)
    os.makedirs(thisdir)
    rica = RICA(imgShape = (15, 15, 3),
                nFeatures = 400,
                lambd = .05,
                epsilon = 1e-5,
                saveDir = thisdir)
    rica.run(data, maxFun = 3, whiten = True)

    return 'finished return value'
def main():
    parser = argparse.ArgumentParser(description='Makes features for the human activity deteciton dataset. Example usage:\n./humanObjectFeatures.py /path/to/data_obj_feats.txt')
    parser.add_argument('--name', type = str, default = 'junk',
                        help = 'Name for GitResultsManager results directory (default: junk)')
    parser.add_argument('--quick', action='store_true', help = 'Enable quick mode (default: off)')
    parser.add_argument('--nodiary', action='store_true', help = 'Disable diary (default: diary is on)')

    #parser.add_argument('stackedLayersFilename', type = str,
    #                    help = 'File where a StackedLayers model was stored, something like stackedLayers.pkl.gz')
    #parser.add_argument('command', type = str, default = 'embed', choices = ['visall', 'embed'], nargs='?',
    #                    help = 'What to do: one of {visall (save all plots), embed (drop into shell)}. Default: embed.')

    parser.add_argument('--stackedlayers', type = str, default = '',
                        help = 'Path to a *.pkl.gz file containing a pickeled StackedLayers object to load (default: None)')
    parser.add_argument('--fdata', type = str, default = '',
                        help = 'Path to a "..../formatted/data/method_name" directory containing files like 0510175829_1.txt. Needed only if adding truth labels. (default: None)')
    parser.add_argument('--outfile', type = str, default = 'data_objs_feats_plus.txt',
                        help = 'What to name the output file (default: data_objs_feats_plus.txt)')
    parser.add_argument('dataDir', type = str, default = 'data',
                        help = 'Where to look for the "by_id" directory')
    parser.add_argument('data_obj_feats_file', type = str,
                        help = 'Which data_objs_feats.txt file to load')

    args = parser.parse_args()

    resman.start(args.name, diary = not args.nodiary)
    saveDir = resman.rundir

    #print 'Loading StackedLayers from %s' % args.stackedLayersFilename
    #sl = loadFromPklGz(args.stackedLayersFilename)
    #print 'Loaded these StackedLayers:'
    #sl.printStatus()

    stackedLayers = None
    if args.stackedlayers:
        stackedLayers = loadFromPklGz(args.stackedlayers)

    makeFeats(dataDir = args.dataDir, featsFilename = args.data_obj_feats_file,
              saveDir = saveDir, outputFilename = args.outfile, quick = args.quick,
              stackedLayers = stackedLayers, formattedDataDir = args.fdata,
              featsBase = True, featsConst = 0, featsRand = 0, featsSL = False, featsTruth = False)
    
    resman.stop()
def ricaRun(randSeed, resman):
    testfn('rica')

    data = loadFromPklGz('../data/atari/mspacmantrain_15_50000_3c.pkl.gz')
    data = data.T  # Make into one example per column

    print 'randSeed is', randSeed
    random.seed(randSeed)
    print 'making dirs'
    thisdir = os.path.join(resman.rundir, 'seed-%03d' % randSeed)
    os.makedirs(thisdir)
    rica = RICA(imgShape=(15, 15, 3),
                nFeatures=400,
                lambd=.05,
                epsilon=1e-5,
                saveDir=thisdir)
    rica.run(data, maxFun=3, whiten=True)

    return 'finished return value'
def main():
    parser = argparse.ArgumentParser(description='Trains a StackedLayers model.')
    parser.add_argument('layerFilename', type = str,
                        help = 'File defining layers, something like tica-10-15.layers')
    parser.add_argument('trainParamsFilename', type = str,
                        help = 'File defining training parameters, something like tica-10-15.trainparams')
    parser.add_argument('--name', type = str, default = 'junk',
                        help = 'Name for GitResultsManager results directory (default: junk)')
    parser.add_argument('--load', type = str, default = '',
                        help = ('Load a previously created StackedLayers object. This can ' +
                                'be used to resume training a previously checkpointed, ' +
                                'partially trained StackedLayers object (default: none)'))
    parser.add_argument('--quick', action='store_true', help = 'Enable quick mode (default: off)')
    parser.add_argument('--nodiary', action='store_true', help = 'Disable diary (default: diary is on)')

    args = parser.parse_args()

    resman.start(args.name, diary = not args.nodiary)
    saveDir = resman.rundir


    layerDefinitions = importFromFile(args.layerFilename, 'layers')
    trainParams = importFromFile(args.trainParamsFilename, 'trainParams')

    shutil.copyfile(args.layerFilename,       os.path.join(saveDir, 'params.layers'))
    shutil.copyfile(args.trainParamsFilename, os.path.join(saveDir, 'params.trainparams'))

    if args.load:
        print 'Loading StackedLayers object from %s' % args.load
        sl = loadFromPklGz(args.load)
    else:
        print 'Creating new StackedLayers object'
        sl = StackedLayers(layerDefinitions)

    sl.printStatus()

    sl.train(trainParams, saveDir = saveDir, quick = args.quick)

    resman.stop()
'''

import pdb
import os, sys, time
from numpy import *

from rica import RICA
from GitResultsManager import resman
from util.dataLoaders import loadFromPklGz, saveToFile



if __name__ == '__main__':
    resman.start('junk', diary = False)

    Nw = 4
    dataXX, dataYY = loadFromPklGz('../data/simpleShapes/train_%02d_50.pkl.gz' % Nw)
    #dataXX, dataYY = loadFromPklGz('../data/simpleShapes/train_%02d_50000.pkl.gz' % Nw)
    data = dataXX.T   # Make into one example per column

    random.seed(0)
    rica = RICA(imgShape = (Nw, Nw),
                nFeatures = 400,
                lambd = .05,
                epsilon = 1e-5,
                saveDir = resman.rundir)
    rica.run(data, maxFun = 300)
    #rica.run(data, maxFun = 300, whiten = True)

    resman.stop()
from PIL import Image
from scipy.optimize.lbfgsb import fmin_l_bfgs_b

from tica import TICA
from GitResultsManager import resman, fmtSeconds
from util.plotting import tile_raster_images
from util.dataLoaders import loadFromPklGz, saveToFile



if __name__ == '__main__':
    resman.start('junk', diary = False)

    print 'probably want simple instead... finish this file first'
    sys.exit(1)
    data = loadFromPklGz('../data/atari/mspacman_train_15_50000_3c.pkl.gz')
    data = data.T   # Make into one example per column
    #data = data[:,:5000]      # HACK!!!!!!!!!
    
    #hiddenISize = 20
    #hiddenJSize = 20
    #lambd = .05
    #neighborhoodSize = 1
    #print '\nChosen TICA parameters'
    
    hiddenISize = random.randint(4, 25+1)
    hiddenJSize = random.randint(10, 30+1)
    lambd = .1 * 2 ** random.randint(-5, 5+1)
    neighborhoodSize = random.uniform(.1,3)
    print '\nRandomly selected TICA parameters'
Esempio n. 14
0
        self.WW = self.runOptimization(data, maxFun, plotEvery)

        #if self.saveDir:
        #    saveToFile(os.path.join(self.saveDir, 'WW+pca.pkl.gz'), (WW, self.pca))

        # Make and save some plots
        self.plotCostLog()
        #if self.doPlots:
        #    self.plotWW(WW)
        #self.plotActivations(WW, data)
        #if self.doPlots:
        #    self.plotReconstructions(WW, data)


if __name__ == '__main__':
    resman.start('junk', diary=False)

    data = loadFromPklGz('../data/rica_hyv_patches_16.pkl.gz')
    #data = data[:,:5000]  #HACK

    random.seed(0)
    rica = RICA(imgShape=(16, 16),
                nOutputs=50,
                lambd=.05,
                epsilon=1e-5,
                float32=False,
                saveDir=resman.rundir)
    rica.learn(data, plotEvery=None, maxFun=5, whiten=True)

    resman.stop()
Esempio n. 15
0
import os, sys, time
from numpy import *
from PIL import Image

from tica import TICA
from GitResultsManager import resman
from util.plotting import tile_raster_images
from util.dataLoaders import loadFromPklGz, saveToFile



if __name__ == '__main__':
    resman.start('junk', diary = False)

    #data = loadFromPklGz('../data/atari/mspacman_train_15_50000_3c.pkl.gz')
    data = loadFromPklGz('../data/atari/space_invaders_train_15_50000_3c.pkl.gz')
    data = data.T   # Make into one example per column
    #data = data[:,:5000]      # HACK!!!!!!!!!
    
    hiddenISize = 8
    hiddenJSize = 8
    lambd = .05
    neighborhoodSize = 1.5
    print '\nChosen TICA parameters'
    
    #hiddenISize = random.randint(4, 25+1)
    #hiddenJSize = random.randint(10, 30+1)
    #lambd = .1 * 2 ** random.randint(-5, 5+1)
    #neighborhoodSize = random.uniform(.1,3)
    #print '\nRandomly selected TICA parameters'
import os, sys, time
from numpy import *
from PIL import Image
from scipy.optimize.lbfgsb import fmin_l_bfgs_b

from tica import TICA
from GitResultsManager import resman, fmtSeconds
from util.plotting import tile_raster_images
from util.dataLoaders import loadFromPklGz, saveToFile

if __name__ == '__main__':
    resman.start('junk', diary=False)

    print 'probably want simple instead... finish this file first'
    sys.exit(1)
    data = loadFromPklGz('../data/atari/mspacman_train_15_50000_3c.pkl.gz')
    data = data.T  # Make into one example per column
    #data = data[:,:5000]      # HACK!!!!!!!!!

    #hiddenISize = 20
    #hiddenJSize = 20
    #lambd = .05
    #neighborhoodSize = 1
    #print '\nChosen TICA parameters'

    hiddenISize = random.randint(4, 25 + 1)
    hiddenJSize = random.randint(10, 30 + 1)
    lambd = .1 * 2**random.randint(-5, 5 + 1)
    neighborhoodSize = random.uniform(.1, 3)
    print '\nRandomly selected TICA parameters'
def main():
    parser = argparse.ArgumentParser(
        description=
        'Makes features for the human activity deteciton dataset. Example usage:\n./humanObjectFeatures.py /path/to/data_obj_feats.txt'
    )
    parser.add_argument(
        '--name',
        type=str,
        default='junk',
        help='Name for GitResultsManager results directory (default: junk)')
    parser.add_argument('--quick',
                        action='store_true',
                        help='Enable quick mode (default: off)')
    parser.add_argument('--nodiary',
                        action='store_true',
                        help='Disable diary (default: diary is on)')

    #parser.add_argument('stackedLayersFilename', type = str,
    #                    help = 'File where a StackedLayers model was stored, something like stackedLayers.pkl.gz')
    #parser.add_argument('command', type = str, default = 'embed', choices = ['visall', 'embed'], nargs='?',
    #                    help = 'What to do: one of {visall (save all plots), embed (drop into shell)}. Default: embed.')

    parser.add_argument(
        '--stackedlayers',
        type=str,
        default='',
        help=
        'Path to a *.pkl.gz file containing a pickeled StackedLayers object to load (default: None)'
    )
    parser.add_argument(
        '--fdata',
        type=str,
        default='',
        help=
        'Path to a "..../formatted/data/method_name" directory containing files like 0510175829_1.txt. Needed only if adding truth labels. (default: None)'
    )
    parser.add_argument(
        '--outfile',
        type=str,
        default='data_objs_feats_plus.txt',
        help='What to name the output file (default: data_objs_feats_plus.txt)'
    )
    parser.add_argument('dataDir',
                        type=str,
                        default='data',
                        help='Where to look for the "by_id" directory')
    parser.add_argument('data_obj_feats_file',
                        type=str,
                        help='Which data_objs_feats.txt file to load')

    args = parser.parse_args()

    resman.start(args.name, diary=not args.nodiary)
    saveDir = resman.rundir

    #print 'Loading StackedLayers from %s' % args.stackedLayersFilename
    #sl = loadFromPklGz(args.stackedLayersFilename)
    #print 'Loaded these StackedLayers:'
    #sl.printStatus()

    stackedLayers = None
    if args.stackedlayers:
        stackedLayers = loadFromPklGz(args.stackedlayers)

    makeFeats(dataDir=args.dataDir,
              featsFilename=args.data_obj_feats_file,
              saveDir=saveDir,
              outputFilename=args.outfile,
              quick=args.quick,
              stackedLayers=stackedLayers,
              formattedDataDir=args.fdata,
              featsBase=True,
              featsConst=0,
              featsRand=0,
              featsSL=False,
              featsTruth=False)

    resman.stop()
Esempio n. 18
0
Jason Yosinski
'''

import pdb
import os, sys, time
from numpy import *

from rica import RICA
from GitResultsManager import resman
from util.dataLoaders import loadFromPklGz, saveToFile

if __name__ == '__main__':
    resman.start('junk', diary=False)

    Nw = 4
    dataXX, dataYY = loadFromPklGz(
        '../data/simpleShapes/train_%02d_50.pkl.gz' % Nw)
    #dataXX, dataYY = loadFromPklGz('../data/simpleShapes/train_%02d_50000.pkl.gz' % Nw)
    data = dataXX.T  # Make into one example per column

    random.seed(0)
    rica = RICA(imgShape=(Nw, Nw),
                nFeatures=400,
                lambd=.05,
                epsilon=1e-5,
                saveDir=resman.rundir)
    rica.run(data, maxFun=300)
    #rica.run(data, maxFun = 300, whiten = True)

    resman.stop()
Esempio n. 19
0
import os, sys, time
from numpy import *
from PIL import Image
from scipy.optimize.lbfgsb import fmin_l_bfgs_b

from rica import RICA
from GitResultsManager import resman, fmtSeconds
from util.plotting import tile_raster_images
from util.dataLoaders import loadFromPklGz, saveToFile



if __name__ == '__main__':
    resman.start('junk', diary = False)

    data = loadFromPklGz('../data/upson_rovio_2/train_10_50000_1c.pkl.gz')
    data = data.T   # Make into one example per column
    #data = data[:,:5000]      # HACK!!!!!!!!!
    
    nFeatures = 100
    lambd = .05
    neighborhoodSize = 1.5
    print '\nChosen TICA parameters'
    
    for key in ['nFeatures', 'lambd']:
        print '  %20s: %s' % (key, locals()[key])
    
    random.seed(0)
    rica = RICA(imgShape = (10, 10),
                nFeatures = nFeatures,
                lambd = lambd,
        #if self.saveDir:
        #    saveToFile(os.path.join(self.saveDir, 'WW+pca.pkl.gz'), (WW, self.pca))

        # Make and save some plots
        self.plotCostLog()
        #if self.doPlots:
        #    self.plotWW(WW)
        #self.plotActivations(WW, data)
        #if self.doPlots:
        #    self.plotReconstructions(WW, data)



if __name__ == '__main__':
    resman.start('junk', diary = False)

    data = loadFromPklGz('../data/rica_hyv_patches_16.pkl.gz')
    #data = data[:,:5000]  #HACK
    
    random.seed(0)
    rica = RICA(imgShape = (16, 16),
                nOutputs = 50,
                lambd = .05,
                epsilon = 1e-5,
                float32 = False,
                saveDir = resman.rundir)
    rica.learn(data, plotEvery = None, maxFun = 5, whiten = True)

    resman.stop()