'numpy.ndarray' object has no attribute 'permute'
时间: 2023-10-02 22:10:25 浏览: 633
`numpy.ndarray` object does not have a built-in `permute` attribute. If you want to permute the dimensions of a NumPy array, you can use the `transpose` function or the `swapaxes` method. Here is an example of how you can permute the dimensions of a NumPy array:
```python
import numpy as np
arr = np.array([[1, 2, 3], [4, 5, 6]])
# Permute the dimensions using transpose
permuted_arr = np.transpose(arr)
# Permute the dimensions using swapaxes
permuted_arr = arr.swapaxes(0, 1)
print(permuted_arr)
```
Both `transpose` and `swapaxes` allow you to specify the new order of dimensions. In the example above, the original array `arr` has dimensions (2, 3), and the permuted array `permuted_arr` has dimensions (3, 2) after transposing or swapping axes.
阅读全文
相关推荐


















