May 2019
Intermediate to advanced
272 pages
7h 19m
English
The code for sampling the generator is straightforward. First, we load the model, then create a Z vector, get the output from the generator that provides the probability of each , also known as logits, and sample it with the mode of the distribution, that is, by taking the index with the highest probability and converting it into a word by using our token_to_id function:
import numpy as npfrom utils import load_model, sampledef inference(model_path, weights_path): G = load_model(model_path, weights_path) z = np.random.uniform(-1, 1, 1) res = G.inference(z) text = sample(res) print(text)
In the following table, we provide cherry-picked examples that produce sequences of words that overall are grammatically and syntactically ...
Read now
Unlock full access