运行文档中的rasa_核心示例
› python3 -m rasa_core.run -d models/dialogue -u models/nlu/default/current
并在对话框中的每条消息之后获取此错误输出:
.../sklearn/...: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.
这是一个关于numpy的问题,该问题已被修复,但尚未在最新版本中发布:https://github.com/scikit-learn/scikit-learn/issues/10449
以下操作未起作用,无法暂时关闭警告:
-W ignore
python3 -W ignore -m rasa_core.run -d models/dialogue -u models/nlu/default/current
warnings.simplefilter
python3
>>> warnings.simplefilter('ignore', DeprecationWarning)
>>> exit()
python3 -m rasa_core.run -d models/dialogue -u models/nlu/default/current
此警告是由于numpy不赞成使用truth value check on empty array
这种改变的理由是
检查以下示例:
解决方案
根据scikit learn library上的issue 10449,此问题已在library的master分支中修复。但是,这将在2018年8月左右提供,因此一个可能的替代方案是使用不存在此问题的较低版本的numpy库,即1.13.3,因为scikit库默认将引用最新版本的numpy(在编写此答案时为1.14.2)
或者使用pip3,如下所示
忽略警告
如果我们想使用最新版本的库(在本例中是numpy),它给出了deprecation警告,并且只想让deprecation警告保持沉默,那么我们可以使用python的filterwarnings模块的Warnings方法来实现它
以下示例将生成上述问题中提到的折旧警告:
产生
为了解决这个问题,添加filterwarning作为DeprecationWarning
如果有多个模块发出警告,并且我们希望选择性地发出无声警告,则使用模块属性。e、 g.从scikit学习模块发出无声弃用警告
相关问题 更多 >
编程相关推荐