view algorithms/tests/test_aa.py @ 476:8fcd0f3d9a17

added a few algorithms
author Olivier Breuleux <breuleuo@iro.umontreal.ca>
date Mon, 27 Oct 2008 17:26:00 -0400
parents
children 267ec8baef9f
line wrap: on
line source


import 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