bp神经网络运行报错sum() got an unexpected keyword argument 'keepdims'
时间: 2023-10-05 22:06:04 浏览: 39
这个错误通常是因为您使用的 Numpy 版本太老,不支持 `keepdims` 参数。请尝试更新 Numpy 版本,或者在调用 `sum()` 函数时去掉 `keepdims` 参数。
如果您使用的是较新的 Numpy 版本,可能是因为您的输入数据类型不正确导致的。请确保输入数据类型为 Numpy 数组,并且保证数组的维度正确。
相关问题
sum() got an unexpected keyword argument 'keepdims'
The error message you are seeing indicates that the `sum()` function is not expecting the `keepdims` keyword argument that you have provided.
The `keepdims` argument was added to the `sum()` function in Python 3.2, so if you are using an earlier version of Python, you may see this error. To fix this issue, you can either upgrade your Python version to 3.2 or later, or you can remove the `keepdims` argument from your `sum()` function call.
If you are using Python 3.2 or later and still seeing this error, double-check that you are not misspelling the argument name or using it in an unsupported way.
TypeError: sum() got an unexpected keyword argument 'keepdims'
这个错误通常是因为您正在使用的Python版本不支持`keepdims`参数。`keepdims`参数是在Python 3.2中引入的,如果您的Python版本低于3.2,则不支持该参数。
解决此问题的方法是升级您的Python版本或删除`keepdims`参数。如果您想保留`keepdims`参数,则可以使用以下代码:
```python
import numpy as np
a = np.array([[1, 2], [3, 4]])
sum_a = np.sum(a, axis=0, keepdims=True)
print(sum_a)
```
这将使用NumPy库中的`sum`函数来计算数组`a`的列和,并将`keepdims`参数设置为`True`。这将返回一个形状为`(1,2)`的数组,其中包含列和。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)