machine-learning - Keras分类模型

标签 machine-learning neural-network deep-learning keras classification

我需要帮助来构建用于分类的 keras 模型。 我有

输入:167个光谱点

输出 11 类研究物质。

但是在一个数据集中可以是具有多种物质的物质幽灵(例如包含2、3、4类)。 我尝试使用categorical_crossentropy,但它仅适用于非相交类。

KerasDoc :

Note: when using the categorical_crossentropy loss, your targets should be in categorical format (e.g. if you have 10 classes, the target for each sample should be a 10-dimensional vector that is all-zeros expect for a 1 at the index corresponding to the class of the sample). In order to convert integer targets into categorical targets, you can use the Keras utility to_categorical:

我的代码:

model = Sequential()
model.add(Dense(64, input_dim=167))
model.add(Dense(32))
model.add(Dense(11))
model.add(Activation('sigmoid'))
model.compile(loss='categorical_crossentropy', optimizer='rmsprop', metrics=['accuracy'])

我尝试了很多模型,但都没有得到好的结果。

最佳答案

您可能应该很好地使用 sigmoidbinary_crossentropy ( See here )

PS:这不是您的情况,但对于 categorial_crossentropy,您最好使用 softmax 激活。 softmax 输出经过优化以仅最大化一类的东西。

(如果有人想用一个好的或更好的“优化器”来补充这个答案,请随意)。

关于machine-learning - Keras分类模型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44163621/

相关文章:

tensorflow - 在 tensorflow 中实现两个图像之间的交叉熵损失

machine-learning - Scikit learn - 测试集上的 fit_transform

python - pyspark : KeyError when converting a DataFrame column of String type to Double

python - 得分为 ='roc_auc' 的 cross_val_score 和 roc_auc_score 有什么区别?

r - R 中的 h2o.predict 错误

java - 从 deeplearning4j 层提取特征

logging - Tensorflow Estimator 打印损失时使用什么数据集

machine-learning - 为什么自动编码器中的解码器在最后一层使用 sigmoid?

machine-learning - 词向量上的 CNN 会引发输入维度错误

opencv - 如何选择好的SURF特征关键点?