英文:
Launching optuna-dashboard in Google Colaboratory
问题
有没有办法在Google Colaboratory中启动optuna-dashboard?
在运行!optuna-dashboard --port 1234 sqlite:////content/drive/MyDrive/optimization.db时,链接无效。
英文:
Is there a way to start optuna-dashboard in Google Colaboratory?
When running !optuna-dashboard --port 1234 sqlite:////content/drive/MyDrive/optimization.db the link is invalid
答案1
得分: 1
Sure, here's the translated content:
optuna-dashboard的作者在这里。
感谢您尝试使用optuna-dashboard。
您需要像下面这样使用`google.colab.output`:
```python
import time
import threading
from optuna_dashboard import wsgi
import optuna
from wsgiref.simple_server import make_server
port = 1234
storage = optuna.storages.RDBStorage("sqlite:////content/drive/MyDrive/optimization.db")
app = wsgi(storage)
httpd = make_server("localhost", port, app)
thread = threading.Thread(target=httpd.serve_forever)
thread.start()
time.sleep(3) # 等待服务器启动
from google.colab import output
output.serve_kernel_port_as_window(port, path='/dashboard/')
将会打印optuna-dashboard的链接。请点击以打开。
请注意,我已经将代码中的HTML实体字符(`"` 和 `'`)翻译为相应的引号。
<details>
<summary>英文:</summary>
Author of optuna-dashboard here.
Thank you for trying to use optuna-dashboard.
You need to use `google.colab.output` like below:
```python
import time
import threading
from optuna_dashboard import wsgi
import optuna
from wsgiref.simple_server import make_server
port = 1234
storage = optuna.storages.RDBStorage("sqlite:////content/drive/MyDrive/optimization.db")
app = wsgi(storage)
httpd = make_server("localhost", port, app)
thread = threading.Thread(target=httpd.serve_forever)
thread.start()
time.sleep(3) # Wait until the server startup
from google.colab import output
output.serve_kernel_port_as_window(port, path='/dashboard/')
The the link to optuna-dashboard will be printed. Please click to open.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论