python - 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' ))
解决方案
推荐阅读
- spring - 如何找到 Redis 中可用的最大连接数以及使用的连接数和免费的连接数?
- php - 如果变量具有特定值,则中断
- visio - 删除 Visio 的以太网形状中的设备连接器
- scala - Spark AnalysisException:路径不存在:Azure Blob 存储
- javascript - 使用 Typescript 在组件中传递参数时出错
- node.js - 如何配置 axios 使用 SSL 证书?
- javascript - setFilesToUpload 操作对我不起作用
- python - 来自两个输入数据集的多输出回归
- javascript - 如何在变量中调用函数?
- java - Spring MVC - 接收列表的 Rest 端点可能会接收单个对象