<jupyter_start><jupyter_text>Get Nearest Neighbors of generated images<jupyter_code>nn_sampled_labels = np.concatenate([np.zeros(3), np.ones(3), np.ones(3)+1])
nn_noise = np.random.normal(0, 1, (9, 128))
gen_imgs = 0.5*generator.predict([nn_noise, nn_sampled_labels]) + 0.5
originals_flattened = originals.flatten().reshape(7133, 12288)
from sklearn.neighbors import NearestNeighbors

nn = NearestNeighbors(metric="euclidean").fit(originals_flattened)
gen_imgs_flattened = gen_imgs.flatten().reshape(9, int(368640/30))
_, ind = nn.kneighbors(gen_imgs_flattened, n_neighbors=2)
fig, axs = plt.subplots(9, 3, figsize=(3,9))

k = 0
for imIndex in ind:

    axs[k, 0].imshow(gen_imgs[k])
    axs[k, 0].axis('off')

    j = 1
    for i in imIndex:
        axs[k, j].imshow(originals[i])
        axs[k, j].axis("off")

        j+=1

    k+=1
plt.savefig("nearestneighbors.png", dpi=250)
plt.show()<jupyter_output><empty_output><jupyter_text>Latent Space (Linear) Interpolation<jupyter_code>numInterpolate = 6 # how many images to include in resulting interpolation
start_vector = np.random.normal(0, 1, (1, 128))
stop_vector = np.random.normal(0, 1, (1, 128))

class_vector = np.zeros((1,))
fig, axs = plt.subplots(1, numInterpolate, figsize=(20,5))

cnt = 0
for alpha in np.linspace(0, 1, num=numInterpolate):
    interpolated_vector = start_vector*alpha + stop_vector*(1-alpha)
    gened = 0.5*generator.predict([interpolated_vector, class_vector])[0] + 0.5
    
    # display image
    axs[cnt].imshow(gened)
    axs[cnt].axis("off")
    cnt+=1
plt.savefig("interpolation.png", dpi=400)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15375077495350278, 'fraction_numerical': 0.04773713577185369, 'mean_word_length': 5.231660231660232, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '270506', 'license': 'MIT', 'n_tokens_mistral': 709, 'n_tokens_neox': 652, 'n_words': 114, 'path': '.ipynb_checkpoints/analyzeACGAN-checkpoint.ipynb', 'repo_name': 'alxiang/lesion-GAN', 'size': '1613'}