0

While trying out the 'pool_2d' method of Theano, I got the error "Wrong number of dimensions: expected 4, got 1 with shape (16, )". The code is given below.

from theano import tensor, shared, function
from theano.tensor.signal.pool import pool_2d
import numpy


class Test:
    def __init__(self):
        i = tensor.dtensor4()
        o = pool_2d(input = i, ws = (2, 2), ignore_border = True, stride = None, pad = (0, 0), mode = 'max')

        self.pool = function([i], o)

    def pool(self, iput):
        iput = numpy.array(iput)
        iput.shape = (1, 1, 4, 4)
        print(self.pool(iput))


x = Test()
x.pool([1.,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.,15.,16.])

What is the reason for the error here?

Manu Soman
  • 153
  • 11

1 Answers1

0

It was a stupid mistake I did. I assigned the Theano function to self.pool variable and then created another method with the same name as 'pool' causing name clash.

Manu Soman
  • 153
  • 11