jfzhang95 / Chinese_Poem_Writer

Chinese Poem Writer Based on TCN

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Chinese poem writer

Introduction

We built a Chinese poem writer based on Temporal Convolutional Networks (TCN). This paper recently indicates that a simple TCN architecture outperforms RNNs across a diverse range of tasks and datasets, while demonstrating longer effective memory. Therefore, we built this Chinese poem writer using TCN.

Dependencies

Python3.x (Tested with 3.5)
PyTorch (Tested with 0.4.0)

Installation

To use this code, please do:

  1. Clone the repo:
    git clone https://github.com/jfzhang95/Chinese_Poem_Writer
    cd Chinese_Poem_Writer
  2. To try the demo code, please run:
    python main.py -m fast

Training

To train this Chinese poems writer, you can run:

python train.py

For more details, please see in train.py.

Usage

We built three poem generator modes:

  1. fast - it can generate each word only based on the last word.
  2. context - it can generate each word based on the entire previous context.
  3. head - it can generate Acrostic based on user inputs.

To change generator mode, you should change "fast" to "context" or "head" behind:

python main.py -m fast

Results

python main.py -m fast

fast

python main.py -m context

context

python main.py -m head

head

Upload generated poem into diyiziti, we can get more artistic result!

4

TODO

  • Basic model and function
  • Write a script to upload generated poem automatically
  • Training our model with more and better data

We thank the authors of pytorch-tcn for making their PyTorch implementation of TCN available!

About

Chinese Poem Writer Based on TCN

License:MIT License


Languages

Language:Python 100.0%