# Wandb does not display train/eval loss except for last one

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fwandb-does-not-display-train-eval-loss-except-for-last-one%2F9170%3E%5C
**Category:** Beginners\
**Created:** [August 12, 2021, 12:51am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fwandb-does-not-display-train-eval-loss-except-for-last-one%2F9170 "2021-08-12T00:51:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![w-nicole](https://avatars.discourse-cdn.com/v4/letter/w/839c29/32.png) [@w-nicole](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fw-nicole)%5C
**Post date:** [August 12, 2021, 12:51am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fwandb-does-not-display-train-eval-loss-except-for-last-one%2F9170%2F1 "2021-08-12T00:51:04Z")

</div>

Hello,

I am having difficulty getting my code to log metrics periodically to wandb, so I can check that I am checkpointing correctly. Specifically, although I am running my model for 10 epochs (with 2 examples per epoch for debugging) and am requesting logging every 2 steps, my wandb output displays only the very last metric for both train and eval, a single dot. The metric corresponds correctly to the output for epoch 10.

Could you please help me find the issue in my code/understanding?

I am adapting the following script to get it to save validation checkpoints periodically:

> <https://github.com/huggingface/transformers/blob/v4.6.1/examples/pytorch/language-modeling/run_mlm.py>

Specifically, the above after parsing my arguments:

```auto
python3 run_mlm.py --model_name_or_path bert-base-uncased --do_train --do_eval --output_dir ./models/development/Alex/with_tags --train_file ./finetune/child/Alex/train.txt --validation_file ./finetune/child/Alex/val.txt --max_train_samples 2 --max_eval_samples 2 --overwrite_output_dir

```

and overwriting the default values in the TrainingArguments as follows in my version of the run\_mlm.py:

```auto
 # Added these lines
    training_args.load_best_model_at_end = True
    training_args.metric_for_best_model = "eval_loss"
    # end added 
    
    # 8/7/21 added
    is_child = model_args.model_name_or_path != 'bert-base-uncased'
    num_epochs = 10 if is_child else 10 # Debug mode only!!!
    # end add
   
    
    # 8/1/21 added line
    training_args.save_total_limit = 1
    strategy = "steps"
    training_args.logging_strategy = strategy
    training_args.evaluation_strategy = strategy
    training_args.save_strategy = strategy
    
    # For the child scripts
    logger.info('run_mlm.py is in debug mode and is requesting epoch = 20 for non-child! Need to revert!')
    
    training_args.save_steps = interval_steps
    training_args.logging_steps = interval_steps
    training_args.eval_steps = interval_steps
    # end added
     
    # For now train for fewer epochs because perplexity difference is not very large.
    training_args.num_train_epochs = num_epochs
    training_args.learning_rate = learning_rate
    # end additions 

```

---

<div class="post-metadata">

**Author:** ![morgan](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/morgan/32/2293_2.png) [@morgan](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fmorgan)%5C
**Post date:** [September 7, 2021, 2:28pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fwandb-does-not-display-train-eval-loss-except-for-last-one%2F9170%2F2 "2021-09-07T14:28:28Z")

</div>

Does wandb work any better with `logging_steps=1` ? Try adding `training_args.report_to = "wandb"` also, as it might be needed in future transformers releases.

Do the logs from huggingface that get printed in the console print as expected or they’re also truncated?

---

<div class="post-metadata">

**Author:** ![mpost](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/mpost/32/3934_2.png) [@mpost](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fmpost)%5C
**Post date:** [March 4, 2022, 7:58am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fwandb-does-not-display-train-eval-loss-except-for-last-one%2F9170%2F3 "2022-03-04T07:58:49Z")

</div>

I had the same issue and found: If you use the `Trainer` you would want to pass in the value `evaluation_strategy = 'steps'`. This adds the additional logging to wandb.
