<jupyter_start><jupyter_text>Analysis code for Toy Example<jupyter_code>import torch
import h5py
import numpy as np

from torch import nn
from matplotlib import pyplot as plt
from models import wgan
from torch.utils.data import Dataset
def gen_rand_noise():
    noise = torch.randn(BATCH_SIZE, 128)
    noise = noise.cpu()
    
    return noise<jupyter_output><empty_output><jupyter_text>During the training, we used the normalized value of the pixel, and pList and rList converts the unit of pixel to normalized value to 1.<jupyter_code>def pConverter(x):
    """
    x: an integer from 30 to 96.
    """
    if type(x) is not int:
        raise Exception("Should be integer")
    if x > 96 or x < 30:
        raise Exeption("Pixel should be in 29<x<97.")
        
    return x/128

def rConverter(x):
    """
    x: an integer from 14 to 32.
    """
    
    if type(x) is not int:
        raise Exception("Should be integer")
    if x > 32 or x < 14:
        raise Exeption("Pixel should be in 13<x<33.")
        
    return np.pi*x*x/128/128<jupyter_output><empty_output><jupyter_text>Generating circles with the generator. The toy dataset has three channels with dimension 128 for width and height.<jupyter_code>BATCH_SIZE = 1
CHANNEL = 3
DIM = 128
# Directory to the generator file. *.pt.
aG = torch.load('./output/test/generator.pt', map_location='cpu')
aG.eval()
fixed_noise = gen_rand_noise()<jupyter_output><empty_output><jupyter_text>The order of tuning parameter is following: $c_{1, x}, c_{2, x},c_{1, y},c_{2, y},r_{1},r_{2}$.<jupyter_code>lv = torch.FloatTensor([pConverter(30), pConverter(90), pConverter(30), pConverter(90),
                        rConverter(15), rConverter(20)]).repeat(BATCH_SIZE, 1)
gen_images = aG(gen_rand_noise(), lv).view(BATCH_SIZE, CHANNEL, DIM, DIM)
image = gen_images.detach().numpy()
image = np.argmax(image, axis=1)
plt.imshow(image[0], cmap='nipy_spectral')
plt.axis('off')
plt.clim(-6, 1.5)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12233502538071066, 'fraction_numerical': 0.03553299492385787, 'mean_word_length': 3.9522613065326633, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 19, '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}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '292462', 'license': 'MIT', 'n_tokens_mistral': 739, 'n_tokens_neox': 675, 'n_words': 195, 'path': 'Analysis.ipynb', 'repo_name': 'chomd90/invnet', 'size': '1970'}