machine-learning - Keras 对数损失函数
问题描述
我必须对 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,具体取决于您的输出。
推荐阅读
- javascript - 数据表和 JSON 计算的问题
- mongodb - 是否可以在 MongoDB 中使用带有 $unwind 运算符的索引?
- r - ancova 不是作为模型打印,而是作为数据框打印
- php - 如何删除端点密钥。如果存在
- java - 如何使用特殊尺寸的热敏打印机打印
- python - SQLAlchemy 自引用 column_property
- python - 使用forloop的结果在python中创建新列表
- r - 如何使用 RMarkdown 和 bookdown 以及 word_document2 导入 .tex 文件
- javascript - 为什么这些功能中的一个比另一个更快,即使它应该是相反的?
- asynchronous - 异步 SQLalchemy:访问急切加载的空关系会触发新的延迟加载,引发错误