Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -176,6 +176,7 @@ st.markdown("""
|
|
| 176 |
.block-container {
|
| 177 |
padding-top: 2rem;
|
| 178 |
padding-bottom: 2rem;
|
|
|
|
| 179 |
}
|
| 180 |
</style>
|
| 181 |
""", unsafe_allow_html=True)
|
|
@@ -213,28 +214,19 @@ if 'func' in st.session_state and 'gradient_func' in st.session_state:
|
|
| 213 |
grad_val = st.session_state.gradient_func(x_old)
|
| 214 |
x_new = x_old - learning_rate * grad_val
|
| 215 |
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
else:
|
| 220 |
-
st.session_state.points.append(x_new)
|
| 221 |
-
st.session_state.step += 1
|
| 222 |
-
st.success(f"Iteration {st.session_state.step} Complete!")
|
| 223 |
except Exception as e:
|
| 224 |
st.error(f"Error in iteration: {e}")
|
| 225 |
|
| 226 |
if st.button("Run Iterations"):
|
| 227 |
try:
|
| 228 |
-
tolerance = 0.001
|
| 229 |
for i in range(num_iterations):
|
| 230 |
x_old = float(st.session_state.points[-1])
|
| 231 |
grad_val = st.session_state.gradient_func(x_old)
|
| 232 |
x_new = x_old - learning_rate * grad_val
|
| 233 |
|
| 234 |
-
if abs(x_new - x_old) < tolerance or abs(grad_val) < tolerance:
|
| 235 |
-
st.success(f"Reached Minima early at x = {x_new:.6f} (after {i+1} steps)")
|
| 236 |
-
break
|
| 237 |
-
|
| 238 |
st.session_state.points.append(x_new)
|
| 239 |
st.session_state.step += 1
|
| 240 |
|
|
|
|
| 176 |
.block-container {
|
| 177 |
padding-top: 2rem;
|
| 178 |
padding-bottom: 2rem;
|
| 179 |
+
max-width: 1200px;
|
| 180 |
}
|
| 181 |
</style>
|
| 182 |
""", unsafe_allow_html=True)
|
|
|
|
| 214 |
grad_val = st.session_state.gradient_func(x_old)
|
| 215 |
x_new = x_old - learning_rate * grad_val
|
| 216 |
|
| 217 |
+
st.session_state.points.append(x_new)
|
| 218 |
+
st.session_state.step += 1
|
| 219 |
+
st.success(f"Iteration {st.session_state.step} Complete!")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 220 |
except Exception as e:
|
| 221 |
st.error(f"Error in iteration: {e}")
|
| 222 |
|
| 223 |
if st.button("Run Iterations"):
|
| 224 |
try:
|
|
|
|
| 225 |
for i in range(num_iterations):
|
| 226 |
x_old = float(st.session_state.points[-1])
|
| 227 |
grad_val = st.session_state.gradient_func(x_old)
|
| 228 |
x_new = x_old - learning_rate * grad_val
|
| 229 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 230 |
st.session_state.points.append(x_new)
|
| 231 |
st.session_state.step += 1
|
| 232 |
|