简体   繁体   中英

How to fix "RecursionError: maximum recursion depth exceeded"

I am using keras to generate the images of dogs using GAN for a kaggle competitions. I am using google colab. But i am encountering an error.

ERROR

RecursionError: maximum recursion depth exceeded

CODE

Here is the function:

def load_data():
(x_train, y_train), (x_test, y_test) = load_data()
x_train = (x_train.astype(np.float32) - 127.5)/127.5
x_train = x_train.reshape(60000, 784)
return (x_train, y_train, x_test, y_test)
(X_train, y_train,X_test, y_test)=load_data()
print(X_train.shape)

Hope anyone can help.

The function is doing infinite recursion, its called load_data() and it calls load_data() without any recursion limit, hence infinite recursion.

You probably want to call load_data() in a module, like cifar10 or mnist , and for that you have to specifically refer to that module, for example, keras.datasets.mnist.load_data() .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM