InvalidArgumentError: expected dimension in the range [-1, 1), but received 1

I am not sure what this error means. This error occurs when trying to calculate acc:

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

I tried to find solutions, but could not find any on the Internet. Any ideas what caused my mistake?

Here is a link to my full code .

+7
source share
4 answers

, , argmax . , (50,), tf.argmax(y, 1) . : Tensorflow:

+2

, , :

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

, axis input_dims, .

[-1,1) : [ (, -1 ), ) ( 1 ).

+1

tf.equal(tf.argmax(y, 1), tf.argmax(labels, 1))

,

tf.equal(tf.argmax(y, -1), tf.argmax(labels, -1))

:

// tensorflow/compiler/tf2xla/kernels/index_ops_cpu.cc:58
OP_REQUIRES(ctx, axis >= 0 && axis < input_dims,
            errors::InvalidArgument("Expected dimension in the range [",
                                    -input_dims, ", ", input_dims,
                                    "), but got ", dim));
0

. batch_labels

# if use one hot code use
# y_true_cls = tf.argmax(y_true, dimension=1)

# if not one hot code use
y_true_cls = y_true

-1

Source: https://habr.com/ru/post/1680040/


All Articles