我希望在输出层使用线性激活。我目前使用model.add(...)添加层。我知道如何使用其他激活函数(例如sigmoid函数,您可以使用model.add(...,activation = "sigmoid") )。但我的问题是我根本不想要任何激活函数。也就是说,我希望w·x作为来自模型的输出,而不是a(w·x),其中a是激活函数。我该怎么办?难道根本不包括activation工作吗?
发布于 2020-05-25 11:32:40
创建您自己的激活函数,该函数返回所需的内容。
from keras.utils.generic_utils import get_custom_objects
from keras.layers import Activation
def custom_activation(x):
return x
get_custom_objects().update({'custom_activation': Activation(custom_activation)})
model.add(...,activation = "custom_activation")编辑
正如@MarcoCerliani所指出的,没有必要做以上的事情。下面这两条语句都使用linear激活函数。
model.add(...,activation = "linear")
model.add(...)https://stackoverflow.com/questions/62001507
复制相似问题