File size: 552 Bytes
fbe515e
 
 
 
 
 
 
 
 
 
 
663083f
 
fbe515e
 
663083f
fbe515e
 
4629b15
6d15033
fbe515e
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import numpy as np
import base64
import io
import seaborn as sns
import matplotlib
import matplotlib.pyplot as plt
from neural_network.neural_network import NeuralNetwork

matplotlib.use("Agg")

def plot(model: NeuralNetwork) -> None:
    fig, ax = plt.subplots()
    sns.scatterplot(
        x=np.arange(len(model.loss_history)),
        y=model.loss_history,
        ax=ax,
    )
    buf = io.BytesIO() 
    fig.savefig(buf, format="png")
    plt.close(fig)
    plot_data = base64.b64encode(buf.getvalue()).decode("utf-8")
    model.plot = plot_data