Quickstart — Startup Name Generator (sng) 0.3 documentation

# Quickstart

    In [1]:

    %load_ext autoreload
    %autoreload 2

    In [2]:

    # While the sng package is not installed, add the package's path
    # (the parent directory) to the library path:

    import os
    import sys
    sys.path.insert(0, os.path.abspath('../../'))

    In [3]:

    import sng

    Using TensorFlow backend.

## Prepare and train the model

Create a Config object to set your own preferences regarding training or simulation:

    In [4]:

    cfg = sng.Config(
        epochs=50
    )
    cfg.to_dict()

    Out[4]:

    {'batch_size': 64,
     'debug': True,
     'epochs': 50,
     'hidden_dim': 50,
     'max_word_len': 12,
     'min_word_len': 4,
     'n_layers': 2,
     'suffix': '',
     'temperature': 1.0,
     'verbose': True}

Choose from one of these builtin wordlists to get started quickly:

    In [5]:

    sng.show_builtin_wordlists()

    Out[5]:

    ['gallic.txt',
     'english.txt',
     'behemoth.txt',
     'lorem-ipsum.txt',
     'greek.txt',
     'black-speech.txt',
     'german.txt',
     'french.txt',
     'latin.txt',
     'pokemon.txt']

We’ll load the latin wordlist and look at a few sample words:

    In [6]:

    latin = sng.load_builtin_wordlist('latin.txt')

    In [7]:

    latin[:5]

    Out[7]:

    ['in', 'nova', 'fert', 'animus', 'mutatas']

Initialize and fit the word generator:

    In [8]:

    gen = sng.Generator(wordlist=latin, config=cfg)

    2973 words

    24 characters, including the \n:
    ['\n', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'x', 'y', 'z']

    First two sample words:
    ['detque\n', 'concordia\n']

    In [9]:

    gen.fit()

    epoch 0 words: Rcqeslrot, Hqvqiie, Ntyfuamiie, Fvgseafueiaa, loss: 1.5849
    epoch 10 words: Uutsque, Duluas, Epeenunt, Omanetas, loss: 1.2277
    epoch 20 words: Eibosque, Iuritas, Xoncut, Omniditus, loss: 1.1217
    epoch 30 words: Lirus, Timone, Lilosidum, Oggo, loss: 1.0706
    epoch 40 words: Unga, Oricuva, Umnaras, Untit, loss: 1.029

    In [10]:

    gen.simulate(n=4)

    Out[10]:

    ['Baleve', 'Remiduitum', 'Urbam', 'Ugnue']

    In [11]:

    gen.config.suffix = ' Software'

    In [12]:

    gen.simulate(n=4)

    Out[12]:

    ['Otimanae Software', 'Repte Software', 'Redeps Software', 'Urque Software']

## Save and load the model for later

    In [14]:

    gen.save('my_model', overwrite=True)

Then:

    In [15]:

    gen2 = sng.Generator.load('my_model')

    2973 words

    24 characters, including the \n:
    ['\n', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'x', 'y', 'z']

    First two sample words:
    ['demittere\n', 'sonanti\n']

    In [16]:

    gen2.simulate(n=4)

    Out[16]:

    ['Redent Software', 'Ulde Software', 'Uxsit Software', 'Ortitum Software']