方法一
#打印某一层的参数名
for name in model.state_dict():
print(name)
方法二
params = list(model.named_parameters())#get the index by debuging
print(params[2][0])#name
print(params[2][1].data)#data
方法三
for name,param in model.named_parameters():
params[name] = param.detach().cpu().numpy()
print(params['0.weight'])
方法四
#打印每一层的参数名和参数值
#schemem1(recommended)
for name,param in model.named_parameters():
print(name,param)
查找自定义层
for m in (list(model.modules()))[2:]:
if str(m)[0:14] == 'BinarizeLinear':
layer.append(LN)
LN += 1