资源算法seq2seq-couplet

seq2seq-couplet

2019-12-19 | |  39 |   0 |   0

This is a project use seq2seq model to play couplets (对对联)。 This project is written with Tensorflow. You can try the demo at https://ai.binwang.me/couplet.

Pre-requirements

  • Tensorflow

  • Python 3.6

  • Dataset

Dataset

You will need some data to run this program, the dataset can be downloaded from this project.

** Note: If you are using your own dataset, you need to add <s> and <s> as the first two line into the vocabs file. **

Usage

Train

Open couplet.py and config the file locations and hyperparams. Then run python couplet.py to train the model. You can see the training loss and bleu score at Tensorbloard. You may need to re-config learning_rate when you find the loss stops descresing. Here is an example of the loss graph:

图片.png

If you stoped the training and want to continue to train it. You can set restore_model to True and use m.train(<epoches>, start=<start>), which start is the steps you've already run.

I've trained the model on a Nivida GTX-1080 GPU for about 4 days.

Run the trained model

Open server.py and config the vocab_file and model_dir params. Then run python server.py will start a web service that can play couplet.

Examples

Here are some examples generated by this model:

上联下联
殷勤怕负三春意潇洒难书一字愁
如此清秋何吝酒这般明月不须钱
天朗气清风和畅云蒸霞蔚日光辉
梦里不知身是客醉时已觉酒为朋
千秋月色君长看一夜风声我自怜


上一篇:seq2seq

下一篇:tensorflow-seq2seq-tutorials

用户评价
全部评价

热门资源

  • seetafaceJNI

    项目介绍 基于中科院seetaface2进行封装的JAVA...

  • spark-corenlp

    This package wraps Stanford CoreNLP annotators ...

  • Keras-ResNeXt

    Keras ResNeXt Implementation of ResNeXt models...

  • capsnet-with-caps...

    CapsNet with capsule-wise convolution Project ...

  • shih-styletransfer

    shih-styletransfer Code from Style Transfer ...