久久久久久久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 對象)
主站蜘蛛池模板: 日韩有码在线播放 | 涩涩视频在线观看 | 国产精品久久免费观看 | 看av片网站 | 久久99精品久久久 | 成人日韩av | 日韩一区欧美一区 | 日日干日日操 | 无码一区二区三区视频 | 午夜在线免费观看 | 无码日韩精品一区二区免费 | 久久久精品网站 | 欧美一区二区三区在线 | www.9191.com| 国产精品视频在线观看 | 午夜在线视频 | 久久久久久久一区二区三区 | 久久丝袜视频 | 欧美激情精品久久久久久 | 一区二区三区四区在线视频 | 国产三级在线观看播放 | 欧美一区二区三区在线免费观看 | 久久久久久久久久久久久久久久久久久久 | 国产精品久久久久久吹潮 | 亚洲精品一级 | 美女人人操| 国产日韩免费视频 | 日韩毛片播放 | 日本一区二区高清不卡 | 成人在线观看网址 | 欧美aaa级| av毛片 | 天天干天天爽 | 男人天堂视频在线观看 | 在线色网站| 日韩在线91 | 亚洲欧美自拍偷拍视频 | 天堂精品视频 | 国产精品a久久久久 | 久久久久久久久久久久久久国产 | 性欧美精品一区二区三区在线播放 |