Mpavan45 commited on
Commit
e8d0245
Β·
verified Β·
1 Parent(s): 0991f6d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -11
app.py CHANGED
@@ -4,7 +4,7 @@ import plotly.graph_objects as go
4
 
5
  # Title of the app
6
  st.set_page_config(page_title="Interactive Gradient Descent Visualizer", layout="wide")
7
- st.markdown("<h1 style='text-align: center;'> 🌟 Gradient Descent Visualizer</h1>", unsafe_allow_html=True)
8
 
9
  # Custom CSS for background and button color
10
  st.markdown("""
@@ -14,14 +14,16 @@ st.markdown("""
14
  color: white; /* Set text color to white for visibility */
15
  }
16
  .stButton>button {
17
- background-color: #00FFFF; /* Light Cyan color */
18
- color: black;
19
  border-radius: 5px;
20
  padding: 10px 20px;
21
  font-size: 16px;
 
22
  }
23
  .stButton>button:hover {
24
- background-color: #00CED1; /* Darker cyan on hover */
 
25
  }
26
  </style>
27
  """, unsafe_allow_html=True)
@@ -71,14 +73,14 @@ left_col, right_col = st.columns([1, 2]) # 1 for left, 2 for right grid proport
71
 
72
  # Left side content (Function Input and Gradient Descent Parameters)
73
  with left_col:
74
- st.markdown("### Input Your Function")
75
  function_input = st.text_input(
76
- "Enter Function:`Ex:'x**2`,`np.sin(x)`,",
77
  "x**2 + x",
78
  key="math_function",
79
  on_change=reset_session_state
80
  )
81
- st.markdown("### Set Parameters")
82
  initial_point = st.number_input(
83
  "Initial Value of x",
84
  value=4.0,
@@ -95,7 +97,7 @@ with left_col:
95
  key="learning_rate"
96
  ) # Updates session state directly without reset
97
 
98
- st.markdown("### Controls")
99
 
100
  if st.button("πŸ”„ Run Descent Step", type="primary"):
101
  try:
@@ -113,7 +115,7 @@ with left_col:
113
 
114
  # Right side content (Visualization and Iteration Details)
115
  with right_col:
116
- st.markdown("### Gradient Descent Visualization")
117
 
118
  # Display iteration details using buttons
119
  col1, col2, col3 = st.columns(3)
@@ -128,8 +130,8 @@ with right_col:
128
 
129
  try:
130
  selected_x, selected_y = st.session_state.history[st.session_state.current_index]
131
- st.markdown(f"x Value: `{selected_x:.4f}`")
132
- st.markdown(f"f(x): `{selected_y:.4f}`")
133
  except IndexError:
134
  st.warning("No iteration data available. Please run a descent step first.")
135
 
 
4
 
5
  # Title of the app
6
  st.set_page_config(page_title="Interactive Gradient Descent Visualizer", layout="wide")
7
+ st.markdown("<h1 style='text-align: center; color: gold;'> 🌟 Gradient Descent Visualizer</h1>", unsafe_allow_html=True)
8
 
9
  # Custom CSS for background and button color
10
  st.markdown("""
 
14
  color: white; /* Set text color to white for visibility */
15
  }
16
  .stButton>button {
17
+ background-color: gold; /* Gold color for buttons */
18
+ color: black; /* Button text color */
19
  border-radius: 5px;
20
  padding: 10px 20px;
21
  font-size: 16px;
22
+ font-weight: bold;
23
  }
24
  .stButton>button:hover {
25
+ background-color: darkgoldenrod; /* Darker gold on hover */
26
+ color: white; /* White text color on hover */
27
  }
28
  </style>
29
  """, unsafe_allow_html=True)
 
73
 
74
  # Left side content (Function Input and Gradient Descent Parameters)
75
  with left_col:
76
+ st.markdown("<h3 style='color: lightblue;'>Input Your Function</h3>", unsafe_allow_html=True)
77
  function_input = st.text_input(
78
+ "Enter Function:`Ex:'x**2`,`np.sin(x)`",
79
  "x**2 + x",
80
  key="math_function",
81
  on_change=reset_session_state
82
  )
83
+ st.markdown("<h3 style='color: lightgreen;'>Set Parameters</h3>", unsafe_allow_html=True)
84
  initial_point = st.number_input(
85
  "Initial Value of x",
86
  value=4.0,
 
97
  key="learning_rate"
98
  ) # Updates session state directly without reset
99
 
100
+ st.markdown("<h3 style='color: lightcoral;'>Controls</h3>", unsafe_allow_html=True)
101
 
102
  if st.button("πŸ”„ Run Descent Step", type="primary"):
103
  try:
 
115
 
116
  # Right side content (Visualization and Iteration Details)
117
  with right_col:
118
+ st.markdown("<h3 style='color: lightpink;'>Gradient Descent Visualization</h3>", unsafe_allow_html=True)
119
 
120
  # Display iteration details using buttons
121
  col1, col2, col3 = st.columns(3)
 
130
 
131
  try:
132
  selected_x, selected_y = st.session_state.history[st.session_state.current_index]
133
+ st.markdown(f"x Value: `<span style='color: gold;'>{selected_x:.4f}</span>`", unsafe_allow_html=True)
134
+ st.markdown(f"f(x): `<span style='color: gold;'>{selected_y:.4f}</span>`", unsafe_allow_html=True)
135
  except IndexError:
136
  st.warning("No iteration data available. Please run a descent step first.")
137