Dataset: MNIST handwritten digits — civic benchmark
Generated: 2025-07-24T18:09:49.833655Z
| Epoch | accuracy | loss | val_accuracy | val_loss |
|---|---|---|---|---|
| 1 | 0.8776 | 0.4346 | 0.9626 | 0.1258 |
| 2 | 0.9641 | 0.1201 | 0.9733 | 0.0896 |
| 3 | 0.9724 | 0.0900 | 0.9783 | 0.0695 |
| 4 | 0.9777 | 0.0733 | 0.9802 | 0.0626 |
| 5 | 0.9809 | 0.0623 | 0.9803 | 0.0548 |
| 6 | 0.9839 | 0.0544 | 0.9842 | 0.0503 |
| 7 | 0.9850 | 0.0500 | 0.9857 | 0.0420 |
| 8 | 0.9863 | 0.0448 | 0.9859 | 0.0442 |
| 9 | 0.9874 | 0.0405 | 0.9865 | 0.0453 |
| 10 | 0.9884 | 0.0372 | 0.9881 | 0.0384 |
Model: "sequential" ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┓ ┃ Layer (type) ┃ Output Shape ┃ Param # ┃ ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━┩ │ conv2d (Conv2D) │ (None, 24, 24, 16) │ 416 │ ├──────────────────────────────────────┼─────────────────────────────┼─────────────────┤ │ max_pooling2d (MaxPooling2D) │ (None, 12, 12, 16) │ 0 │ ├──────────────────────────────────────┼─────────────────────────────┼─────────────────┤ │ conv2d_1 (Conv2D) │ (None, 11, 11, 8) │ 520 │ ├──────────────────────────────────────┼─────────────────────────────┼─────────────────┤ │ max_pooling2d_1 (MaxPooling2D) │ (None, 5, 5, 8) │ 0 │ ├──────────────────────────────────────┼─────────────────────────────┼─────────────────┤ │ flatten (Flatten) │ (None, 200) │ 0 │ ├──────────────────────────────────────┼─────────────────────────────┼─────────────────┤ │ dense (Dense) │ (None, 100) │ 20,100 │ ├──────────────────────────────────────┼─────────────────────────────┼─────────────────┤ │ dense_1 (Dense) │ (None, 10) │ 1,010 │ └──────────────────────────────────────┴─────────────────────────────┴─────────────────┘ Total params: 66,140 (258.36 KB) Trainable params: 22,046 (86.12 KB) Non-trainable params: 0 (0.00 B) Optimizer params: 44,094 (172.25 KB)
# ============================================================
# 📣 EchoReport Lab — Trains CNN and Generates Unified HTML
# Calls echo_report() from report_dual_html module
# ============================================================
print("🔥 EchoLab script started")
import os
import sys
import numpy as np
import tensorflow as tf
from keras.models import Sequential
from keras.layers import Dense, Input, Conv2D, MaxPooling2D, Flatten
from keras.utils import to_categorical
from keras.datasets import mnist
# Unified HTML report generator with TSNE + history
from echo_report.report_dual_html import report_dual_html as echo_report
# ------------------------------------------------------------
# 1. Environment Setup
# ------------------------------------------------------------
print(f"Interpreter: {sys.executable}")
os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0'
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
# ------------------------------------------------------------
# 2. Load and Preprocess MNIST
# ------------------------------------------------------------
(X_train, y_train), (X_test, y_test) = mnist.load_data()
print(f"🧪 Training samples: {X_train.shape[0]}")
print(f"🧪 Test samples: {X_test.shape[0]}")
X_train = X_train.reshape(-1, 28, 28, 1).astype("float32") / 255.0
X_test = X_test.reshape(-1, 28, 28, 1).astype("float32") / 255.0
y_train = to_categorical(y_train)
y_test = to_categorical(y_test)
num_classes = y_test.shape[1]
print(f"✅ Preprocessing complete — {num_classes} classes")
# ------------------------------------------------------------
# 3. Define CNN Model
# ------------------------------------------------------------
def convolutional_model():
model = Sequential([
Input(shape=(28, 28, 1)),
Conv2D(16, (5, 5), activation='relu'),
MaxPooling2D((2, 2)),
Conv2D(8, (2, 2), activation='relu'),
MaxPooling2D((2, 2)),
Flatten(),
Dense(100, activation='relu'),
Dense(num_classes, activation='softmax')
])
model.compile(optimizer='adam',
loss='categorical_crossentropy',
metrics=['accuracy'])
return model
print("📦 Model constructed. Preparing to train...")
model = convolutional_model()
# ------------------------------------------------------------
# 4. Train Model
# ------------------------------------------------------------
history = model.fit(X_train, y_train,
validation_data=(X_test, y_test),
epochs=10,
batch_size=200,
verbose=2)
print("✅ Training finished.")
# ------------------------------------------------------------
# 5. Evaluate Model
# ------------------------------------------------------------
scores = model.evaluate(X_test, y_test, verbose=0)
print(f"📊 Accuracy: {scores[1]*100:.2f}%")
print(f"❌ Error Rate: {100 - scores[1]*100:.2f}%")
# ------------------------------------------------------------
# 6. Generate Report via echo_report()
# ------------------------------------------------------------
echo_report(
model=model,
history=history,
scores=scores,
X_embed=X_test,
y_embed=y_test,
dataset_info="MNIST handwritten digits — civic benchmark",
serial_no=1,
notes=[
"EchoReport Lab — symbolic archive of CNN training",
"Reconstructed package version"
]
)