|
import gradio as gr |
|
from botorch.test_functions.synthetic import Hartmann |
|
from torch import Tensor |
|
|
|
|
|
def hartmann(x1, x2, x3, x4): |
|
x_tensor = Tensor((x1, x2, x3, x4)) |
|
hartmann_function = Hartmann(dim=4) |
|
y = hartmann_function(x_tensor) |
|
|
|
return float(y) |
|
|
|
|
|
iface = gr.Interface( |
|
fn=hartmann, |
|
inputs=[ |
|
gr.Number(0.33, label="x1", minimum=0.0, maximum=1.0), |
|
gr.Number(0.33, label="x2", minimum=0.0, maximum=1.0), |
|
gr.Number(0.33, label="x3", minimum=0.0, maximum=1.0), |
|
gr.Number(0.33, label="x4", minimum=0.0, maximum=1.0), |
|
], |
|
outputs=gr.Number( |
|
hartmann(0.33, 0.33, 0.33, 0.33), label="Hartmann function value" |
|
), |
|
) |
|
iface.launch() |
|
|