Spaces:
Build error
Build error
Update app.py
Browse files13 unmodified lines1415161718192021222324252627282930316 unmodified lines383940414243444546474825 unmodified lines7475767778798081828313 unmodified linesst.session_state.epoch = 0if "running" not in st.session_state:st.session_state.running = Falseif "loss_history" not in st.session_state:st.session_state.loss_history = []# ================= TRAINING CONTROL PANEL (Top) =================st.markdown("### Training Controls")col1, col2, col3, col4, col5, col6 = st.columns(6)with col1:if st.button("↩️ Reset"):st.session_state.epoch = 0st.session_state.running = Falsest.session_state.loss_history = []with col2:if st.button("▶️ Train"):st.session_state.running = True6 unmodified linesproblem_type = st.selectbox("Problem Type", ["Classification", "Regression"])with col6:learning_rate = st.selectbox("Learning Rate", [0.0001, 0.001, 0.01, 0.03, 0.1])if st.session_state.running:time.sleep(1)st.session_state.epoch += 1st.session_state.loss_history.append(np.exp(-0.1 * st.session_state.epoch) + np.random.uniform(0, 0.05))# ================= MAIN LAYOUT =================col_features, col_hidden, col_plot = st.columns([2, 2, 3])25 unmodified lines# Loss Plotfig, ax = plt.subplots()ax.plot(range(len(st.session_state.loss_history)), st.session_state.loss_history, marker="o")ax.set_title("Epoch vs. Loss")ax.set_xlabel("Epoch")ax.set_ylabel("Loss")st.pyplot(fig)# ================= DATASET SELECTION (Sidebar) =================13 unmodified lines1415161718192021222324252627282930313233346 unmodified lines414243444546474849505152535425 unmodified lines80818283848586878889909113 unmodified linesst.session_state.epoch = 0if "running" not in st.session_state:st.session_state.running = Falseif "train_loss_history" not in st.session_state:st.session_state.train_loss_history = []if "test_loss_history" not in st.session_state:st.session_state.test_loss_history = []# ================= TRAINING CONTROL PANEL (Top) =================st.markdown("### Training Controls")col1, col2, col3, col4, col5, col6, col7 = st.columns(7)with col1:if st.button("↩️ Reset"):st.session_state.epoch = 0st.session_state.running = Falsest.session_state.train_loss_history = []st.session_state.test_loss_history = []with col2:if st.button("▶️ Train"):st.session_state.running = True6 unmodified linesproblem_type = st.selectbox("Problem Type", ["Classification", "Regression"])with col6:learning_rate = st.selectbox("Learning Rate", [0.0001, 0.001, 0.01, 0.03, 0.1])with col7:num_epochs = st.slider("Epochs", 1, 100, 10)if st.session_state.running:time.sleep(1)st.session_state.epoch += 1st.session_state.train_loss_history.append(np.exp(-0.1 * st.session_state.epoch) + np.random.uniform(0, 0.05))st.session_state.test_loss_history.append(np.exp(-0.1 * st.session_state.epoch) + np.random.uniform(0, 0.05) + 0.02)# ================= MAIN LAYOUT =================col_features, col_hidden, col_plot = st.columns([2, 2, 3])25 unmodified lines# Loss Plotfig, ax = plt.subplots()ax.plot(range(len(st.session_state.train_loss_history)), st.session_state.train_loss_history, marker="o", label="Train Loss")ax.plot(range(len(st.session_state.test_loss_history)), st.session_state.test_loss_history, marker="s", label="Test Loss")ax.set_title("Epoch vs. Loss")ax.set_xlabel("Epoch")ax.set_ylabel("Loss")ax.legend()st.pyplot(fig)# ================= DATASET SELECTION (Sidebar) =================
app.py+14-6