Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add recipe for fine-tuning Zipformer with adapter #1512

Merged
merged 8 commits into from
Feb 29, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions egs/librispeech/ASR/zipformer_adapter/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,12 @@ def train_one_epoch(
be set to 0.
"""
model.train()
# set modules except adapters to eval mode
for name, m in model.named_modules():
if "adapter" in name:
m.training = True
marcoyang1998 marked this conversation as resolved.
Show resolved Hide resolved
else:
m.training = False

tot_loss = MetricsTracker()

Expand Down Expand Up @@ -1159,12 +1165,6 @@ def save_bad_model(suffix: str = ""):
valid_dl=valid_dl,
world_size=world_size,
)
model.train()
for name, m in model.named_modules():
if "adapter" in name:
m.training = True
else:
m.training = False
logging.info(
f"Validation on {valid_set}: Epoch {params.cur_epoch}, validation: {valid_info}"
)
Expand All @@ -1175,6 +1175,8 @@ def save_bad_model(suffix: str = ""):
valid_info.write_summary(
tb_writer, f"train/{valid_set}_valid_", params.batch_idx_train
)
model.train()
# set modules except adapters to eval mode
for name, m in model.named_modules():
if "adapter" in name:
m.training = True
Expand Down
Loading