Traceback (most recent call last): File "E:\PycharmProjects\pythonProject\cnn_test\CNN_AlexNet\start.py", line 18, in <module> solver.train() File "E:\PycharmProjects\pythonProject\cnn_test\CNN_AlexNet\solver.py", line 225, in train self._step() File "E:\PycharmProjects\pythonProject\cnn_test\CNN_AlexNet\solver.py", line 165, in _step loss, grads = self.model.loss(X_batch, y_batch) File "E:\PycharmProjects\pythonProject\cnn_test\CNN_AlexNet\cnn.py", line 104, in loss a3, cache3 = conv_relu_forward(a2,W34,b34,conv_param34) File "E:\PycharmProjects\pythonProject\cnn_test\CNN_AlexNet\layer_utils.py", line 47, in conv_relu_forward a, conv_cache = conv_relu_forward(x, w, b, conv_param) File "E:\PycharmProjects\pythonProject\cnn_test\CNN_AlexNet\layer_utils.py", line 47, in conv_relu_forward a, conv_cache = conv_relu_forward(x, w, b, conv_param) File "E:\PycharmProjects\pythonProject\cnn_test\CNN_AlexNet\layer_utils.py", line 47, in conv_relu_forward a, conv_cache = conv_relu_forward(x, w, b, conv_param) [Previous line repeated 993 more times] RecursionError: maximum recursion depth exceeded
时间: 2023-10-08 16:06:35 浏览: 82
python-unit-test-tool-comparison:比较Python unittest,nose和py.test
这个错误通常出现在使用递归函数时,递归层数超过了系统允许的最大递归深度,导致程序出错。在您的代码中,出现了无限递归的情况,导致递归深度超过了Python解释器的限制。要解决这个问题,您可以考虑以下方法:
1. 优化代码,减少递归调用次数,避免无限递归的情况。
2. 增加 Python 解释器的最大递归深度限制,例如使用 sys.setrecursionlimit() 函数进行设置。
3. 重新设计算法,避免使用递归函数,改用循环等其他方式实现逻辑。
希望这些方法对您有所帮助。
阅读全文