我必须在 keras 中应用以下损失函数:
这是我的代码:
input_shape = self.s_dim[1:]
input_ = Input(shape=input_shape, name='input')
hidden = Dense(self.n_hidden, activation='relu')(input_)
out = Dense(3, activation='sigmoid')(hidden)
model = Model(inputs=input_, outputs=out, name="ar-model")
model.compile(loss='mean_squared_logarithmic_error', optimizer=SGD(lr=self.lr_ar))
return model
损失函数mean_squared_logarithmic_error
适合这里吗?
最佳答案
mean_squared_logarithmic_error 与对数损失不同,这正是您正在寻找的。对数损失与交叉熵相同。您可以使用 binary_crossentropy 或 categorical_crossentropy,具体取决于您的输出。
关于machine-learning - Keras 对数损失函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50097385/