<jupyter_start><jupyter_text>Only Adaptive learned matrix<jupyter_code>import wandb
api = wandb.Api()

for boolean in [True, False]:
    print("Apt only", str(boolean))
    runs = api.runs("beyersito/Graph-WaveNet", {"config.aptonly": boolean})
    print("Found %i" % len(runs))
    loss = []
    for run in runs:
        if run.state == "finished":
            if "best_valid_loss" in run.summary:
                loss.append(run.summary.best_valid_loss)
    print(min(loss), max(loss))
    
    
for boolean in [True, False]:
    print("Apt only", str(boolean))
    runs = api.runs("beyersito/Graph-WaveNet", "$and": [{"config.aptonly": False}, {"config.addaptadj": True}]})
    print("Found %i" % len(runs))
    loss = []
    for run in runs:
        if run.state == "finished":
            if "best_valid_loss" in run.summary:
                loss.append(run.summary.best_valid_loss)
    print(min(loss), max(loss))
from util import build_model
import torch
import torch.nn.functional as F
import numpy as np
import seaborn as sns

runs = api.runs("beyersito/Graph-WaveNet", {"$and": [{"config.aptonly": False}, {"config.addaptadj": True}]})
# runs = api.runs("beyersito/Graph-WaveNet", {"config.aptonly": False})

class dotdict(dict):
    """dot.notation access to dictionary attributes"""
    __getattr__ = dict.get
    __setattr__ = dict.__setitem__
    __delattr__ = dict.__delitem__
    
    
    
def plot_adapt(engine):

    nodevec1 = engine.model.nodevec1
    nodevec2 = engine.model.nodevec2

    with torch.no_grad():
        adp = F.softmax(F.relu(torch.mm(nodevec1, nodevec2)), dim=1)
    adp = adp.cpu().detach().numpy()

#     print(adp[stationIdToIndex(60, st_df), stationIdToIndex(69, st_df)])
#     ax_labels = [st_df.iloc[i].id for i in range(adp.shape[0])]

#     adp[adp < 0.1] = 0

    n_points = 4
    ind = adp.argsort(axis=None)[-n_points:] ## pick the largest n_points

    topind = np.unravel_index(ind, adp.shape)
    print("topind", list(zip(*topind)))
    values = np.take(adp, ind)
    print("values", values)
#     print([(stations_ids[i], stations_ids[j]) for (i, j) in zip(*topind)])
    return adp
#     print(sns.heatmap(adp, cmap="YlGnBu"))
#                 , xticklabels=ax_labels, yticklabels=ax_labels)
    
adps = []
for run in runs:
    if run.state == "finished":
        args = dotdict(run.config)
        args.device = 'cpu'
        engine, scaler, dataloader, adj_mx = build_model(args)
        save = run.summary.save_location
        run.file(save.rsplit('/', 1)[-1]).download(replace=True)
        try:
            engine.model.load_state_dict(torch.load(save, map_location=torch.device('cpu')))
            adp = plot_adapt(engine)
            adps.append(adp)  
        except:
            pass
from matplotlib import rcParams
rcParams['figure.figsize'] = 12,12

adps = np.asarray(adps)
print(adps.shape)
sns.heatmap(np.mean(adps, axis=0), cmap="YlGnBu")
sns.heatmap(np.std(adps, axis=0), cmap="YlGnBu")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1522248243559719, 'fraction_numerical': 0.008029441284710606, 'mean_word_length': 3.199438202247191, 'pattern_counts': {'":': 11, '<': 6, '<?xml version=': 0, '>': 5, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '486835', 'license': 'MIT', 'n_tokens_mistral': 1108, 'n_tokens_neox': 1082, 'n_words': 214, 'path': 'Results Analysis.ipynb', 'repo_name': 'beyersito/Graph-WaveNet', 'size': '2989'}