Giter Site home page Giter Site logo

Comments (2)

AaronJny avatar AaronJny commented on June 28, 2024

严格来说,这个模型并没有对生成格式进行限制,五言、七言都是模型内部决定的,是模型学习到的规律。

甚至,喂给模型的数据集,也不全是绝句(你说的五言和七言应该都是指绝句),之所以生成的结果大多是五言和七言,是因为这样的数据占绝大多数(只有极少数不规律的诗),进而模型生成五言和七言的概率更大(近乎100%)。

所以问题的关键是——数据。如果你只给模型喂五言的数据集,它就会生成五言;如果你只给它喂七言的数据集,它就会生成七言。

如果想要自由生成五言和七言的话,最简单的方法是分别使用五言的数据集和七言的数据集训练两个模型,然后根据参数决定调用哪个模型进行生成。

如果想要把两种生成统一到一个模型也不是不行,我没有做这方面尝试,所以不能给出肯定的方案,只是大概提供一个思路:改变模型的结构,模型的输入不止是词的序列,还要加上一个特征,表示这首诗是五言还是七言。这样,训练好的模型,在你给定这个特征时,即可生成对应格式的文本。

当然,上面主要是从“让模型自主决定”的角度来说的。还有个比较low的方法,就是人工强制干预。即在生成文本的方法内,提前给定特定格式(五言或七言),当碰到应当输出标点符号时,直接按格式进行填充,而不交给模型决定。但这种方法太刻意了,生成的效果和模型的性能割裂开了。

from deeplearningexamples.

390962851 avatar 390962851 commented on June 28, 2024

好的 谢谢^_^

from deeplearningexamples.

Related Issues (11)

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.