In the following for loop I get name's and parameter's of my neural network. Depending on the bias flag I will do some operations on the weight's and bias's using **block**. However, when bias is False, I just do operations on weight's but if bias flag is True, I will do it for both weight's and bias's.
for name, param in model.named_parameters():
if bias = Fasle and 'weight' in name:
**block**
elif bias = True and 'weight' or 'bias' in name:
**block**
Question: since **block** is the same for if and elif, I want to avoid writing it and have it once. Can you help me to figure this out?
Aucun commentaire:
Enregistrer un commentaire