Skip to content

Instantly share code, notes, and snippets.

@mbklein
Created October 27, 2019 01:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbklein/db6a34e1a8eeb65a1cf62d0d9d2a9746 to your computer and use it in GitHub Desktop.
Save mbklein/db6a34e1a8eeb65a1cf62d0d9d2a9746 to your computer and use it in GitHub Desktop.
My dumb neural net generator
#!/usr/bin/env python3
import pathlib
import sys
from textgenrnn import textgenrnn
stem = sys.argv[1]
count = 100 if len(sys.argv) < 3 else int(sys.argv[2])
temp = [1.0, 0.5, 0.2, 0.2] if len(sys.argv) < 4 else float(sys.argv[3])
hdfile = f"{stem}.hdf5"
if pathlib.Path(hdfile).exists():
t = textgenrnn(hdfile)
else:
t = textgenrnn()
t.train_from_file(f"{stem}.txt", num_epochs=5)
t.save(hdfile)
t.generate_to_file(f"generated_{stem}.txt", n=count, temperature=temp)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment