pytorch_classification icon indicating copy to clipboard operation
pytorch_classification copied to clipboard

ValueError: optimizer got an empty parameter list

Open Romitavia opened this issue 4 years ago • 8 comments

运行train.py的时候报错ValueError: optimizer got an empty parameter list,报错位置optimizer = optim.Adam(filter(lambda p: p.requires_grad, model.parameters()), lr=cfg.LR)这个是什么问题呀

Romitavia avatar Feb 08 '21 01:02 Romitavia

我也是报的这个错误,解决了吗?

Aruen24 avatar Mar 05 '21 15:03 Aruen24

你可以查一下看是不是init的那个双下划线是不是存在,然后看一下label的问题,这个代码的问题在你的label只能是int型,你用string型无法递到GPU里,需要写一个转换

------------------ 原始邮件 ------------------ 发件人: "lxztju/pytorch_classification" <[email protected]>; 发送时间: 2021年3月5日(星期五) 晚上11:42 收件人: "lxztju/pytorch_classification"<[email protected]>; 抄送: "645195574"<[email protected]>;"Author"<[email protected]>; 主题: Re: [lxztju/pytorch_classification] ValueError: optimizer got an empty parameter list (#26)

我也是报的这个错误,解决了吗?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

Romitavia avatar Mar 06 '21 03:03 Romitavia

我也是报的这个错误,解决了吗?

兄弟问下你这个问题解决了吗???

kk701710 avatar Apr 01 '21 03:04 kk701710

解决了的 我忘记这个报错是具体在哪一部分了 要不加qq联系

------------------ 原始邮件 ------------------ 发件人: "lxztju/pytorch_classification" @.>; 发送时间: 2021年4月1日(星期四) 中午11:04 @.>; @.@.>; 主题: Re: [lxztju/pytorch_classification] ValueError: optimizer got an empty parameter list (#26)

我也是报的这个错误,解决了吗?

兄弟问下你这个问题解决了吗???

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

Romitavia avatar Apr 01 '21 03:04 Romitavia

解决了的 我忘记这个报错是具体在哪一部分了 要不加qq联系 ------------------ 原始邮件 ------------------ 发件人: "lxztju/pytorch_classification" @.>; 发送时间: 2021年4月1日(星期四) 中午11:04 @.>; @.@.>; 主题: Re: [lxztju/pytorch_classification] ValueError: optimizer got an empty parameter list (#26) 我也是报的这个错误,解决了吗? 兄弟问下你这个问题解决了吗??? — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

我扣扣598369667,加我以下

kk701710 avatar Apr 01 '21 03:04 kk701710

有验证问题

------------------ 原始邮件 ------------------ 发件人: "lxztju/pytorch_classification" @.>; 发送时间: 2021年4月1日(星期四) 中午11:36 @.>; @.@.>; 主题: Re: [lxztju/pytorch_classification] ValueError: optimizer got an empty parameter list (#26)

解决了的 我忘记这个报错是具体在哪一部分了 要不加qq联系 … ------------------ 原始邮件 ------------------ 发件人: "lxztju/pytorch_classification" @.>; 发送时间: 2021年4月1日(星期四) 中午11:04 @.>; @.@.>; 主题: Re: [lxztju/pytorch_classification] ValueError: optimizer got an empty parameter list (#26) 我也是报的这个错误,解决了吗? 兄弟问下你这个问题解决了吗??? — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

我扣扣598369667,加我以下

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

Romitavia avatar Apr 01 '21 03:04 Romitavia

要不你直接加我 就这邮箱的qq号 645195574

------------------ 原始邮件 ------------------ 发件人: "lxztju/pytorch_classification" @.>; 发送时间: 2021年4月1日(星期四) 中午11:36 @.>; @.@.>; 主题: Re: [lxztju/pytorch_classification] ValueError: optimizer got an empty parameter list (#26)

解决了的 我忘记这个报错是具体在哪一部分了 要不加qq联系 … ------------------ 原始邮件 ------------------ 发件人: "lxztju/pytorch_classification" @.>; 发送时间: 2021年4月1日(星期四) 中午11:04 @.>; @.@.>; 主题: Re: [lxztju/pytorch_classification] ValueError: optimizer got an empty parameter list (#26) 我也是报的这个错误,解决了吗? 兄弟问下你这个问题解决了吗??? — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

我扣扣598369667,加我以下

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

Romitavia avatar Apr 01 '21 03:04 Romitavia

#####build the network model
if not cfg.RESUME_EPOCH:
    print('****** Training {} ****** '.format(cfg.model_name))
    print('****** loading the Imagenet pretrained weights ****** ')
    if not cfg.model_name.startswith('efficientnet'):
        model = cfg.MODEL_NAMES[cfg.model_name](num_classes=cfg.NUM_CLASSES)
        # #冻结前边一部分层不训练
        ct = 0
        for child in model.children():
            ct += 1
            # print(child)
            if ct < 8:
                print(child)
                for param in child.parameters():
                    param.requires_grad = False

in train.py file, I change the "param.requires_grad = False" to "param.requires_grad = True", and problem solved

caixh39 avatar Apr 14 '21 09:04 caixh39