Skip to content

taishan1994/pytorch_peot_rnn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pytorch_peot_rnn

基于pytorch_rnn的古诗词生成

说明

config.py里面含有训练、测试、预测的参数,更改后运行:

python main.py

预测结果

if config.do_predict:
	result = trainer.generate('丽日照残春')
	print("".join(result))
	result = trainer.gen_acrostic('深度学习')
	print("".join(result))
	
丽日照残春风光摇落时不知花发意不得见春风深山高下有余灵万里无人见钓矶度日茱萸人不得一枝不得不相见学舞一枝花落叶不知何处是君王习书不见金闺后应是君王赐手间

参考

https://github.com/chenyuntc/pytorch-book
其中第九章的古诗词生成,修改了以下地方:
1、重构了代码架构;
2、增加了数据集生成的过程;
3、RNN网络改为batch_first;
4、计算损失时不计算padding部分;

About

基于pytorch_rnn的古诗词生成

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages