KeyError:用于Anaconda Accelerate库的dtype(' int32')

时间:2018-01-29 03:41:31

标签: python anaconda accelerate

我正在尝试学习如何使用anaconda的加速库。根据{{​​3}},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

1 个答案:

答案 0 :(得分: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))