小编soo*_*ran的帖子

ValueError:传递给 LatentDirichletAllocation.fit 的数据中的负值

我正在尝试使用 LDA 获取最大化类之间分离的功能子空间,但脚本引发了错误 ValueError: Negative values in data passed to LatentDirichletAllocation.fit

我不是不能用于负数据吗?或者有什么问题?我一直在寻找,但没有找到答案......

python lda

5
推荐指数
1
解决办法
1250
查看次数

枚举数据加载器时出现 KeyError

我正在尝试遍历初始化如下的 pytorch 数据加载器:

trainDL = torch.utils.data.DataLoader(X_train,batch_size=BATCH_SIZE,shuffle=True,**kwargs)

其中 X_train 是一个像这样的熊猫数据框: 我的熊猫 DF

因此,我无法执行以下语句,因为我在“枚举”中收到 KeyError:

for batch_idx, (data, _) in enumerate(trainDL):
    {stuff}
Run Code Online (Sandbox Code Playgroud)

有没有人知道发生了什么?

编辑:

我得到的错误是:

KeyError                                  Traceback (most recent call last)
~/.local/share/virtualenvs/Pipenv-l_wD1rT4/lib/python3.6/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
   2896             try:
-> 2897                 return self._engine.get_loc(key)
   2898             except KeyError:

pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

KeyError: 40592

During handling of the above exception, another exception occurred:

KeyError                                  Traceback (most recent call last)
<ipython-input-63-95142e0748bb> in <module>
----> 1 for batch_idx, (data, _) …
Run Code Online (Sandbox Code Playgroud)

python keyerror pytorch dataloader

1
推荐指数
1
解决办法
4275
查看次数

标签 统计

python ×2

dataloader ×1

keyerror ×1

lda ×1

pytorch ×1