Spaces:
Runtime error
Runtime error
branin function
Browse files- app.py +23 -0
- requirements.txt +2 -0
app.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import numpy as np
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
def branin(x1, x2):
|
| 6 |
+
y = float(
|
| 7 |
+
(x2 - 5.1 / (4 * np.pi**2) * x1**2 + 5.0 / np.pi * x1 - 6.0) ** 2
|
| 8 |
+
+ 10 * (1 - 1.0 / (8 * np.pi)) * np.cos(x1)
|
| 9 |
+
+ 10
|
| 10 |
+
)
|
| 11 |
+
|
| 12 |
+
return y
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
iface = gr.Interface(
|
| 16 |
+
fn=branin,
|
| 17 |
+
inputs=[
|
| 18 |
+
gr.Number(0.25, label="x1", minimum=0.0, maximum=1.0),
|
| 19 |
+
gr.Number(0.75, label="x2", minimum=0.0, maximum=1.0),
|
| 20 |
+
],
|
| 21 |
+
outputs=gr.Number(label="branin function value"),
|
| 22 |
+
)
|
| 23 |
+
iface.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
numpy
|
| 2 |
+
gradio
|