sherjilozair / char-rnn-tensorflow

Multi-layer Recurrent Neural Networks (LSTM, RNN) for character-level language models in Python using Tensorflow
MIT License
2.64k stars 959 forks source link

Instructions for sampling prior models? #102

Closed ProbonoBonobo closed 7 years ago

ProbonoBonobo commented 7 years ago

I've searched the repository, read the documentation a few times, and tried invoking python sample.py on anything that looked remotely interesting in the data directory. Calling python sample.py works great on the model that's currently in training. How do I call an arbitrary model? Is there some parameter keyword I need to pass along with the filename argument to sample.py? "--sample" seemed like a good bet, but on closer inspection that option doesn't look related.

chars_vocab.pkl                      model.ckpt-1000.index                model.ckpt-3000.meta                 model.ckpt-62000.data-00000-of-00001 model.ckpt-64000.index
checkpoint                           model.ckpt-1000.meta                 model.ckpt-4000.data-00000-of-00001  model.ckpt-62000.index               model.ckpt-64000.meta
config.pkl                           model.ckpt-2000.data-00000-of-00001  model.ckpt-4000.index   

(tensorflow) Nobodys-MacBook-Pro:char-rnn-tensorflow kz$ python sample.py model.ckpt-64149.index
usage: sample.py [-h] [--save_dir SAVE_DIR] [-n N] [--prime PRIME]
                 [--sample SAMPLE]
sample.py: error: unrecognized arguments: model.ckpt-64149.index

sample.py: error: unrecognized arguments: model.ckpt-64149.data-00000-of-00001
(tensorflow) Nobodys-MacBook-Pro:char-rnn-tensorflow kz$ python sample.py -h
usage: sample.py [-h] [--save_dir SAVE_DIR] [-n N] [--prime PRIME]
                 [--sample SAMPLE]

(tensorflow) Nobodys-MacBook-Pro:save kz$ python ../sample.py --sample model.ckpkt-64149.meta
usage: sample.py [-h] [--save_dir SAVE_DIR] [-n N] [--prime PRIME]
                 [--sample SAMPLE]
ProbonoBonobo commented 7 years ago

I think I've figured out the missing detail that helps explain some of my confusion from earlier, I didn't realize the significance of the metadata files being generated in the save_dir. tl;dr: relative to the Torch implementation, there is a nice suite of tools here for visualizing the context of a model's training loss validation, and it is assumed that you are pointing each model to a unique save_dir. You will overwrite previous models if you don't manually override the default save_dir when initializing a new model, so watch out! It also looks like I might have overwritten some data the previous model depended on (char-vocab.pkl) for obtaining the ASCII mappings back to English.

None of this is to say this is a problem with the repository itself, I greatly appreciate the contextual tools and look forward to learning how to use them soon. Truly awesome work 👍