AVH1993 commited on
Commit
386ff90
Β·
1 Parent(s): a2554fd

Create example

Browse files
Files changed (3) hide show
  1. README.md +7 -5
  2. app.py +28 -0
  3. requirements.txt +4 -0
README.md CHANGED
@@ -1,12 +1,14 @@
1
  ---
2
- title: Hartmann6D
3
- emoji: πŸ’»
4
- colorFrom: purple
5
- colorTo: indigo
6
  sdk: gradio
7
- sdk_version: 4.23.0
8
  app_file: app.py
9
  pinned: false
 
 
10
  ---
11
 
12
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: Hartmann-6
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 six-dimensional transfer learning example
12
  ---
13
 
14
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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, x5, x6):
7
+ x_tensor = Tensor((x1, x2, x3, x4, x5, x6))
8
+ hartmann_function = Hartmann(dim=6)
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
+ gr.Number(0.33, label="x5", minimum=0.0, maximum=1.0),
22
+ gr.Number(0.33, label="x6", minimum=0.0, maximum=1.0),
23
+ ],
24
+ outputs=gr.Number(
25
+ hartmann(0.33, 0.33, 0.33, 0.33, 0.33, 0.33), label="Hartmann function value"
26
+ ),
27
+ )
28
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ numpy
2
+ gradio
3
+ botorch
4
+ torch