keras深度训练7: constant val_acc

Keras: acc and val_acc are constant over 300 epochs, is this normal?

https://stats.stackexchange.com/questions/259418/keras-acc-and-val-acc-are-constant-over-300-epochs-is-this-normal

It seems that your model is not able to make sensible adjustments to your weights. The log loss is decreasing a tiny bit, but then gets stuck. It is just randomly guessing.

I think the root of the problem is that you have sparse positive inputs, positive initial weights and a ReLu activation. I suspect that this combination does not lead to nonzero weight adjustments (however, I do not have any literature background on this)

There are a few things that you could try:

Change the initialization to normal.
Use sigmoid layers everywhere.
Normalize your input, e.g. use StandardScaler from scikit learn.
Increase the initial learning rate and/or choose a different optimizer.
For debugging purposes, decrease the size of the hidden layer or even remove it.

Loss曲线震荡:

分析原因: 1:训练的batch_size太小

  1. 当数据量足够大的时候可以适当的减小batch_size,由于数据量太大,内存不够。但盲目减少会导致无法收敛,batch_size=1时为在线学习。

  2. batch的选择,首先决定的是下降方向,如果数据集比较小,则完全可以采用全数据集的形式。这样做的好处有两点,

    1)全数据集的方向能够更好的代表样本总体,确定其极值所在。

    2)由于不同权重的梯度值差别巨大,因此选取一个全局的学习率很困难。

  3. 增大batchsize的好处有三点:

    1)内存的利用率提高了,大矩阵乘法的并行化效率提高。

    2)跑完一次epoch(全数据集)所需迭代次数减少,对于相同的数据量的处理速度进一步加快。

    3)一定范围内,batchsize越大,其确定的下降方向就越准,引起训练震荡越小。

  4. 盲目增大的坏处:

    1)当数据集太大时,内存撑不住。

    2)batchsize增大到一定的程度,其确定的下降方向已经基本不再变化。

    总结:

    1)batch数太小,而类别又比较多的时候,可能会导致loss函数震荡而不收敛,尤其是在你的网络比较复杂的时候。
    
    2)随着batchsize增大,处理相同的数据量的速度越快。
    
    3)随着batchsize增大,达到相同精度所需要的epoch数量越来越多。
    
    4)由于上述两种因素的矛盾, Batch_Size 增大到某个时候,达到时间上的最优。
    
    5)过大的batchsize的结果是网络很容易收敛到一些不好的局部最优点。同样太小的batch也存在一些问题,比如训练速度很慢,训练不容易收敛等。
    
    6)具体的batch size的选取和训练集的样本数目相关
    

分析原因: 2:数据输入不对

1:数据输入不对包括数据的格式不是网络模型指定的格式,导致训练的时候网络学习的数据不是想要的; 此时会出现loss曲线震荡;

解决办法:检查数据输入格式,数据输入的路径;

分析原因: 3:训练脚本里面的 路径是否配置正确;

1:当脚本中的train.bin的路径或者模型参数的路径配置不对时,会导致训练模型结果不对.

解决办法:检查脚本配置是否正确.

tensorboard错误 :TensorBoard attempted to bind to port 6006, but it was already in use
https://blog.csdn.net/weixin_35654926/article/details/75577515

理解 TensorBoard
https://blog.csdn.net/u010099080/article/details/77426577

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值