【问题标题】:I have coded for class balancing loss我已经为类平衡损失编码
【发布时间】:2021-10-04 07:18:41
【问题描述】:

其他类平衡损失

            class_weights = 1.0/np.mean(mdlParams['labels_array'][mdlParams['trainInd'],:],axis=0)
            print("Current class weights",class_weights) 
            class_weights = class_weights*mdlParams['extra_fac']
            print("Current class weights with extra",class_weights) 
        elif mdlParams['balance_classes'] == 9:

错误说: class_weights_ = 1.0/np.mean(mdlParams['labels_array'][indices_ham,:8],axis=0) IndexError:数组的索引过多:数组是一维的,但有 2 个被索引

【问题讨论】:

    标签: loss


    【解决方案1】:

    mdlParams 是一维数组,所以调用

    mdlParams['labels_array'][mdlParams['trainInd']
    

    会给你一个错误。

    为了更好地解释,mdlParams 可以说是一个大小为 [10] 的数组

    但您正在尝试读取 mdlParams[10][1] 而没有第二维度来接受 1

    【讨论】:

      猜你喜欢
      • 2018-06-07
      • 1970-01-01
      • 2021-02-17
      • 2016-05-11
      • 2018-03-12
      • 2019-02-09
      • 2021-12-30
      • 2015-01-08
      • 2019-12-25
      相关资源
      最近更新 更多