Git Product home page Git Product logo

numpy_lstm_rnn's Introduction

RNN and LSTM in numpy

I write a cnn network in numpy fully, including forward and backpropagation.
including those layers, Fullconnect, RNNCell, LSTMCell, Embedding, Cross Entropy loss and MSE loss
In training, it use cpu,it can train with Chinse poetry

Train and predict

train in MacBook Pro 2020 Intel

character

rnn English 26 character

python rnn_1layer\train_rnn_1layer.py
python rnn_1layer\predict_rnn_1layer.py

lstm English 26 character

python lstm_1layer\train_lstm_1layer.py
python lstm_1layer\predict_lstm_1layer.py

Poetry

rnn in character

python rnn_3layer_chars\train_rnn_2layerV2_Embedding_highfreq.py
python rnn_3layer_chars\predict_rnn_2layerV2_Embedding_highfreq.py

rnn in hanlp words segmentation

*_dynamic is the dynamic rnn, dynamic input sequence and dynamic output sequence

python rnn_3layer\train_rnn_2layer_Embedding_dynamic.py
python rnn_3layer\predict_rnn_2layer_Embedding_dynamic.py

*_V2_Embedding.py's labels is moving one word by input words, input sequence==output sequence

python rnn_3layer\train_rnn_2layerV2_Embedding.py
python rnn_3layer\predict_rnn_2layerV2_Embedding.py

output sequence = 1

python rnn_3layer\train_rnn_2layer_Embedding.py
python rnn_3layer\predict_rnn_2layer_Embedding.py

lstm in hanlp words segmentation

*_dynamic is the dynamic lstm, dynamic input sequence and dynamic output sequence

python lstm_3layer\train_lstm_2layer_Embedding_dynamic.py
python lstm_3layer\predict_lstm_2layer_Embedding_dynamic.py

*_V2_Embedding.py's labels is moving one word by input words, input sequence==output sequence

python lstm_3layer\train_lstm_2layerV2_Embedding.py
python lstm_3layer\predict_lstm_2layerV2_Embedding.py

output sequence = 1

python lstm_3layer\train_lstm_2layer_Embedding.py
python lstm_3layer\predict_lstm_2layer_Embedding.py

bidirectional lstm

python lstm_3layer\train_bidirectional_lstm_2layerV2_Embedding.py
python lstm_3layer\predict_bidirectional_lstm_2layerV2_Embedding.py

FORSHOW

输入:暮云千山雪
暮云千山雪,
春行复深上。
风无流鸟树,
清客鸟归还。

输入:朝送山僧去
朝送山僧去,
莫君在梦何。
不知山不知,
山中我欲幸。

输入:携杖溪边听
携杖溪边听,
抱我树月知。
故山中常更,
鸟中应上鬓。

输入:楼高秋易寒
楼高秋易寒,
凭谁暮云云,
添我下来衣,
知一别来云,

输入:残星落檐外
残星落檐外,
馀月罢窗来,
水白先成秋,
霞暗未成不,

输入:月在画楼西
月在画楼西,
烛故是愁来。
何转知此山,
花常更花中。

blogs

numpy实现RNN层的前向传播和反向传播-https://zhuanlan.zhihu.com/p/645190373
numpy实现LSTM层的前向传播和反向传播-https://zhuanlan.zhihu.com/p/645261658
numpy实现embedding层的前向传播和反向传播-https://zhuanlan.zhihu.com/p/642997702
全连接层的前向传播和反向传播-https://zhuanlan.zhihu.com/p/642043155
损失函数的前向传播和反向传播-https://zhuanlan.zhihu.com/p/642025009

Reference

https://blog.csdn.net/SHU15121856/article/details/104387209
https://hanlp.hankcs.com/docs/api/hanlp/pretrained/tok.html
https://github.com/hankcs/HanLP
https://github.com/Werneror/Poetry
https://discuss.pytorch.org/t/how-nn-embedding-trained/32533/11
https://zhuanlan.zhihu.com/p/247970862
https://zhuanlan.zhihu.com/p/147685918
https://zhuanlan.zhihu.com/p/28054589
https://zhuanlan.zhihu.com/p/371849556
https://zhuanlan.zhihu.com/p/54868269
https://zhuanlan.zhihu.com/p/488710218
http://colah.github.io/posts/2015-08-Understanding-LSTMs/
https://blog.csdn.net/zhaojc1995/article/details/80572098
https://github.com/wzyonggege/RNN_poetry_generator
https://github.com/stardut/Text-Generate-RNN
https://github.com/youyuge34/Poems_generator_Keras
https://github.com/justdark/pytorch-poetry-gen

numpy_lstm_rnn's People

Contributors

zoujiu1 avatar

Stargazers

 avatar

Watchers

 avatar  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.