<jupyter_start><jupyter_text>CelebA: scan over the latent dimensionality n  Setup<jupyter_code>%matplotlib inline

import sys
import numpy as np
from matplotlib import pyplot as plt
from itertools import product

import plot_settings as ps<jupyter_output><empty_output><jupyter_text>Load results<jupyter_code>dims = 2**np.arange(3, 10.5, 1, dtype=np.int)


def load(tag, shape, numpyfy=True, result_dir="../data/results"):
    results = []
    
    for dim in dims:
        try:
            this_result = np.load(f"{result_dir}/mf_{dim}_celeba_scan_{dim}_{tag}.npy")
            
            if (not numpyfy) or (shape is None) or np.product(this_result.shape) == np.product(shape):
                results.append(this_result.reshape(shape))
            else:
                results.append(np.nan*np.ones(shape))

        except FileNotFoundError as e:
            print(e)
            if shape is None:
                results.append(None)
            else:
                results.append(np.nan*np.ones(shape))
    
    if numpyfy:
        results = np.array(results, dtype=np.float)
        results = results.reshape([results.shape[0]] + list(shape))
        
    return results


model_test_reco_xs = load("model_x_reco_test", (100, 3, 64, 64))
model_test_reco_errors = load("model_reco_error_test", (100,))
model_gen_fids = load("samples_fid", (1,)).squeeze()
model_gen_fids.shape

max_reco_error = 10000.
model_mean_reco_errors = np.mean(np.clip(model_test_reco_errors, 0., max_reco_error), axis=1)
model_mean_reco_errors.shape<jupyter_output><empty_output><jupyter_text>Plot<jupyter_code>ps.figure_width?
model_mean_reco_errors / 1.e3
fig, ax1 = ps.figure_width(width=0.5*ps.TEXTWIDTH, r_space=True, small_margin=0.02, large_margin=0.12)

plt.plot(dims, model_gen_fids, marker="o", ms=6., c=ps.COLOR_FLMA, ls="--")

plt.xscale("log")
plt.xlabel("Manifold dimension $n$")

plt.ylabel("FID score")
plt.ylim(38,76)
ax1.yaxis.label.set_color(ps.COLOR_FLMA)
ax1.tick_params(axis='y', colors=ps.COLOR_FLMA)


ax2 = ax1.twinx()

plt.plot(dims, model_mean_reco_errors / 1.e3, marker="s", ms=6., c=ps.COLOR_AF, zorder=-5)

plt.ylabel("Mean reconstruction error / $10^3$")
plt.yticks([0., 1., 2., 3., 4])
plt.ylim(0., 4.15)
ax2.yaxis.label.set_color(ps.COLOR_AF)
ax2.tick_params(axis='y', colors=ps.COLOR_AF)

plt.savefig("../figures/celeba_dimension_scan.pdf")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14273754709083297, 'fraction_numerical': 0.02678945165341147, 'mean_word_length': 3.9075975359342916, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '170981', 'license': 'MIT', 'n_tokens_mistral': 962, 'n_tokens_neox': 909, 'n_words': 151, 'path': 'experiments/notebooks/celeba_dimension_scan.ipynb', 'repo_name': 'selflein/manifold-flow', 'size': '2389'}