<jupyter_start><jupyter_text>Function to Parse Accuracies/Loss from a log file<jupyter_code>def to_deci(s):
    return float(s.strip('\n%'))/100

def get_acc_and_loss(fn):
  with open(fn) as f:
    content = f.readlines()
  
  train_acc = [] #every 50
  valid_acc = [] #every 50
  top1 = [] #every 200
  top3 = [] #every 200
  top5 = [] #every 200
  loss = [] #every 50
  
  curr_step = 0
  for line in content:
    l = line.split(' ')
    if "accuracy" in line:
        if "test" in line:
            if "top 3" in line:
                if "Best" in line:
                    continue
                top3.append(to_deci(l[-1]))
            elif "top 5" in line:
                top5.append(to_deci(l[-1]))
            else:
                top1.append(to_deci(l[-1]))
        if "Train" in line:
            train_acc.append(to_deci(l[-1]))
        if "Validation" in line:
            valid_acc.append(to_deci(l[-1]))
    if "entropy" in line:
        loss.append(float(l[-1].strip('\n')))
        
  return train_acc, valid_acc, top1, top3, top5, loss 
train_2, val_2, top1_2, top3_2, top5_2, loss_2 = get_acc_and_loss("/data/10k_aug_outputs/log_10k_aug_preprocessed_lr0.005.txt")
train, val, top1, top3, top5, loss = get_acc_and_loss("/data/10k_aug_outputs/log_10k_aug_preprocessed_lr1e-3_adam.txt")
train_4, val_4, top1_4, top3_4, top5_4, loss_4 = get_acc_and_loss("/data/10k_aug_outputs/log_10k_aug_preprocessed_lr2e-4_adam.txt")
train_3, val_3, _, _, _, loss_3= get_acc_and_loss("/data/10k_aug_outputs/log_10k_aug_preprocessed_lr5e-3_adam.txt")
_, _, _, _, _, loss_5 = get_acc_and_loss("/data/10k_aug_outputs/log_10k_aug_preprocessed_lr8e-4_adam.txt")<jupyter_output><empty_output><jupyter_text>Plot of training vs. validation vs. test accuracies<jupyter_code># plt.figure(figsize=(12, 10))
plt.plot(range(0, 201, 4), top1, label="test")
plt.plot(train, label="train")
plt.plot(val, label="validation")
plt.title('Training vs. Validation vs. Testing accuracies')
plt.xlabel('steps')
plt.ylabel('accuracy')
plt.legend(loc=4)
plt.savefig("figures/train_vs_val_acc.pdf", format='pdf')<jupyter_output><empty_output><jupyter_text>Plot of top1, top3, and top5 Results<jupyter_code>plt.plot(range(0, 201, 4), top1, label="top1")
plt.plot(range(0, 201, 4), top3, label="top3")
plt.plot(range(0, 201, 4), top5, label="top5")
plt.xlabel('steps')
plt.ylabel('accuracy')
plt.legend(loc=4)
plt.savefig("figures/train_vs_val_acc", format='png')<jupyter_output><empty_output><jupyter_text>Plot of different gradient descent methods<jupyter_code>x_len = len(loss_2)
plt.plot(range(x_len), loss_2, label="gradientDescent")
plt.plot(range(x_len), loss_3[:x_len], label="Adam")
plt.xlabel('steps')
plt.ylabel('loss')
plt.legend(loc=1)
plt.savefig("figures/grad_desc_methods", format='png')
plt.plot(loss_3, label="lr=5e-3")
plt.plot(loss, label="lr=1e-3")
plt.plot(loss_5, label="lr=8e-4")
plt.plot(loss_4, label="lr=2e-4")
plt.legend(loc=1)
plt.savefig("figures/learn_rates.pdf", format='pdf')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15930965814802522, 'fraction_numerical': 0.04812479256554929, 'mean_word_length': 4.4601449275362315, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '227329', 'license': 'MIT', 'n_tokens_mistral': 1310, 'n_tokens_neox': 1201, 'n_words': 203, 'path': 'scripts/.ipynb_checkpoints/tags_net_analysis-checkpoint.ipynb', 'repo_name': 'ludazhao/art_history_net', 'size': '3013'}