如果你需要修改你的后端, 只要将字段 backend 更改为 theano 或 cntk,Keras 将在下次运行 Keras 代码时使用新的配置。...Keras 也可以使用外部后端,这可以通过更改 keras.json 配置文件和 “backend” 设置来执行。...使用抽象 Keras 后端:
如果你希望你编写的 Keras 模块与 Theano (th) 和 TensorFlow (tf) 兼容,则必须通过抽象 Keras 后端 API 来编写它们。...=(3, 4, 5))
var = K.ones(shape=(3, 4, 5))
你需要的大多数张量操作都可以像在 TensorFlow 或 Theano 中那样完成:
b = K.random_uniform_variable...(shape=(3, 4), low=0, high=1) # 均匀分布
c = K.random_normal_variable(shape=(3, 4), mean=0, scale=1) # 高斯分布