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

fix: Fixed wandb issue #4

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Changes from all commits
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
7 changes: 5 additions & 2 deletions tokenlearn/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
try:
import wandb

__WANDB_INSTALLED = True
_WANDB_INSTALLED = True
except ImportError:
_WANDB_INSTALLED = False

Expand Down Expand Up @@ -174,6 +174,9 @@ def train_supervised( # noqa: C901
# Initialize W&B only if wandb is installed and project name is provided
if _WANDB_INSTALLED and project_name:
init_wandb(project_name=project_name, config=config)
wandb_initialized = True
else:
wandb_initialized = False

train_dataloader = train_dataset.to_dataloader(shuffle=True, batch_size=batch_size)

Expand Down Expand Up @@ -254,7 +257,7 @@ def train_supervised( # noqa: C901
current_lr_linear = optimizer.param_groups[1]["lr"]

# Log training loss and learning rates to wandb
if _WANDB_INSTALLED:
if wandb_initialized:
wandb.log(
{
"epoch": epoch,
Expand Down