view _nnet_ops.py @ 216:4b7e89b75e2b

Modified ArrayDataSet's handling of column fields. Previously, if a fieldname were associated with an integer column index (by opposition to a column range or slice) then it would be returned as a Nx1 matrix. Now if a fieldname is associated with an integer column index, then it will make a field which is a vector of length N. The old behaviour can still be achieved by associating a fieldname with the slice(col, col+1).
author James Bergstra <bergstrj@iro.umontreal.ca>
date Thu, 22 May 2008 19:07:51 -0400
parents 3ef569b92fba
children
line wrap: on
line source


import unittest
import theano._test_tensor as TT
import numpy

from nnet_ops import *

class T_sigmoid(unittest.TestCase):
    def setUp(self):
        numpy.random.seed(9999)
    def test_elemwise(self):
        TT.verify_grad(self, sigmoid, [numpy.random.rand(3,4)])

class T_softplus(unittest.TestCase):
    def setUp(self):
        numpy.random.seed(9999)
    def test_elemwise(self):
        TT.verify_grad(self, softplus, [numpy.random.rand(3,4)])

class T_CrossentropySoftmax1Hot(unittest.TestCase):
    def setUp(self):
        numpy.random.seed(9999)
    def test0(self):
        y_idx = [0,1,3]
        class Dummy(object):
            def make_node(self, a,b):
                return crossentropy_softmax_1hot_with_bias(a, b, y_idx)[0:1]
        TT.verify_grad(self, Dummy(), [numpy.random.rand(3,4),
            numpy.random.rand(4)])

    def test1(self):
        y_idx = [0,1,3]
        class Dummy(object):
            def make_node(self, a):
                return crossentropy_softmax_1hot(a, y_idx)[0:1]
        TT.verify_grad(self, Dummy(), [numpy.random.rand(3,4)])



if __name__ == '__main__':
    unittest.main()