# Fix TensorFlow tf.reverse() ValueError: Shape must be rank 1 but is rank 0 – TensorFlow Tutorial

By | June 28, 2020

When you are using tensorflow tf.reverse() function, you may find this error: ValueError: Shape must be rank 1 but is rank 0. In this tutorial, we will tell you how to fix this error.

As to code below:

x1 = tf.reverse(x, axis = 0)

where x is a tensor, which will be reversed based on axis 0. However, run this code, you will get a value error.

How to fix this value error?

To fix this value error is very simple, we shoud make axis is a list. For example:

x1 = tf.reverse(x, axis = [0])

Then this value error is fixed.