项目作者: jan-henkel

项目描述 :
Train a character-level RNN on an input textfile and generate samples. Inspired by Andrej Karpathy's char-rnn.
高级语言: Python
项目地址: git://github.com/jan-henkel/char-rnn-tf.git
创建时间: 2017-05-09T02:57:27Z
项目社区:https://github.com/jan-henkel/char-rnn-tf

开源协议:

下载


char-rnn-tf

Train a character-level RNN on an input textfile and generate samples. Inspired by Andrej Karpathy’s char-rnn.

train.py usage

Call train.py to train the model. Example:

  1. python train.py '/path/to/input.txt'

General usage as described by the help message:

  1. train.py [-h] [--seq-len SEQ_LENGTH] [--stride STRIDE]
  2. [--val-frac VAL_FRAC] [--reprocess] [--type {lstm,rnn,gru}]
  3. [--layers NUM_LAYERS] [--layer-norm]
  4. [--embed-dim EMBEDDING_DIM] [--hidden-dim HIDDEN_DIM]
  5. [--nobias] [--save-dir SAVE_DIR] [--restore-last]
  6. [--clear-model] [--iter ITERATIONS] [--lr LEARNING_RATE]
  7. [--batch-size BATCH_SIZE] [--dropout DROPOUT_KEEP_PROB]
  8. [--print-every PRINT_EVERY]
  9. PATH
  10. positional arguments:
  11. PATH path of the input file
  12. optional arguments:
  13. -h, --help show this help message and exit
  14. input preprocessing:
  15. --seq-len SEQ_LENGTH sequence length
  16. --stride STRIDE stride, defaults to sequence length
  17. --val-frac VAL_FRAC fraction of data used for validation set
  18. --reprocess do preprocessing again (otherwise preprocessing
  19. arguments will be ignored if preprocessed data is
  20. already present)
  21. model parameters:
  22. --type {lstm,rnn,gru}
  23. rnn type
  24. --layers NUM_LAYERS number of layers
  25. --layer-norm use layer normalization. has no effect on anything
  26. other than lstm
  27. --embed-dim EMBEDDING_DIM
  28. embedding dimension. defaults to one-hot encoding if
  29. not specified
  30. --hidden-dim HIDDEN_DIM
  31. rnn hidden layer dimension
  32. --nobias don't learn bias for character scores
  33. model save and restore settings:
  34. --save-dir SAVE_DIR optional, defaults to path derived from input file
  35. --restore-last restore last model rather than best performing model.
  36. does nothing if no previous model is present
  37. --clear-model clear previous model parameters
  38. training parameters:
  39. --iter ITERATIONS number of iterations
  40. --lr LEARNING_RATE learning rate
  41. --batch-size BATCH_SIZE
  42. batch size
  43. --dropout DROPOUT_KEEP_PROB
  44. dropout keep probability
  45. --print-every PRINT_EVERY
  46. number of iterations between progress reports and
  47. checkpoints

sample.py usage

Call sample.py to generate samples from a previously trained model. Example:

  1. python sample.py '/path/to/input.txt' --prime-text 'The meaning of life is '

General usage as described by the help message:

  1. sample.py [-h] [--save-dir SAVE_DIR] [--restore-last]
  2. [--len SAMPLE_LENGTH] [--prime-text PRIME_TEXT]
  3. [--temp TEMPERATURE]
  4. path
  5. positional arguments:
  6. path path of the input file
  7. optional arguments:
  8. -h, --help show this help message and exit
  9. model restore settings:
  10. --save-dir SAVE_DIR model save directory, defaults to path derived from
  11. input file
  12. --restore-last restore last model rather than best performing model
  13. sample settings:
  14. --len SAMPLE_LENGTH sample length
  15. --prime-text PRIME_TEXT
  16. prime the rnn with an input
  17. --temp TEMPERATURE sampling temperature, smaller values lead to more
  18. conservative guesses