Add example
Browse files- README.md +8 -6
- app.py +26 -0
- requirements.txt +4 -0
README.md
CHANGED
|
@@ -1,13 +1,15 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version: 4.
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
-
license:
|
|
|
|
|
|
|
| 11 |
---
|
| 12 |
|
| 13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: Hartmann-4
|
| 3 |
+
emoji: π
|
| 4 |
+
colorFrom: yellow
|
| 5 |
+
colorTo: purple
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 4.21.0
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
+
license: mit
|
| 11 |
+
short_description: Optimize a four-dimensional transfer learning example
|
| 12 |
+
|
| 13 |
---
|
| 14 |
|
| 15 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from botorch.test_functions.synthetic import Hartmann
|
| 3 |
+
from torch import Tensor
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def hartmann(x1, x2, x3, x4):
|
| 7 |
+
x_tensor = Tensor((x1, x2, x3, x4))
|
| 8 |
+
hartmann_function = Hartmann(dim=4)
|
| 9 |
+
y = hartmann_function(x_tensor)
|
| 10 |
+
|
| 11 |
+
return float(y)
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
iface = gr.Interface(
|
| 15 |
+
fn=hartmann,
|
| 16 |
+
inputs=[
|
| 17 |
+
gr.Number(0.33, label="x1", minimum=0.0, maximum=1.0),
|
| 18 |
+
gr.Number(0.33, label="x2", minimum=0.0, maximum=1.0),
|
| 19 |
+
gr.Number(0.33, label="x3", minimum=0.0, maximum=1.0),
|
| 20 |
+
gr.Number(0.33, label="x4", minimum=0.0, maximum=1.0),
|
| 21 |
+
],
|
| 22 |
+
outputs=gr.Number(
|
| 23 |
+
hartmann(0.33, 0.33, 0.33, 0.33), label="Hartmann function value"
|
| 24 |
+
),
|
| 25 |
+
)
|
| 26 |
+
iface.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
numpy
|
| 2 |
+
gradio
|
| 3 |
+
botorch
|
| 4 |
+
torch
|