2

我正在尝试学习如何使用 anaconda 的加速库。根据https://docs.anaconda.com/accelerate/cublas.html, amin() 方法“查找数组 x 中第一个最大元素的索引。与 np.argmax(x) 相同”。

这是我的代码:

import accelerate.cuda.blas as blas
import numpy as np

self = blas.Blas()
a = np.array([1, 2, 3, 4])
print(self.amin(a))

这就是它返回的内容

Traceback (most recent call last):
File "/opt/anaconda1anaconda2anaconda3\api.py", line 147, in _dispatch
KeyError: dtype('int32')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\Boo\Desktop\clarify.py", 
line 11, in <module>
print(self.amin(a))
File "/opt/anaconda1anaconda2anaconda3\api.py", line 238, in amin
File "/opt/anaconda1anaconda2anaconda3\api.py", line 149, in _dispatch
TypeError: int32
4

1 回答 1

0

np.array需要是float32数组而不是默认值int32

import accelerate.cuda.blas as blas
import numpy as np

self = blas.Blas()
a = np.array([1, 2, 3, 4], dtype='float32')
print(self.amin(a))
于 2018-01-29T04:29:26.790 回答