lstm = LSTMNetwork()

# apply configuration to lstm config
lstm.configure(config)
# tell the network the function to use for printing status information while training
lstm.get_status = util.get_status_function(data_store, lstm, config["status_frequency"])
# Populate layers
lstm.populate(
    in_size=np.shape(samples[0][0])[0],  # input size of first lstm unit - according to input vector size
    out_size=np.shape(samples[0][0])[0],  # output size of output layer - according to input/output vector size
    memory_sizes=config["memory_sizes"])  # list of lstm unit sizes (memory unit sizes)

# Uncomment to load previously saved network weights and biases from directory
#lstm.load(config["save_dir"])


# train the network
lstm.train(
        sequences=samples,
        iterations=config["iterations"],
        target_loss=config["target_loss"],
        dry_run=False  # weight updates won't be applied if set to True
)

### Generate string by feeding lstm network with it's own output:
# retrieve character from
character = data_store.input_vecid2data[random.randint(0, data_store.length() - 1)]
seed = data_store.encode_input(chr(character))
# get 'freestyle' sample from character of length 100
print(data_store.decode_all_outputs(lstm.freestyle(seed, 100)))