All Projects → adepierre → caffe-char-rnn

adepierre / caffe-char-rnn

Licence: other
Multi-layer Recurrent Neural Networks (with LSTM) for character-level language models in Caffe

Programming Languages

C++
36643 projects - #6 most used programming language
Batchfile
5799 projects
CMake
9771 projects

Projects that are alternatives of or similar to caffe-char-rnn

triplet
Re-implementation of tripletloss function in FaceNet
Stars: ✭ 94 (+276%)
Mutual labels:  caffe
Mxnet2Caffe-Tensor-RT-SEnet
Mxnet2Caffe_Tensor RT
Stars: ✭ 18 (-28%)
Mutual labels:  caffe
GuidedNet
Caffe implementation for "Guided Optical Flow Learning"
Stars: ✭ 28 (+12%)
Mutual labels:  caffe
Scale-Adaptive-Network
Semantic Image Segmentation by Scale-Adaptive Networks (TIP 2019)
Stars: ✭ 42 (+68%)
Mutual labels:  caffe
caffe-static
在caffe应用到工程实现时,为了方便系统安装,需要尽可能减少软件的依赖库。 本项目以bash shell/PowerShell脚本实现将caffe依赖的所有第三方库与caffe静态编译一起,以满足全静态编译的要求。 通过本项目提供的脚本生成的caffe编译环境不需要在系统安装任何第三方库和软件,就可以自动完成caffe项目静态编译. 目前在centos6.5/ubuntu16/win7/win10上测试通过,windows上VS2013,VS2015,MinGW 5.2.0编译通过
Stars: ✭ 23 (-8%)
Mutual labels:  caffe
MSG-Net
Depth Map Super-Resolution by Deep Multi-Scale Guidance, ECCV 2016
Stars: ✭ 76 (+204%)
Mutual labels:  caffe
Image2LMDB
Convert image folder to lmdb, adapted from Efficient-PyTorch
Stars: ✭ 58 (+132%)
Mutual labels:  caffe
hangul ipsum
한글 버전의 lorem ipsum 생성기
Stars: ✭ 17 (-32%)
Mutual labels:  text-generation
caffe srgan
A Caffe Implementation of SRGAN
Stars: ✭ 59 (+136%)
Mutual labels:  caffe
gap-text2sql
GAP-text2SQL: Learning Contextual Representations for Semantic Parsing with Generation-Augmented Pre-Training
Stars: ✭ 83 (+232%)
Mutual labels:  text-generation
text-wgan
Improved Training of Wasserstein GANs for Text Generation
Stars: ✭ 20 (-20%)
Mutual labels:  text-generation
caffe-simnets
The SimNets Architecture's Implementation in Caffe
Stars: ✭ 13 (-48%)
Mutual labels:  caffe
XNOR-Net
XNOR-Net, CUDNN5 supported version of XNOR-Net-caffe: https://github.com/loswensiana/BWN-XNOR-caffe
Stars: ✭ 30 (+20%)
Mutual labels:  caffe
vgg16 batchnorm
VGG16 architecture with BatchNorm
Stars: ✭ 14 (-44%)
Mutual labels:  caffe
tensorrt-ssd-easy
No description or website provided.
Stars: ✭ 32 (+28%)
Mutual labels:  caffe
porn-description-generator
Generates new porn descriptions based on an edited dataset of xhamster video descriptions uploaded between 2007-2016.
Stars: ✭ 40 (+60%)
Mutual labels:  text-generation
PSPNet-Pytorch
Implemetation of Pyramid Scene Parsing Network in Pytorch
Stars: ✭ 26 (+4%)
Mutual labels:  caffe
MobileNet-SSD-windows
No description or website provided.
Stars: ✭ 91 (+264%)
Mutual labels:  caffe
arcface retinaface mxnet2onnx
arcface and retinaface model convert mxnet to onnx.
Stars: ✭ 53 (+112%)
Mutual labels:  caffe
Xception-caffe
Xception implemented with caffe
Stars: ✭ 45 (+80%)
Mutual labels:  caffe

caffe-char-rnn

This code is an adapation of Karpathy's code based on his blog post. It is a multi-layer Recurrent Neural Network using Caffe for training/sampling from character-level language models. The main component of the network is a LSTM (Long Short-Term Memory) layer.

Requirements

The only requirement for this code is Caffe and all its dependencies. The instruction to get them are on Caffe installation page.

Training with GPU (if you have CUDA installed along with Caffe) is supported and much faster than with CPU.

I have only tested this code on Windows with Visual Studio 2015, but it should also be able to run on Linux and OS X provided that Caffe is correctly installed.

Usage

The project uses CMake as a building tool. Once you have correctly built and compiled the code, you should be abble to launch the program.

Sampling Shakespeare

The folder launch_files contains everything you need to make the model generate some Shakespeare. Just go in this folder and launch test.bat (or the corresponding line if you are not on Windows). The path to the application may also be slightly different if you are not on Windows.

Training a new model

To train a new model, you only need one txt file with all your training samples (similar to the shakespeare.txt file). Then, you just have to launch train.bat with correct parameters. If you change sequence_length or batch_size parameters, you will also have to change them in caffe_char_rnn.prototxt.

Just after the first launch of the program with your new text file, a new vocabulary_XXX.txt file is created. If the size of the vocabulary is different from the previous one, the program will crash. So you need to change it in caffe_char_rnn.prototxt and in train.bat. Once it is done, the program should run.

Sampling with a new model

To generate new characters with a model, you need two files :

  • a vocabulary_XXX.txt file with all the characters in your training set
  • a caffe_char_rnn_iter_XXXXXX.caffemodel file with the trained network

Both of these files are created when you have trained your model. Once you have set these files in the test.bat file and you have set all the parameters according to what you want, you just can launch test.bat to generate the characters.

Parameters

There are several parameters you can set to change the training/sampling.

Training parameters

snapshot: use this with a caffe_char_rnn_iter_XXXX.solverstate file if you want to continue a training session

logfile and log_interval: if logfile is not empty, the loss will be saved every log_interval iteration. Use them to monitor your training and check if your network is not overfitting

textfile: the training dataset

Testing parameters

temperature: the temperature is in range [0,1]. With higher temperature, the model is less conservative, but do more mistakes. If you set the temperature to 0, the model always takes the characters with the highest probability whithout considering the others even if they have very close probabilities.

seed: you can pass here a string that the model will use to initialize it's prediction. If the seed is shorter than sequence_length or if it is empty, random characters are added at the begining

output_file: use this parameter if you want to keep the predicted characters in a file

Results

Here are some samples generated by the network trained on the shakespeare.txt file with the seed "To be, or not to be: that is the question:". Notice that the network has learned the structure of the text and is abble to generate both dialogue and monologue (for this example the temperature was 0.5).

To be, or not to be: that is the question:
My lord of Rome, such as he to the power
And when the sea of the day would tell them here.

KING HENRY V:
Thou canst not see thee to my wife,
That the sea of the world and promise is this
That have of hand, as shown in the earth for me.

BAPTISTA:
I have been a morning better to the other than this
as any thing of my life; that's the state of the company,
To be a barbarous head of sight of this
That she had land a tray to direct and with me.

CASSIO:
A good sing, sir, I would not speak at his lady:
And there is the gods and the man bear him as I have
so long with the house and hold to him a good shape.

ANTONIO:
That is the soul, why should he say the world?

PRINCE HENRY:
I must not wear their way to wear you and the manner of a
company of the prince and the pains of your own account.

SICINIUS:
Why, then, sir, I will do the fault of the day,
I am a daughter to the strong and meet.

PANDARUS:
Pray you, my lord, that she is private through the end
and the trick of such a fool, and the father shall
make before the poor fall to the present man of my man:
And that the love to this hand for this incle,
That we have in my service of the world,
I would have washed and make her to my rest:
But now the strange and good blood say the worst
Is not a good more standing but to thee be plainly
To have it to the summer to the sun,
And will be satisfied to out the way:
The hand-proceeding countrymen are not a fool
Than this hour of the sea of his man

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].