diff --git a/.gitignore b/.gitignore index 04d8c76..05b7fbe 100644 --- a/.gitignore +++ b/.gitignore @@ -170,4 +170,6 @@ cython_debug/ .vscode/launch.json /data/books/alice_in_wonderland.txt -/data/books/wizard_of_oz.txt \ No newline at end of file +/data/books/wizard_of_oz.txt +/data/memory/context.json +/data/memory/dreams.json \ No newline at end of file diff --git a/dashboard/dashboard.py b/dashboard/dashboard.py index cb66b6d..547579a 100644 --- a/dashboard/dashboard.py +++ b/dashboard/dashboard.py @@ -2,22 +2,33 @@ from flask import Flask, render_template from model.memory import load_dreams from model.tokenizer import Tokenizer from context.context import load_context -import threading +import os app = Flask(__name__) tokenizer = Tokenizer() +def load_loss_data(): + path = "data/logs/loss.log" + if not os.path.exists(path): + return [] + with open(path, "r", encoding="utf-8") as f: + lines = f.readlines() + return [float(line.strip().split(",")[1]) for line in lines[-50:]] + + @app.route("/") def index(): dreams = load_dreams() top_dreams = dreams[:5] memory_size = len(load_context()) + loss_data = load_loss_data() return render_template("index.html", vocab_size=len(tokenizer.vocab), top_dreams=top_dreams, - memory_size=memory_size) + memory_size=memory_size, + loss_data=loss_data) def run_dashboard(): diff --git a/dashboard/templates/index.html b/dashboard/templates/index.html index 5c0b5aa..e6b323b 100644 --- a/dashboard/templates/index.html +++ b/dashboard/templates/index.html @@ -14,5 +14,11 @@