前言
由於需要在同一個.ipynb中重新載入os.environ設定,以方便切換 tensorflow <–> theano,所以直接在 cell 中使用重啟功能。
在 Jupyter Notbook 的 cell block 中設定 restart。
from IPython.core.display import HTML
HTML("<script>Jupyter.notebook.kernel.restart()</script>")
實際使用
# In[0]
import keras # load tensorflow backend
In[1]
from IPython.core.display import HTML HTML("")
# In[]
import os
os.environ["KERAS_BACKEND"] = "theano"
import keras # load theano backend
```
* * *
Refer
-----
[python - Jupyter: disable restart kernel warning - Stack Overflow](https://stackoverflow.com/questions/37472274/jupyter-disable-restart-kernel-warning/47055462#47055462)
[How to switch Backend with Keras (from TensorFlow to Theano) - Stack Overflow](https://stackoverflow.com/questions/42177658/how-to-switch-backend-with-keras-from-tensorflow-to-theano)