如何使用 Theano 创建自定义高斯激活函数以在 Keras 层中使用

How to create a custom Gaussian activation function with Theano to use in a Keras layer

我如何使用 Theano 编写用于 Keras 隐藏层的高斯激活函数。

谢谢。

为了使用keras的抽象并避免对theano的依赖,你需要使用backend module from keras

像这样:

import keras.backend as K

def gaussian(x):
    return K.exp(-K.pow(x,2))

您也可以查看 keras source code 以获取灵感。