示例#1
0
    class DummyDataset:
        def __init__(self,X):
            self.X = X.transpose(0,3,1,2).reshape(X.shape[0],np.prod(X.shape[1:]))

        def get_design_matrix(self):
            return self.X

        def set_design_matrix(self,X):
            self.X = X

    X = model.get_input_space().make_batch_theano()
    Y = model.fprop(X)

    f = theano.function([X],Y)
    X = theano.tensor.tensor3()
    pool = theano.function([X],pooling.max_pool(X))

    Xs = []
    y = []

    for i, (x,y) in enumerate(zip(dataset.raw.get_design_matrix(),dataset.raw.get_targets())):
        print i, dataset.raw.get_design_matrix().shape
#        Xs.append(f(np.cast['float32'](row[None,:].reshape(1,3,96,96).transpose(0,2,3,1))))
        Xs.append(f(np.cast['float32'](x[None,:].reshape(1,96,96,3))))
        y.append(y)
        print Xs[-1]
        if i==5:
            break

    Xs = np.array(Xs)
    y = np.array(y)
示例#2
0
def test_max_pooling():
    x = T.tensor3()
    xval = numpy.random.rand(4, 3, 2)
    fn = theano.function([x], pooling.max_pool(x))
    fn(xval)
示例#3
0
def test_max_pooling():
    x = T.tensor3()
    xval = numpy.random.rand(4,3,2)
    fn = theano.function([x], pooling.max_pool(x))
    fn(xval)