Spaces:
Sleeping
Sleeping
Update final_graph.py
Browse files- final_graph.py +7 -7
final_graph.py
CHANGED
|
@@ -160,7 +160,7 @@ def reset_all(): return (
|
|
| 160 |
with gr.Blocks() as demo:
|
| 161 |
with gr.Tabs():
|
| 162 |
with gr.TabItem("Secant Approximation"):
|
| 163 |
-
gr.HTML("<p><strong>Secant Approximation</strong> <span style='cursor:help' title='Approximates derivative via (f(x+h)-f(x))/h'>
|
| 164 |
with gr.Row():
|
| 165 |
with gr.Column(scale=3):
|
| 166 |
h = gr.Slider(0.001, 1.0, value=0.01, step=0.001, label="h")
|
|
@@ -169,7 +169,7 @@ with gr.Blocks() as demo:
|
|
| 169 |
with gr.Column(scale=1):
|
| 170 |
gr.HTML("<p><strong>Key Question:</strong><br>What does the secant slope approximate?<br><span style='cursor:help' title='The instantaneous rate of change (derivative).'>β</span></p>")
|
| 171 |
with gr.TabItem("Tangent Visualization"):
|
| 172 |
-
gr.HTML("<p><strong>Tangent Visualization</strong> <span style='cursor:help' title='Shows tangent line at x and slope dy/dx'>
|
| 173 |
with gr.Row():
|
| 174 |
with gr.Column(scale=3):
|
| 175 |
x0 = gr.Slider(-1.0, 2.0, value=0.0, step=0.1, label="x")
|
|
@@ -178,7 +178,7 @@ with gr.Blocks() as demo:
|
|
| 178 |
with gr.Column(scale=1):
|
| 179 |
gr.HTML("<p><strong>Key Question:</strong><br>What does the tangent line represent?<br><span style='cursor:help' title='The instantaneous rate of change at the point.'>β</span></p>")
|
| 180 |
with gr.TabItem("Gradient Descent"):
|
| 181 |
-
gr.HTML("<p><strong>Gradient Descent</strong> <span style='cursor:help' title='Shows gradient descent steps on x^2 curve'>
|
| 182 |
with gr.Row():
|
| 183 |
with gr.Column(scale=3):
|
| 184 |
lr = gr.Slider(0.01, 0.5, value=0.1, step=0.01, label="Learning Rate")
|
|
@@ -189,7 +189,7 @@ with gr.Blocks() as demo:
|
|
| 189 |
with gr.Column(scale=1):
|
| 190 |
gr.HTML("<p><strong>Key Question:</strong><br>How does gradient descent move?<br><span style='cursor:help' title='It moves opposite to the gradient towards the function minimum.'>β</span></p>")
|
| 191 |
with gr.TabItem("Chain Rule"):
|
| 192 |
-
gr.HTML("<p><strong>Chain Rule</strong> <span style='cursor:help' title='Visualizes chain rule in computation graph'>
|
| 193 |
with gr.Row():
|
| 194 |
with gr.Column(scale=3):
|
| 195 |
x_s = gr.Slider(0.0, 2.0, value=1.0, step=0.1, label="x")
|
|
@@ -198,7 +198,7 @@ with gr.Blocks() as demo:
|
|
| 198 |
with gr.Column(scale=1):
|
| 199 |
gr.HTML("<p><strong>Key Question:</strong><br>How is dL/dx computed?<br><span style='cursor:help' title='By multiplying partial derivatives along graph: 4Γ3Γ2.'>β</span></p>")
|
| 200 |
with gr.TabItem("Backpropagation"):
|
| 201 |
-
gr.HTML("<p><strong>Backpropagation</strong> <span style='cursor:help' title='Visualizes backprop in a simple DNN'>
|
| 202 |
with gr.Row():
|
| 203 |
with gr.Column(scale=3):
|
| 204 |
xb = gr.Slider(-2.0, 2.0, value=0.5, step=0.1, label="x")
|
|
@@ -214,7 +214,7 @@ with gr.Blocks() as demo:
|
|
| 214 |
demo.load(load_bp, [], [pb, mb])
|
| 215 |
with gr.Row():
|
| 216 |
reset_btn = gr.Button("Reset to default settings")
|
| 217 |
-
gr.HTML("<span style='cursor:help' title='Reset all sliders to defaults.'>
|
| 218 |
reset_btn.click(reset_all, [], [h, x0, lr, init, st, x_s, xb, w1b, w2b, tb])
|
| 219 |
|
| 220 |
-
demo.launch()
|
|
|
|
| 160 |
with gr.Blocks() as demo:
|
| 161 |
with gr.Tabs():
|
| 162 |
with gr.TabItem("Secant Approximation"):
|
| 163 |
+
gr.HTML("<p><strong>Secant Approximation</strong> <span style='cursor:help' title='Approximates derivative via (f(x+h)-f(x))/h'></span></p>")
|
| 164 |
with gr.Row():
|
| 165 |
with gr.Column(scale=3):
|
| 166 |
h = gr.Slider(0.001, 1.0, value=0.01, step=0.001, label="h")
|
|
|
|
| 169 |
with gr.Column(scale=1):
|
| 170 |
gr.HTML("<p><strong>Key Question:</strong><br>What does the secant slope approximate?<br><span style='cursor:help' title='The instantaneous rate of change (derivative).'>β</span></p>")
|
| 171 |
with gr.TabItem("Tangent Visualization"):
|
| 172 |
+
gr.HTML("<p><strong>Tangent Visualization</strong> <span style='cursor:help' title='Shows tangent line at x and slope dy/dx'></span></p>")
|
| 173 |
with gr.Row():
|
| 174 |
with gr.Column(scale=3):
|
| 175 |
x0 = gr.Slider(-1.0, 2.0, value=0.0, step=0.1, label="x")
|
|
|
|
| 178 |
with gr.Column(scale=1):
|
| 179 |
gr.HTML("<p><strong>Key Question:</strong><br>What does the tangent line represent?<br><span style='cursor:help' title='The instantaneous rate of change at the point.'>β</span></p>")
|
| 180 |
with gr.TabItem("Gradient Descent"):
|
| 181 |
+
gr.HTML("<p><strong>Gradient Descent</strong> <span style='cursor:help' title='Shows gradient descent steps on x^2 curve'></span></p>")
|
| 182 |
with gr.Row():
|
| 183 |
with gr.Column(scale=3):
|
| 184 |
lr = gr.Slider(0.01, 0.5, value=0.1, step=0.01, label="Learning Rate")
|
|
|
|
| 189 |
with gr.Column(scale=1):
|
| 190 |
gr.HTML("<p><strong>Key Question:</strong><br>How does gradient descent move?<br><span style='cursor:help' title='It moves opposite to the gradient towards the function minimum.'>β</span></p>")
|
| 191 |
with gr.TabItem("Chain Rule"):
|
| 192 |
+
gr.HTML("<p><strong>Chain Rule</strong> <span style='cursor:help' title='Visualizes chain rule in computation graph'></span></p>")
|
| 193 |
with gr.Row():
|
| 194 |
with gr.Column(scale=3):
|
| 195 |
x_s = gr.Slider(0.0, 2.0, value=1.0, step=0.1, label="x")
|
|
|
|
| 198 |
with gr.Column(scale=1):
|
| 199 |
gr.HTML("<p><strong>Key Question:</strong><br>How is dL/dx computed?<br><span style='cursor:help' title='By multiplying partial derivatives along graph: 4Γ3Γ2.'>β</span></p>")
|
| 200 |
with gr.TabItem("Backpropagation"):
|
| 201 |
+
gr.HTML("<p><strong>Backpropagation</strong> <span style='cursor:help' title='Visualizes backprop in a simple DNN'></span></p>")
|
| 202 |
with gr.Row():
|
| 203 |
with gr.Column(scale=3):
|
| 204 |
xb = gr.Slider(-2.0, 2.0, value=0.5, step=0.1, label="x")
|
|
|
|
| 214 |
demo.load(load_bp, [], [pb, mb])
|
| 215 |
with gr.Row():
|
| 216 |
reset_btn = gr.Button("Reset to default settings")
|
| 217 |
+
gr.HTML("<span style='cursor:help' title='Reset all sliders to defaults.'></span>")
|
| 218 |
reset_btn.click(reset_all, [], [h, x0, lr, init, st, x_s, xb, w1b, w2b, tb])
|
| 219 |
|
| 220 |
+
demo.launch()
|