Samyro

Samyro

what ipsum beast lurches towards Bethlehem to be born?

An automatic poetry organizer built on TensorFlow‘s RNNs.  In Python, using the C bindings built into TensorFlow for speed.

Samyro learns a text style from examples, saving checkpoints, and generating new text segments from those samples. Derived from example code built for PrettyTensor.

“Samyro” was the first pseudonym of Samuel (Samy) Rosenstock, better known by his later pseudonym Tristan Tzara. (tzara was already taken on pypi.)

Installing an appropriate conda environment

You’ll need tensorflow, which is a bit tricky to install into your local machine. For Ubuntu, I’ve found that Anaconda is very helpful.  Once you’ve installed Conda, you will find it easiest to get TensorFlow installed properly there:

$ conda create --name my-project \
  --channel https://conda.anaconda.org/conda-forge \
  tensorflow
$ source activate my-project
(samyro-project)$

Finding samyro on the web

For development or if you just want to look at the code, you may want to look at the links below.

Using samyro learn at the command-line

The example here assumes you’ve downloaded the TimeCube text into a text file at /opt/data/texts/timecube.txt.

(my-project)$ pip install samyro
(my-project)$ mkdir -p checkpoints/timecube
(my-project)$ samyro learn --name timecube \
  --checkpoint_pattern=checkpoints/timecube/checkpoint \
  --epochs=20 \
  --batch_size=8 \
  --batches_per_epoch=60 \
  --eval_per_epoch=50 \
  --shuffle_eval=True \
  --print_every=50 \
  --embedding_size=16 \
  --lstm_dims=64,128 \
  --sample_length=128 \
  --sample_temperature=0.5 \
  /opt/data/texts/timecube.txt

(Note that you can also pass all the arguments (one per line) in a single file in the source distribution like samyro learn @examples/timecube.cli ).

Using samyro write at the command-line

Eventually you may find that it has sufficiently trained — either you’re happy with the samples you’re drawing, or you’re finding that the accuracy reports (once per epoch) are sufficient.  Now you can use samyro write with the same --checkpoint_pattern, --embedding_size, and --lstm_dims arguments.

# Note that 
(samyro-project)$ samyro write --name timecube \
  --checkpoint_pattern=checkpoints/timecube/checkpoint 
  --embedding_size=16 \
  --lstm_dims=64,128 \
  --temperature=0.5 \
  --max_length=128
Z 
word gods and explains a hell brain stupid. 
Educated stupid and and believe
brains to evil math to not 
man or god educated stupid.
(samyro-project)$

“educated stupid” indeed.

samyro write --seed arguments

It can be entertaining to play with the --seed argument to samyro-write and find out how it completes those texts:

$ samyro write @examples/timecube-write.cli --seed "24 hour da"
24 hour days 
within a Singularity 
bastards your is as a single rotation of 
Earth, stupid and religious and the 
with the mental singularit