[英]`Highway.forward: input must be present` in ELMo embedding?
I use Elmo Embeddings for my NLP task.我将Elmo 嵌入用于我的 NLP 任务。 The pretrain was in the Indonesian language from this git .
预训练是来自此 git的印度尼西亚语。 Importing the library by using the syntax
使用语法导入库
from elmoformanylangs import Embedder
causing the following error:导致以下错误:
TypeError: Highway.forward: input must be present
Please help me to understand what the error message means.请帮助我理解错误消息的含义。
Not sure if this helps, but this refers to the unimplemented superclass method (forward) in torch.nn.Module
.不确定这是否有帮助,但这指的是
torch.nn.Module
中未实现的超类方法(转发)。 This class has the following definiton.此 class 具有以下定义。
forward: Callable[..., Any] = _forward_unimplemented
If you scroll down a bit you will see the definiton of _forward_unimplemented:如果您向下滚动一点,您将看到 _forward_unimplemented 的定义:
def _forward_unimplemented(self, *input: Any) -> None:
The Highway forward definiton has to match this signature too, therefore you will need a *input
argument too.高速公路前向定义也必须匹配此签名,因此您也需要一个
*input
参数。 I got my Hungarian version working with the following signature and first line, probably this could help you too.我的匈牙利语版本使用以下签名和第一行,可能这也可以帮助你。
def forward(self, *input: torch.Tensor) -> type(None): #pylint: disable=arguments-differ
current_input = input[0]
I just edited my \elmoformanylangs\modules\highway.py file under the site-packages of my python environment, and got it working.我刚刚在我的 python 环境的站点包下编辑了我的 \elmoformanylangs\modules\highway.py 文件,并让它工作。
Just do this:只需这样做:
pip uninstall overrides
pip install overrides==3.1.0
My problem was due to an unsupported version of overrides
.我的问题是由于不支持的
overrides
版本造成的。
You can always install the appropriate version, if you are working with anaconda, through conda install overrides==no.version
.如果您正在使用 anaconda,您始终可以通过 conda
conda install overrides==no.version
安装适当的版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.