view algorithms/tests/test_aa.py @ 481:267ec8baef9f

added import to make test_aa run
author James Bergstra <bergstrj@iro.umontreal.ca>
date Mon, 27 Oct 2008 19:40:17 -0400
parents 8fcd0f3d9a17
children
line wrap: on
line source

#from __future__ import absolute_imports

from pylearn import algorithms as models
import theano
import numpy
import time


def test_train(mode = theano.Mode('c|py', 'fast_run')):

    aa = models.SigmoidXEAutoEncoder(regularize = False)
#     print aa.update.pretty(mode = theano.Mode('py', 'fast_run').excluding('inplace'))

    model = aa.make(lr = 0.01,
                    input_size = 100,
                    hidden_size = 1000,
                    mode = mode)

    data = [[0, 1, 0, 0, 1, 1, 1, 0, 1, 0]*10]*10
    #data = numpy.random.rand(10, 100)

    t1 = time.time()
    for i in xrange(1001):
        cost = model.update(data)
        if i % 100 == 0:
            print i, cost
    t2 = time.time()
    return t2 - t1

if __name__ == '__main__':
    numpy.random.seed(10)
    print 'optimized:'
    t1 = test_train(theano.Mode('c|py', 'fast_run'))
    print 'time:',t1
    print

    numpy.random.seed(10)
    print 'not optimized:'
    t2 = test_train(theano.Mode('c|py', 'fast_compile'))
    print 'time:',t2