简体   繁体   English

ELMo嵌入中的“Highway.forward:输入必须存在”?

[英]`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.

相关问题 为什么我得到 Highway.forward:运行时必须存在“输入”:从 elmoformanylangs 导入嵌入器 - Why i getting Highway.forward: `input` must be present when running : from elmoformanylangs import Embedder 带Keras的ELMo嵌入层 - ELMo Embedding layer with Keras 使用ELMo嵌入段落 - Paragraph embedding with ELMo Elmo是嵌入词还是嵌入句子? - Is Elmo a word embedding or a sentence embedding? 在Keras Elmo嵌入层中有0个参数吗? 这正常吗? - In Keras elmo embedding layer has 0 parameters? is this normal? 如何在 sklearn 中使用 BERT 和 Elmo 嵌入 - How to use BERT and Elmo embedding with sklearn 从头开始为 Training ELMO Embedding 准备训练数据 - Training data preparation for Training ELMO Embedding from scratch 如何在交互模式下使用 Elmo 词嵌入与原始预训练模型(5.5B) - How to use Elmo word embedding with the original pre-trained model (5.5B) in interactive mode 将ELMo与Keras结合使用时,如何正确输入训练集和标签? - Using ELMo with Keras, how to correctly input the training set and labels? ValueError:检查输入时出错:预期 input_1 具有形状 (50,),但使用 ELMo 嵌入和 LSTM 获得形状为 (1,) 的数组 - ValueError: Error when checking input: expected input_1 to have shape (50,) but got array with shape (1,) with ELMo embeddings and LSTM
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM