问题描述
我正在尝试创建一个与值
我有一个似乎可以工作的实现,但它比正常的泄漏 relu 慢了大约 50%。所以我认为一定有更好的方法。
这是一个最小的例子:
##############################################################################
import tensorflow as tf
import tensorflow.keras as ke
import tensorflow.keras.layers as l
##############################################################################
def myRelu(x):
return tf.where(x<0,x*0.1,tf.where(tf.math.logical_and(x>=0,x<=1),x,0.9+x*0.1))
##############################################################################
def build_model_1():
model_input = l.Input(shape=(None,365,15,26,2))
x = l.Dense(1,activation='linear')(model_input)
x = l.Lambda(myRelu)(x)
# x = l.Activation(myRelu)(x) # or this
model = ke.Model(inputs=[model_input],outputs=[x])
model.compile(optimizer='Adam',loss='mean_squared_error')
return model
##############################################################################
我已经在互联网上搜索了几个小时,但我还没有找到简单或明确的解决方案。我知道标准的 tf.keras.layers.ReLU 支持一个 max_value,我可以将其设置为 1,但我试图避免这种情况以避免死 relu 问题。
我希望有人能帮助我或为我指明正确的方向。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)