首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Fasttext致命Python错误: Docker运行程序测试中的浮点异常

Fasttext致命Python错误: Docker运行程序测试中的浮点异常
EN

Stack Overflow用户
提问于 2020-11-27 20:50:52
回答 1查看 308关注 0票数 2

我正在做一个Fasttext包装在码头跑步者的小测试。这是一个考验:

代码语言:javascript
运行
复制
import fasttext
import tempfile

def test_fasttext_fit_save():
    x_clean = [
            "comment important one",
            "this is other comment",
            "this is other comment",
            "hi this is a comment",
        ]
    temp = tempfile.NamedTemporaryFile("w+", suffix=".txt")
    for com in x_clean:
        temp.write(com)
        temp.write("\n")
    temp.seek(0)

    model = fasttext.train_unsupervised(input=temp.name,
        dim=3,
        epoch=25,
        lr=0.1,
        minCount=1,
        word_ngrams=1,
        bucket=2000000,
    )
    # Test save
    model.save("model.bin")

但是,当在gitlab码头运行器运行时,我会获得:

代码语言:javascript
运行
复制
test_fasttext_fit_save Fatal Python error: Floating point exception

却没有表现出更多。当在我的计算机中进行此测试时,安装了码头,此测试运行良好。

docker文件具有以下内容:

代码语言:javascript
运行
复制
FROM python:3.8

# Upgrade pip
RUN pip install --upgrade pip
RUN pip install --upgrade setuptools wheel

# Install dependencies
RUN pip install fasttext
RUN pip install tempfile
RUN python -c "import fasttext; print(fasttext)"
RUN pip install pytest==6.0.1
RUN pip install pytest-cov==2.10.1
RUN pip install pytest-testmon
...

我的计算机有4GB和1GB的运行程序,但是测试不使用1GB的内存。

EN

Stack Overflow用户

回答已采纳

发布于 2020-12-07 15:23:52

这似乎是一个内存问题,并不是因为您运行的代码实际上需要它,而是因为快速文本(facebook)需要最少的RAM才能正确地运行事物,例如,先知也会出现这种情况。

一个很好的选择是使用gensim的快速文本实现。

票数 0
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65043720

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档