GithubHelp home page GithubHelp logo

一点小问题 about transe HOT 4 CLOSED

ShangYuming avatar ShangYuming commented on May 29, 2024
一点小问题

from transe.

Comments (4)

ZichaoHuang avatar ZichaoHuang commented on May 29, 2024

假设有n个generator,我们需要在数据队列最后放入n个None,用来告诉每个generator数据队列中已经没有可以处理的数据了,可以return了。
这里是具体的处理逻辑:https://github.com/ZichaoHuang/TransE/blob/master/src/dataset.py#L80

from transe.

ocsponge avatar ocsponge commented on May 29, 2024

我把raw_batch_queue.put(None)注释掉也能正常运行,不知道和不注释有什么区别

from transe.

ZichaoHuang avatar ZichaoHuang commented on May 29, 2024

@ocsponge 按我的经验,这是“生产者-消费者”模式的一般写法。
队列最后的“None”用于告知消费者进程“当前的生产者队列中已经没有待处理的对象,消费者进程可以退出”。
如果不在生产者队列的最后加入None,消费者进程有可能会一直请求数据,造成资源浪费。

from transe.

ocsponge avatar ocsponge commented on May 29, 2024

懂了,非常感谢~

from transe.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.