param1 = list(model.layers.parameters())
param2 = list(model.p)
param = param1+param2
"""
ValueError: can't optimize a non-leaf Tensor
"""
检查:
model.p.is_leaf # True
list(model.p.is_leaf) # False
list使is_leaf = False
# 正确写法
param = list(model.layers.parameters())
param.append(model.p)
网友评论