InvalidArgumentError: Expected dimension in the range [-1, 1) but got 1

mdlee6 picture mdlee6 · Jun 24, 2017 · Viewed 7.7k times · Source

I'm not sure what this error means. This error occurs when I try to calculate acc:

acc = accuracy.eval(feed_dict = {x: batch_images, y: batch_labels, keep_prob: 1.0})

I've tried looking up solutions, but I couldn't find any online. Any ideas on what's causing my error?

Here's a link to my full code.

Answer

Charles Duffy picture Charles Duffy · Jun 24, 2017

The source code generating this error reads as follows:

OP_REQUIRES(context, axis >= 0 && axis < input_dims,
            errors::InvalidArgument("Expected dimension in the range [",
                                    -input_dims, ", ", input_dims,
                                    "), but got ", dim));

Note that axis is required to be less than input_dims, not less-than-or-equal.

This conforms with the syntax [-1,1) in the message: [ indicates an inclusive value (such that -1 is valid), whereas ) indicates an exclusive value (putting 1 itself outside the range).