本文介绍了在Keras中导入Attention包会产生ModuleNotFoundError:没有名为"attention"的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为导入的一部分,我将导入AttentionLayer包,如下所示:

As part of my imports, I am importing the AttentionLayer package as follows:

from attention import AttentionLayer

我收到以下错误:

ModuleNotFoundError: No module named 'attention'

我认为这可能是因为我需要进行pip安装,所以我根据网上发现的其他答案尝试了一些尝试的pip安装:

I figured this might be because I need to pip install it so I tried based on other answers I found online a few pip installs I tried were:

pip install AttentionLayer
pip install Attention 
pip install keras-self-attention

所有这三个给我:

Could not find a version that satisfies the requirement keras-self-attention (from versions: ) No Matching distribution found for....

为什么我无法使它正常工作,如何解决?

Why am I not getting it to work and how can I fix it?

我怀疑这可能与设置pythonpath有关,但是我没有管理员权限才能在工作时对其进行编辑.

I have a suspicion that it might be related to setting the pythonpath but I do not have admin rights to edit this at work.

谢谢.

推荐答案

尝试使用名称keras-attention:

pip install keras-attention

您可以在pip中搜索像这样的软件包:

you can search pip for packages like this:

pip search attention
keras-attention (1.0.0)                      - Attention Mechanism Implementations for NLP via Keras
.
.
.
(other stuff)

这篇关于在Keras中导入Attention包会产生ModuleNotFoundError:没有名为"attention"的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 14:22