在python和numba中更新嵌套字典中的值时键入错误

在python和numba中更新嵌套字典中的值时键入错误,python,numba,Python,Numba,我一直在研究一种表格学习算法,其知识在python中表示为嵌套字典数据结构。 由于我的代码很慢,我计划使用numba。 但是,它始终显示以下引用值更新步骤的错误,如下所示: update = Q_dict[state_string][action_string] + lr * (reward + gamma * max(List(Q_dict[next_state_string].values())) - Q_dict[state_string][action_string])

我一直在研究一种表格学习算法,其知识在python中表示为嵌套字典数据结构。 由于我的代码很慢,我计划使用numba。 但是,它始终显示以下引用值更新步骤的错误,如下所示:

update = Q_dict[state_string][action_string] + lr * (reward + gamma * max(List(Q_dict[next_state_string].values())) - Q_dict[state_string][action_string])
            Q_dict[state_string][action_string] = update
这行代码会引发以下错误:

TypingError: Failed in nopython mode pipeline (step: nopython frontend)
No implementation of function Function(<built-in function setitem>) found for signature:
 
 >>> setitem(DictType[unicode_type,int64]<iv=None>, unicode_type, float64)
 
There are 16 candidate implementations:
      - Of which 14 did not match due to:
      Overload of function 'setitem': File: <numerous>: Line N/A.
        With argument(s): '(DictType[unicode_type,int64]<iv=None>, unicode_type, float64)':
       No match.
      - Of which 2 did not match due to:
      Overload in function 'impl_setitem': File: numba/typed/dictobject.py: Line 674.
        With argument(s): '(DictType[unicode_type,int64]<iv=None>, unicode_type, float64)':
       Rejected as the implementation raised a specific error:
         TypingError: Failed in nopython mode pipeline (step: nopython frontend)
       No implementation of function Function(<intrinsic _cast>) found for signature:
        
        >>> <unknown function>(float64, class(int64))
        
       There are 2 candidate implementations:
             - Of which 2 did not match due to:
             Intrinsic in function '_cast': File: numba/typed/typedobjectutils.py: Line 23.
               With argument(s): '(float64, class(int64))':
              Rejected as the implementation raised a specific error:
                TypingError: cannot safely cast float64 to int64. Please cast explicitly.
TypingError:在nopython模式管道中失败(步骤:nopython前端)
未找到签名的函数()的实现:
>>>setitem(DictType[unicode\u-type,int64],unicode\u-type,float64)
有16种候选实现:
-其中14个不匹配,原因是:
函数“setitem”的重载:文件::行N/A。
带参数:'(DictType[unicode_-type,int64],unicode_-type,float64):
没有对手。
-其中2个不匹配,原因是:
函数“impl_setitem”中的重载:文件:numba/typed/dictobject.py:第674行。
带参数:'(DictType[unicode_-type,int64],unicode_-type,float64):
已拒绝,因为实现引发了特定错误:
TypingError:在nopython模式管道中失败(步骤:nopython前端)
未找到签名的函数()的实现:
>>>(浮点64,类(int64))
有两种候选实现:
-其中2个不匹配,原因是:
函数“_cast”中的固有属性:文件:numba/typed/typedobjectutils.py:第23行。
带参数:“(float64,类(int64))”:
已拒绝,因为实现引发了特定错误:
TypingError:无法安全地将float64强制转换为int64。请明确地施法。
我搜索了网上资源,但没有找到任何有用的东西。 如能了解导致此错误的原因,将不胜感激