I am getting the following error when using images2neibs with neib_shape is 
given as variables and used in a function with scan.

python shapebug.py 
Using gpu device 0: Quadro K4200 (CNMeM is disabled, cuDNN 5004)
theano version 0.8.2
WARNING (theano.tensor.opt): Failed to infer_shape from Op 
Input shapes: [(TensorConstant{1}, Shape_i{1}.0, Shape_i{2}.0, 
Shape_i{3}.0), (TensorConstant{2},), (TensorConstant{2},)]
Exception encountered during infer_shape: <type 'exceptions.ValueError'>
Exception message: length not known: <TensorType(int8, vector)> [id A]

Traceback: Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/theano/tensor/opt.py", line 
917, in get_node_infer_shape
    [self.shape_of[r] for r in node.inputs])
line 258, in infer_shape
    c, d = node.inputs[1]
  File "/usr/local/lib/python2.7/dist-packages/theano/tensor/var.py", line 
549, in __iter__
    for i in xrange(theano.tensor.basic.get_vector_length(self)):
  File "/usr/local/lib/python2.7/dist-packages/theano/tensor/basic.py", 
line 4300, in get_vector_length
    raise ValueError("length not known: %s" % msg)
ValueError: length not known: <TensorType(int8, vector)> [id A]

The code I am running is:

import theano
import theano.tensor as T
from theano.tensor.nnet.neighbours import images2neibs
import numpy as np

def process_one_input_image(input_image, filter_h, filter_w):
    all_windows = images2neibs(input_image.dimshuffle('x', 0, 1, 2), 
neib_shape=(filter_h, filter_w), neib_step=(1, 1))

    # some other code

    return all_windows

def process_all_input_images(input_images, filter_h, filter_w):
    s, _ = theano.scan(fn=process_one_input_image, 
sequences=[input_images], non_sequences=[filter_h, filter_w])

    return s

print 'theano version', theano.__version__

input_images = T.tensor4('input_images')

num_input_images = 3
image_h = 5
image_w = 5
image_ch = 2

filter_h = 2
filter_w = 2

windows = process_all_input_images(input_images, filter_h, filter_w)

f = theano.function([input_images], windows)

images = np.arange(num_input_images * image_h * image_w * 
image_ch).reshape((num_input_images, image_ch, image_h, 

print f(images)

If I change neib_shape=(filter_h, filter_w) to e.g. neib_shape=(2, 2) the 
error goes away.

Is this a bug or am I doing something wrong? How do I get around it?

Petar Palasek


You received this message because you are subscribed to the Google Groups 
"theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to theano-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to