<commit_before>#%% Setup.
from matplotlib import pyplot as plt
from scipy.ndimage import zoom

from eva.models.gated_pixelcnn import GatedPixelCNN

from eva.util.mutil import generate

INPUTS = {
    'cifar10' : (32, 32, 3),
    'mnist_rgb' : (28, 28, 3),
    'mnist' : (28, 28, 1)
}

#%% Args.
# Input.
TYPE = 'mnist_rgb'

# Model.
FILTERS = 126
BLOCKS = 1
CLASSES = 10

# Generation.
BATCH = 10
LATENT = None

# Parse model.
INPUT = INPUTS[TYPE]
M = GatedPixelCNN(INPUT, FILTERS, BLOCKS, LATENT)
M.load_weights('model.h5')

#%% Choice (Probabilistic).
batch = generate(M, LATENT, BATCH, deterministic=False)
for pic in batch:
    plt.imshow(pic, interpolation='nearest')
    plt.show()

#%% ArgMax (Deterministic)
batch = generate(M, LATENT, BATCH, deterministic=True)
for pic in batch:
    plt.imshow(pic, interpolation='nearest')
    plt.show()
<commit_msg>Remove uneeded classes field in inference<commit_after>#%% Setup.
from matplotlib import pyplot as plt
from scipy.ndimage import zoom

from eva.models.gated_pixelcnn import GatedPixelCNN

from eva.util.mutil import generate

INPUTS = {
    'cifar10' : (32, 32, 3),
    'mnist_rgb' : (28, 28, 3),
    'mnist' : (28, 28, 1)
}

#%% Args.
# Input.
TYPE = 'mnist_rgb'

# Model.
FILTERS = 126
BLOCKS = 1

# Generation.
BATCH = 10
LATENT = None

# Parse model.
INPUT = INPUTS[TYPE]
M = GatedPixelCNN(INPUT, FILTERS, BLOCKS, LATENT)
M.load_weights('model.h5')

#%% Choice (Probabilistic).
batch = generate(M, LATENT, BATCH, deterministic=False)
for pic in batch:
    plt.imshow(pic, interpolation='nearest')
    plt.show()

#%% ArgMax (Deterministic)
batch = generate(M, LATENT, BATCH, deterministic=True)
for pic in batch:
    plt.imshow(pic, interpolation='nearest')
    plt.show()

{'fraction_non_alphanumeric': 0.13759355210132412, 'fraction_numerical': 0.028785261945883708, 'mean_word_length': 4.2192192192192195, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5643363', 'n_tokens_mistral': 726, 'n_tokens_neox': 655, 'n_words': 177}