QQ登录

只需要一步,快速开始

 注册地址  找回密码
查看: 1302|回复: 0
打印 上一主题 下一主题

深度学习实现对对联

[复制链接]
字体大小: 正常 放大

1176

主题

4

听众

2884

积分

该用户从未签到

跳转到指定楼层
1#
发表于 2024-4-19 15:59 |只看该作者 |倒序浏览
|招呼Ta 关注Ta
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

    " }' J7 n. e7 _1 d" K( P, p+ J
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. **
UsageTrain
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:
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 Nvidia 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.
Or build the Docker image with Dockerfile and run it with Docker. Remember to mount the correct model file paths into the Docker container.
Examples
Here are some examples generated by this model:
[td]
  • 上联
    : c2 k/ e: a; Y" d9 g$ ~
  • 下联; w1 p/ c# }2 x9 _/ G
  • 殷勤怕负三春意1 a/ Q1 c# r/ x3 L( Z& h. n
  • 潇洒难书一字愁
    & C$ V  R2 O+ s  b7 I9 Q$ [9 ~; Z- F. f
  • 如此清秋何吝酒
    : R# v9 Z" B" R5 D
  • 这般明月不须钱8 v: a' r+ r. ?% ]( E# ~  x( e
  • 天朗气清风和畅/ a$ @9 T, j  C' M  u6 b
  • 云蒸霞蔚日光辉9 ]% ~! W2 Y7 N% a& \( ]
  • 梦里不知身是客
    ! n+ c% @/ V+ l" ?0 D
  • 醉时已觉酒为朋
    ) ~5 \0 C+ ~3 e9 }- K
  • 千秋月色君长看
    # c, O- o1 c) @1 S8 ]/ V
  • 一夜风声我自怜! Q! Q4 d7 _, k. D4 j4 E1 N* a9 o4 ^

4 S1 {) o( L6 e; M  X, w
4 t  r2 `- t' H! F# ^5 G+ o8 F; F. N, f7 J0 |: U& A

seq2seq-couplet-master.zip

24.48 KB, 下载次数: 0, 下载积分: 体力 -2 点

售价: 2 点体力  [记录]  [购买]

zan
转播转播0 分享淘帖0 分享分享0 收藏收藏0 支持支持0 反对反对0 微信微信
您需要登录后才可以回帖 登录 | 注册地址

qq
收缩
  • 电话咨询

  • 04714969085
fastpost

关于我们| 联系我们| 诚征英才| 对外合作| 产品服务| QQ

手机版|Archiver| |繁體中文 手机客户端  

蒙公网安备 15010502000194号

Powered by Discuz! X2.5   © 2001-2013 数学建模网-数学中国 ( 蒙ICP备14002410号-3 蒙BBS备-0002号 )     论坛法律顾问:王兆丰

GMT+8, 2025-9-22 22:12 , Processed in 0.571384 second(s), 54 queries .

回顶部