【问题标题】:ANN - Low performanceANN - 低性能
【发布时间】:2020-06-19 23:16:57
【问题描述】:

我是神经网络的新手,我刚刚将我的第一个人工神经网络定义如下:

model = Sequential()
model.add(Dense(25,input_dim = 20, activation = 'relu'))
model.add(Dense(50,activation='relu'))
model.add(Dense(10,activation='relu'))
model.add(Dense(20,activation='relu')) 
model.add(Dense(4,activation='softmax'))

因此,它有 4 个隐藏层(第一个作为输入)和输出层。

然后,我使用 Adam 优化器编译模型,学习率为 0.2 和分类交叉熵,因为我正在处理一个多类问题。见下文:

adam = optimizers.Adam(lr = 0.2)
model.compile(loss='categorical_crossentropy', optimizer= adam, metrics=['accuracy'])

在检查模型的性能(准确度和损失)时非常低。见下面的结果:

请看学习率降低到 lr = 0.001 的结果:

请查看以下有关数据集的信息:

    RangeIndex: 2000 entries, 0 to 1999
Data columns (total 21 columns):
battery_power    2000 non-null int64
blue             2000 non-null int64
clock_speed      2000 non-null float64
dual_sim         2000 non-null int64
fc               2000 non-null int64
four_g           2000 non-null int64
int_memory       2000 non-null int64
m_dep            2000 non-null float64
mobile_wt        2000 non-null int64
n_cores          2000 non-null int64
pc               2000 non-null int64
px_height        2000 non-null int64
px_width         2000 non-null int64
ram              2000 non-null int64
sc_h             2000 non-null int64
sc_w             2000 non-null int64
talk_time        2000 non-null int64
three_g          2000 non-null int64
touch_screen     2000 non-null int64
wifi             2000 non-null int64
price_range      2000 non-null int64
dtypes: float64(2), int64(19)

数据集已被规范化,并且对 price_range 属性应用了一种热编码,该属性是包含 4 个标签的属性。

【问题讨论】:

  • 训练数据到底是什么?请展示您的训练集中的示例。它有多少样本?请显示您的整个 keras 代码,而不仅仅是模型部分。您是否使用提前停止?
  • 您好 Mathias,已添加数据集信息。我没有使用提前停止

标签: tensorflow machine-learning keras deep-learning neural-network


【解决方案1】:

乍一看,您描述的模型应该可以很好地解决多类问题。所以就目前而言,问题似乎出在数据集本身 - 以下之一:

  1. 在提供的数据集中没有足够的示例来说明问题的复杂性。还要确保数据在训练和测试集中都代表了问题 - 尝试为此目的进行 k 折交叉验证。
  2. 嘈杂的数据 - 如果您的数据集允许数据标记错误或属性值错误,则可能会在训练模型时出现问题。

编辑: 正如 H. Lecter 博士在评论中所说 - 问题也可能是由于缺少收敛的局部最小值引起的,有时是由较大的学习率值引起的。您可以尝试降低学习率值以解决它并收敛。 在每一层中尝试不同数量的层和节点也会有所帮助。 这些是像您这样的案例的常见解决方案,但如果这些不是根本原因 - 您能否提供有关该问题的更多信息?

【讨论】:

  • 也尝试将学习率从 0.2 降低到 0.01、0.001、0.0001。见arxiv.org/pdf/1206.5533.pdf
  • 嗨,我用新的学习率修改了帖子。任何想法为什么会这样?您是否看到模型中有任何可能出错的参数?
猜你喜欢
  • 2015-02-18
  • 2011-06-15
  • 2020-06-02
  • 2011-11-03
  • 2019-08-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多