Closed lili-li-cpu closed 1 year ago
使用对抗训练默认是在compile里面传参就可以用,参考对抗训练,你是说这样不work吗?
是这样的,我使用chinese-bert-wwm-ext然后用对抗训练是起作用的,然后用ernie模型然后进行对抗训练是没起作用的,所以我在想是不是emb_name的名字的问题
是可以通过传入emb_name来修改emb_name的,但是我刚刚试了下,默认的emb_name是可行的,你可以调试看下?
adversarial_train = {'name': 'fgm', 'emb_name': 'word'} # fgm方式,替换默认emb_name
model.compile(loss=nn.CrossEntropyLoss(), optimizer=optim.Adam(model.parameters(), lr=2e-5),
metrics=['accuracy'], adversarial_train=adversarial_train)
好的,好的,非常感谢,我试试
------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2022年9月22日(星期四) 上午10:13 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [Tongjilibo/bert4torch] 您好,波哥,我想在关系抽取模型上添加对抗训练方法,预训练模型使用的是ernie模型,请问需要改预训练模型的embding层嘛 (Issue #37)
是可以通过传入emb_name来修改emb_name的,但是我刚刚试了下,默认的emb_name是可行的,你可以调试看下? adversarial_train = {'name': 'fgm', 'emb_name': 'word'} # fgm方式,替换默认emb_name model.compile(loss=nn.CrossEntropyLoss(), optimizer=optim.Adam(model.parameters(), lr=2e-5), metrics=['accuracy'], adversarial_train=adversarial_train)
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>
对了,这里加入了'emb_name': 'word'这个信息,fgm函数下哪里还需要改正不
应该不需要,我刚刚debug,默认emb_name可以进attack和restore中循环的,你也可以看下
好的好的,谢谢
------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2022年9月22日(星期四) 上午10:34 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [Tongjilibo/bert4torch] 您好,波哥,我想在关系抽取模型上添加对抗训练方法,预训练模型使用的是ernie模型,请问需要改预训练模型的embding层嘛 (Issue #37)
应该不需要,我刚刚debug,默认emb_name可以进attack和restore中循环的,你也可以看下
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>
测试好可以反馈下哈,如果代码有问题我跟进一下
好的好的
您好,波哥,我想在关系抽取模型上添加对抗训练方法,预训练模型使用的是ernie模型,请问需要改预训练模型的embding层嘛,因为我换了预训练模型后使用对抗训练没有效果