<jupyter_start><jupyter_text>Example datapoints<jupyter_code>outputdir = "./threeDotsJacobians/"
rng = np.random.default_rng(0)
for i in range(1,10):
    base_locs = rng.uniform(size=(3,2)) * 0.7 + 0.15
    img = draw_dots_to_image_array(0.08, base_locs)
    cv2.imwrite(outputdir+"Fig2-ExampleThreeDots%d.png" %(i), (img * 255).astype(np.int));

# make image 0 be the one we're actually embedding with
base_locs = np.array([[32/64., 16/64.],[48/64,32/64.],[16/64.,48/64.]])
img = draw_dots_to_image_array(0.08, base_locs)
cv2.imwrite(outputdir+"Fig2-ExampleThreeDots%d.png" %(0), (img * 255).astype(np.int));<jupyter_output><empty_output><jupyter_text>Embed into model<jupyter_code># we use "repeatedSeeds" dataset for consistency and because we're only using a single model
# (so it doesn't matter that the different models used the same dataset random ordering)
combinedOutputs = "threeDotRepeatedSeeds/trainedModels"
device="cuda" if torch.cuda.is_available() else "cpu"
def get_model_and_enc(gammastring, timestamp):
    base_locs = np.array([[32/64., 16/64.],[48/64,32/64.],[16/64.,48/64.]])
    test_data = np.array([[draw_dots_to_image_array(0.08, base_locs)]])
    matching_model_paths = glob.glob(f"../../{combinedOutputs}/defaultConv_lone_beta4_0000_ica{gammastring}_lat10_batch64_lr0_0001_anneal100000/{timestamp}/representation/cache_batch_no300000")
    print("using model %s" % matching_model_paths)
    model_path = matching_model_paths[0]

    model = load_model(model_path,device).double();
    encoding, logvar = model.encode(torch.tensor(test_data).double().to(device));
    return model, encoding<jupyter_output><empty_output><jupyter_text>Find the most active columns and plot them<jupyter_code># contrast adjustment for jacobian
scale = 20
outputdir = "./threeDotsJacobians/"
from pathlib import Path
Path.mkdir(Path(outputdir), exist_ok=True)
# either switch these timestamps to * (to find any matchign run)
# or update to a particular run. These timestamps are associated with the models used in the paper
for gammastring, timestamp in [("0_1000","20210525-080220"),("0_0000","20210525-071950")]:
    print(gammastring)
    print(gammastring)
    print(gammastring)
    print(gammastring)
    model, encoding = get_model_and_enc(gammastring,timestamp)
    jacs = vj.compute_generator_jacobian_analytic(model, encoding, device=device,
                                        im_channels=1)#.detach().cpu().numpy()
    activities = [np.sum(np.square(jac)) for jac in jacs]
    top_jac_inds = np.flip(np.argsort(activities))
    for q, ind in enumerate(top_jac_inds):
        print(jacs[ind].squeeze().shape)
        added_constrast_jac = jacs[ind,0].transpose(1,2,0) * scale + 255/2.
        plt.imshow(added_constrast_jac[:,:,0], vmin=0, vmax=255, cmap="gray");plt.show();plt.close();
        cv2.imwrite(outputdir+"Fig2-JacGamma%sLatent%d.png" %(gammastring,q), added_constrast_jac);<jupyter_output>0_1000
0_1000
0_1000
0_1000
using model ['../../threeDotRepeatedSeeds/trainedModels/defaultConv_lone_beta4_0000_ica0_1000_lat10_batch64_lr0_0001_anneal100000/20210525-080220/representation/cache_batch_no300000']
(64, 64)
{'fraction_non_alphanumeric': 0.1364503816793893, 'fraction_numerical': 0.0737913486005089, 'mean_word_length': 5.431492842535787, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '634941', 'license': 'Apache-2.0', 'n_tokens_mistral': 1301, 'n_tokens_neox': 1142, 'n_words': 200, 'path': 'experimentScripts/visualizations/Figure2-ExampleJacobianValues_ThreeDots.ipynb', 'repo_name': 'travers-rhodes/neurips2021_jlonevae_sanitized', 'size': '3144'}