You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At least for SD2.1, freezing the first n layers (typically, 17) allows it to learn more effectively without catastrophic loss / destructive moves to the base layers.
This helps the model keep concepts that aren't trained in, but are colocated to the tensor subgroups that we're training.
It can be done like so:
first_frozen_layer=0last_frozen_layer=0total_count=0forname, paramintext_encoder.named_parameters():
total_count+=1pieces=name.split(".")
ifpieces[1] !="encoder"andpieces[2] !="layers":
print(f"Ignoring non-encoder layer: {name}")
continueprint(f'Pieces: {pieces}')
current_layer=int(pieces[3])
if (
current_layer>=first_frozen_layerandcurrent_layer<21
): # choose whatever you like to freeze, herelast_frozen_layer=current_layerifhasattr(param, 'requires_grad'):
param.requires_grad=Falseprint(f'Froze layer: {name}')
else:
print(f'Ignoring layer that does not mark as gradient capable: {name}')
The text was updated successfully, but these errors were encountered:
At least for SD2.1, freezing the first n layers (typically, 17) allows it to learn more effectively without catastrophic loss / destructive moves to the base layers.
This helps the model keep concepts that aren't trained in, but are colocated to the tensor subgroups that we're training.
It can be done like so:
The text was updated successfully, but these errors were encountered: