Paddle LSTM 使用 delattr 删除属性,会生成一个其他的属性

0h4hbjxa  于 2022-10-25  发布在  其他
关注(0)|答案(2)|浏览(206)
class MyLayer(paddle.nn.Layer):
    def __init__(self):
        super(MyLayer, self).__init__()
        self.lstm1 = paddle.nn.LSTM(400, 200)
        self.lstm2 = paddle.nn.LSTM(600, 300)
        delattr(self.lstm1, 'bias_hh_l0')

    def forward(self, input):
        pass

mylayer = MyLayer()
for name, param in mylayer.named_parameters():
    print(name)

结果删除了'bias_hh_l0'属性,但是却生成一个’lstm1.0.cell.bias_hh ‘

lstm1.weight_ih_l0
lstm1.weight_hh_l0
lstm1.bias_ih_l0
lstm1.0.cell.bias_hh
lstm2.weight_ih_l0
lstm2.weight_hh_l0
lstm2.bias_ih_l0
lstm2.bias_hh_l0
bd1hkmkf

bd1hkmkf1#

您好,我们已经收到了您的问题,会安排技术人员尽快解答您的问题,请耐心等待。请您再次检查是否提供了清晰的问题描述、复现代码、环境&版本、报错信息等。同时,您也可以通过查看 官网API文档常见问题历史IssueAI社区 来寻求解答。祝您生活愉快~

Hi! We've received your issue and please be patient to get responded. We will arrange technicians to answer your questions as soon as possible. Please make sure that you have posted enough message to demo your request. You may also check out the APIFAQGithub Issue and AI community to get the answer.Have a nice day!

u91tlkcl

u91tlkcl2#

您好,请问具体需求是什么?为什么需要删除 bias_hh_l0 这个属性?如果强行删除的话,会自动再生成 1 个 bias 属性。

相关问题