<jupyter_start><jupyter_text>Plot the loss function output and validation value over epochsAlpha => Kana w/o Attention<jupyter_code>import re
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.colors as mcolors

RE_LOSS = re.compile(r'Epoch \d+ Loss (\d*\.\d*)')
RE_VALIDATION = re.compile(r'Validation Accuracy (\d*\.\d*)')

def get_loss_validation_from_file(file_name):

    losses = []
    validations = []
    
    with open(file_name) as f:
        for line in f:
            line = line.strip()
            match_loss= RE_LOSS.match(line)
            if match_loss:
                losses.append(float(match_loss.group(1)))
            match_valid= RE_VALIDATION.match(line)
            if match_valid:
                validations.append(float(match_valid.group(1)))

    x = np.linspace(0,len(losses)-1,len(losses))
    y_losses = np.array(losses)
    y_validations = np.array(validations)

    return x, y_losses, y_validations  

INPUT_FILE_TEMPLATE = "./training_output/alpha_to_kana_{}_wo_attn/log.txt"
FIG_OUTPUT = 'figs/learning_curve_alpha_to_kana_wo_attn.png'

x_32,  L_32,  V_32  = get_loss_validation_from_file( INPUT_FILE_TEMPLATE.format("32")  )
x_64,  L_64,  V_64  = get_loss_validation_from_file( INPUT_FILE_TEMPLATE.format("64")  )
x_128, L_128, V_128 = get_loss_validation_from_file( INPUT_FILE_TEMPLATE.format("128") )
x_256, L_256, V_256 = get_loss_validation_from_file( INPUT_FILE_TEMPLATE.format("256") )
x_512, L_512, V_512 = get_loss_validation_from_file( INPUT_FILE_TEMPLATE.format("512") )
color_16 = 'tab:blue'
color_32 = 'tab:orange'
color_64 = 'tab:green'
color_128 = 'tab:red'
color_256 = 'tab:purple'
color_512 = 'tab:brown'

fig, ax = plt.subplots(figsize=(10,10))

ax.plot(x_32, L_32, label='loss 32', color=color_32)
ax.plot(x_64, L_64, label='loss 64', color=color_64)
ax.plot(x_128, L_128, label='loss 128', color=color_128)
ax.plot(x_256, L_256, label='loss 256', color=color_256)
ax.plot(x_512, L_512, label='loss 512', color=color_512)

ax.plot(x_32, V_32, '--', label='validation 32', color=color_32)
ax.plot(x_64, V_64, '--', label='validation 64', color=color_64)
ax.plot(x_128, V_128, '--', label='validation 128', color=color_128)
ax.plot(x_256, V_256, '--', label='validation 256', color=color_256)
ax.plot(x_512, V_512, '--', label='validation 512', color=color_512)

ax.set_ylim([0,2.0])
ax.set_xlim([0,100])
ax.set_xlabel('Epochs', fontsize=15)
ax.set_ylabel('Loss / Validation', fontsize=15)
ax.set_title('Learning Curve Alpha to Kana w/o Attention', fontsize=18)
ax.tick_params(axis='both', which='major', labelsize=12)
ax.legend(prop={'size':12})
plt.savefig(FIG_OUTPUT)
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14711359404096835, 'fraction_numerical': 0.07299813780260708, 'mean_word_length': 5.04954954954955, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '182459', 'license': 'Apache-2.0', 'n_tokens_mistral': 1194, 'n_tokens_neox': 1056, 'n_words': 184, 'path': 'plot_loss_validation_alpha_to_kana_wo_attn.ipynb', 'repo_name': 'ShoYamanishi/PersonNamesTransliterator', 'size': '2685'}