首页 > 解决方案 > Python中的Gelu激活

问题描述

嗨,我正在尝试在神经网络中使用 gelu 激活。我无法在我的图层中调用它。

我认为它的 tf.erf 搞砸了,但我并不精通 tensorflow

def gelu(x):

 cdf = 0.5 * (1.0 + tf.erf(x / tf.sqrt(2.0)))
 return x * K.cdf

get_custom_objects().update({'gelu': Activation(gelu)})

model = Sequential()
model.add(Dense(8, input_dim = len(x[0,:]), activation = 'relu')) 
model.add(Dense(4, activation =  'gelu' ))

标签: python

解决方案


推荐阅读