1. 程式人生 > >【Keras】切換後端(Theano和TensorFlow)

【Keras】切換後端(Theano和TensorFlow)

原文見:http://blog.csdn.net/tangwenbo124/article/details/52627774?locationNum=7

實驗室新裝了keras,發現keras預設後端是tensorflow,想換回theano,看了官方文件也沒搞懂,最終搞定,很簡單。 
中文文件的描述:keras中文文件,切換後端

其實就是在C:\Users\75538(75538是我的windos使用者名稱字,找你對應的使用者名稱就行)下有個資料夾.keras,裡面有keras.json檔案,改一下里面的內容就好了,如果沒有資料夾和檔案,手動建立就行。

用theano的話,keras.json寫入

{
    "image_dim_ordering": "th", 
    "epsilon": 1e-07, 
    "floatx": "float32", 
    "backend": "theano"
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

用thesorflow的話,keras.json寫入

{
    "image_dim_ordering": "tf", 
    "epsilon": 1e-07, 
    "floatx": "float32", 
    "backend": "tensorflow"
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

最後儲存就可以了