久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Python/Numba:scipy.special.gammainc()的未知屬性錯誤

Python/Numba: Unknown attribute error with scipy.special.gammainc()(Python/Numba:scipy.special.gammainc()的未知屬性錯誤)
本文介紹了Python/Numba:scipy.special.gammainc()的未知屬性錯誤的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

使用@jit 裝飾器運行代碼時出現錯誤.似乎無法找到函數 scipy.special.gammainc() 的某些信息:

I am having an error when running code using the @jit decorator. It appears that some information for the function scipy.special.gammainc() can't be located:

Failed at nopython (nopython frontend)
Unknown attribute 'gammainc' for Module(<module 'scipy.special' from 'C:homeMinicondalibsite-packagesscipyspecial\__init__.pyc'>) $164.2 $164.3 = getattr(attr=gammainc, value=$164.2)

沒有@jit 裝飾器,代碼將運行良好.也許需要一些東西才能使 scipy.special 模塊的屬性對 Numba 可見?

Without the @jit decorator the code will run fine. Maybe there is something required to make the attributes of the scipy.special module visible to Numba?

提前感謝您的任何建議、意見等.

Thanks in advance for any suggestions, comments, etc.

推薦答案

問題是 gammainc 并不是 Numba 天生知道如何處理的一小部分函數之一(參見 http://numba.pydata.org/numba-doc/dev/reference/numpysupported.html) - 實際上沒有任何 scipy 函數.這意味著你不能在nopython"模式下使用它,不幸的是——它只需要把它當作一個普通的 python 函數調用.

The problem is that gammainc isn't one of the small list of functions that Numba inherently knows how to deal with (see http://numba.pydata.org/numba-doc/dev/reference/numpysupported.html) - in fact none of the scipy functions are. This means you can't use it in "nopython" mode, unfortunately - it just has to treat it as a normal python function call.

如果您刪除 nopython=True,它應該可以工作.然而,這并不是非常令人滿意,因為它可能會更慢.如果沒有看到您的代碼,很難知道確切的建議.但是,總的來說:

If you remove nopython=True, it should work. However, that isn't hugely satisfactory, because it may well be slower. Without seeing your code it's difficult to know exact what to suggest. However, in general:

  • 循環(不包含諸如 gammainc 之類的東西)將被加速,即使沒有 nopython.

  • loops (that don't contain things like gammainc) will be sped up, even without nopython.

gammainc 是一個ufunc",這意味著它可以輕松地一次應用于整個數組,并且無論如何都應該快速運行.

gammainc is a "ufunc", which means it can be readily applied to a whole array at a time, and should run quickly anyway.

你可以調用func.inspect_types()來查看它是否能夠編譯.

you can call func.inspect_types() to see it's been able to compile.

舉個簡單的例子:

from scipy.special import gammainc
import numba as nb
import numpy as np

@nb.jit # note - no "nopython"
def f(x):
  for n in range(x.shape[0]):
    x[n] += 1
  y = gammainc(x,2.5)
  for n in range(y.shape[0]):
    y[n] -= 1
  return y

f(np.linspace(0,20)) # forces it to be JIT'd and outputs an array

然后 f.inspect_types() 將這兩個循環標識為提升循環",這意味著它們將被 JIT 處理并快速運行.gammainc 的位不是 JIT 的,而是一次應用于整個數組,因此也應該很快.

Then f.inspect_types() identifies the two loops as "lifted loops", meaning they'll be JIT'd and run quickly. The bit with gammainc is not JIT'd, but is applied to the whole array at once and so should be fast too.

這篇關于Python/Numba:scipy.special.gammainc()的未知屬性錯誤的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Troubles while parsing with python very large xml file(使用 python 解析非常大的 xml 文件時出現問題)
Find all nodes by attribute in XML using Python 2(使用 Python 2 在 XML 中按屬性查找所有節點)
Python - How to parse xml response and store a elements value in a variable?(Python - 如何解析 xml 響應并將元素值存儲在變量中?)
How to get XML tag value in Python(如何在 Python 中獲取 XML 標記值)
How to correctly parse utf-8 xml with ElementTree?(如何使用 ElementTree 正確解析 utf-8 xml?)
Parse XML from URL into python object(將 XML 從 URL 解析為 python 對象)
主站蜘蛛池模板: 天天综合久久 | 操人网站 | 成人欧美一区二区三区黑人孕妇 | 毛片一区二区三区 | 日韩在线观看一区 | 亚洲精品一区二区三区丝袜 | 精品无码久久久久国产 | 精品久久香蕉国产线看观看亚洲 | 亚洲国产精品福利 | 羞羞的视频免费在线观看 | 国产精品久久久免费 | 亚洲国产一区二区视频 | 一区二区三区在线播放 | 亚洲一区二区三区免费观看 | 视频一区在线 | 欧美日韩专区 | 欧美激情亚洲激情 | 91一区二区三区在线观看 | 国产高清在线精品一区二区三区 | 99精品久久久久 | 精品视频在线一区 | 久久91av| 一区免费视频 | av一区二区三区 | 日韩电影中文字幕 | 99久久久久 | 日韩精品1区2区3区 成人黄页在线观看 | 欧美精品久久久久 | 国产欧美日韩综合精品一区二区 | 亚洲在线日韩 | 久久aⅴ乱码一区二区三区 91综合网 | 日韩国产在线观看 | www.一区二区三区 | 久久久久综合 | 亚洲精品国产精品国自产在线 | 婷婷桃色网 | 福利片在线| 国产一区二区三区四区区 | 久久久蜜臀国产一区二区 | 天堂一区二区三区四区 | 成人在线视频一区 |