Git Product home page Git Product logo

chinese-poem-creater's Introduction

chinese-poem-creater

实践char-rnn

1.获得带torch的docker

地址:https://hub.docker.com/r/kaixhin/torch/

2.安装好,进入docker

apt-get update
apt-get install git 
git clone https://github.com/karpathy/char-rnn.git

ubuntu对中文的支持
locale -a
export LANG="zh_CN.utf8"

//TODO::繁体字问题还未解决

3.

cd char-rnn

将input文件夹的某个文件移到 data/your-floder-name,并改名为input.txt

4.学习

th train.lua -data_dir data/your-floder-name -gpuid -1

结果如下

3294/3300 (epoch 49.909), train_loss = 1.44961959, grad/param norm = 1.9957e-01, time/batch = 0.4320s
3295/3300 (epoch 49.924), train_loss = 1.45700514, grad/param norm = 1.7992e-01, time/batch = 0.4353s
3296/3300 (epoch 49.939), train_loss = 1.44030483, grad/param norm = 1.9692e-01, time/batch = 0.4467s
3297/3300 (epoch 49.955), train_loss = 1.49928484, grad/param norm = 2.1121e-01, time/batch = 0.4377s
3298/3300 (epoch 49.970), train_loss = 1.49634007, grad/param norm = 2.3070e-01, time/batch = 0.4322s
3299/3300 (epoch 49.985), train_loss = 1.45957477, grad/param norm = 2.6381e-01, time/batch = 0.4482s
decayed learning rate by a factor 0.97 to 0.00057368183755432
evaluating loss over split index 2
1/4...
2/4...
3/4...
4/4...
saving checkpoint to cv/lm_lstm_epoch50.00_2.0510.t7
3300/3300 (epoch 50.000), train_loss = 1.46940195, grad/param norm = 2.5143e-01, time/batch = 0.4425s

5.取样

th sample.lua cv/lm_lstm_epoch50.00_2.0510.t7 -gpuid -1 -temperature 0.2

6.调整取样参数

temperature在0~1之间调整,越小越保守,越大越奔放

7.取样效果

    ###公司
    # th sample.lua cv/lm_lstm_epoch50.00_1.0812.t7  -gpuid -1 -temperature 0.2 -primetext 云
    creating an lstm...
    seeding with �云
    --------------------------
    �云江车租车有限公司
    北京华天进口报关全设备有限公司
    深圳市华洁家政服务有限公司
    北京华天进口房地产经纪有限公司
    深圳市博泰物流公司
    广州市宏利房地产经纪有限公司
    天津市鹏运房地产代理有限公司
    北京晨创达实业有限公司
    北京大兴家具有限公司
    深圳市宏山区家具维修服务公司
    北京宏大庆玉房屋维修服务公司
    北京兴达家政服务有限公司
    北京中大地毯有限公司
    天津市明昊服务有限公司
    深圳市华洁环保科技有限公司
    上海家家家政服务有限公司
    大连华易房地产经纪有限公司
    宁波博达家居用品有限公司
    北京华泰家政服务有限公司
    北京华宇博达汽车租赁有限公司
    北京华宇博达有限公司
    天津市易教记设公司
    北京鑫泰家政服务有限公司
    南京华宇博财务咨询有限公司
    北京宏发电子商务有限公司
    大连博安建筑装饰工程有限公司
    北京金龙圣美家政公司
    深圳市天安房屋维修服务有限公司
    北京华宏科技有限公司
    宁波海江南瑞科技有限公司
    北京华洁物流有限公司
    深圳市大姐家政服务有限公司
    北京世纪联家居装饰有限公司
    北京海宁二手家具回收公司
    北京市新华财务咨询有限公司
    广州市宏庆装饰工程有限公司
    深圳市华宇房产经纪有限公司
    天津市星月管道疏通有限公司
    宁波三宇汽车租赁有限公司
    北京智尚文化传媒有限公司
    深圳市新星清洁服务有限公司
    北京宏大庆环保科技有限公司
    上海家家家政服务有限公司
    无锡市家家家电回收公司
    广州市鸿达汽车服务有限公司
    宁波宇昌家政服务有限公司
    北京宏大洋教育咨询有限公司
    广州市宏庆清洁服务有限公司
    北京宏发日盛装饰工程有限公司
    北京华天物流公司
    杭州运输安装公司
    大连运辉物资回收公司
    成都市宏发物流有限公司

    ###李白诗词
    # th sample.lua cv/lm_lstm_epoch50.00_1.9798.t7 -gpuid -1 -temperature 0.5
    creating an lstm...
    missing seed text, using uniform probability over first character
    --------------------------
    ��。
      霜桃李此四,因与天地边。遥舞和阳人,取乐以游迟。
      君门家四海,三可还未太。山发结天剑,飞与松千须。
      赵别夜四道,独送有才情。心子琴高女,吾何天地人。
      征君欲没水,清光不可双。君在望咸尘,日忆成梧波。
      晨无独子水,绿花何所欢。君学歌天飞,未然不情迟。
      春风吹清洞,松入闻姑新。我言南成月,入入尚与心。
      初君见安子,白颦西谢宣。举呼吹陵来,天我几几时天。
      人心谢家家,猁高惭六吆。一朝远宫客,无以悲清鸣。
      北流沧海云,幽有难相思。天地千里天,年岁惜安剑。
      君不可我意,出此出楼草。闲将白鹦醉,天心有所怕。
      挂明未天地,心端不可通。日花星连天,无以无奔归。
      秋梦落日日,长啸送入中。大桑落日族,美人安心忧。
    月时纬十别
      张送借长年,君去散素霞。长松已山月,君与四风风。
      佳春五月坐,无以枝荣贵。水君千里天,千金缄绝枝。
      昨日结欲栂,清海空天上。江天秋流水,时上秀田流。
      三千卧玉剑,黄麟皆岭齐。天上有天风,梨君入归门。
      可心入青镜,江晖缹太水。长常凌不见,孤剑有相发。
      三千将何时,天洞金阳中。我来天地崐,明月凋海泉。
      自从天地陇,三千谢旧回。洗水安可可,结交无时失。
      遗来道酒论,大征自盈安。秦人入草千,后家寄成行。
      得我不山巢,拂拫金相绝。未心不见鸟,歌心人飞风。
      将军发沙赠,波歌未应难。世人不能山,心是无三图。
      当应失想月,百夫玉剑闻。开帆海月处,更有海才楚。
      君不见君子,三图平春风。天子去天地,纵辰夜行奱。
      君宫望飞士,风云不得映。君歌出常道,子乘若海情

chinese-poem-creater's People

Contributors

chriswangweb avatar

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.