# Wandb.watch doesnt log anything for me

**URL:** <https://community.wandb.ai/t/wandb-watch-doesnt-log-anything-for-me/3996>\
**Category:** W&B Help\
**Created:** [March 3, 2023, 3:09pm UTC](https://community.wandb.ai/t/wandb-watch-doesnt-log-anything-for-me/3996 "2023-03-03T15:09:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![samlapp](https://avatars.discourse-cdn.com/v4/letter/s/8e7dd6/32.png) [@samlapp](https://community.wandb.ai/u/samlapp)\
**Post date:** [March 3, 2023, 3:09pm UTC](https://community.wandb.ai/t/wandb-watch-doesnt-log-anything-for-me/3996/1 "2023-03-03T15:09:40Z")

</div>

Hi, despite trying many variations and looking through similar issues including #1197 and #2096, I cannot manage to get wandb to log anything about parameters and gradients using wandb.watch(). The documentation has not been helpful. Here’s a sample of what I’m trying to do:

```auto
from torchvision.models import resnet18
import torch

m = resnet18()
m.train()

opt = torch.optim.SGD(m.parameters(),lr=0.1)

loss_fn = torch.nn.BCEWithLogitsLoss()

#track with wandb
wandb_session = wandb.init(
    entity='kitzeslab',
    project="trying wandb in opensoundscape", 
    name='try basic gradient logging',
)

#tried various version of this line, with no criterion argumnet, criterion=loss_fn, etc
# tried both wandb.watch() and wandb_session.watch()
# tried 'all' and 'gradients' for log
wandb_session.watch(models=m,log='all')#,criterion=loss_fn)#,crieterion=torch.nn.BCEWithLogitsLoss)

#train one epoch:

for samples in train_loader:
    #please just trust that this is how I get samples from my dataloader
    samples = collate_samples(samples)
    tensors = samples['samples']
    labels = samples['labels']

    #tried both forward() and __call__ ()
    logits = m. __call__ (tensors) 

    # calculate loss
    loss = loss_fn(logits,labels.float())

    opt.zero_grad()
    # backward pass: calculate the gradients
    loss.backward()
    # update the network using the gradients*lr
    opt.step()
    wandb_session.log({'loss':loss})
    
wandb_session.finish()

```

The loss logs to wandb fine, but I don’t have panels for Parameters or Gradients. Am I doing something wrong?

---

<div class="post-metadata">

**Author:** ![samlapp](https://avatars.discourse-cdn.com/v4/letter/s/8e7dd6/32.png) [@samlapp](https://community.wandb.ai/u/samlapp)\
**Post date:** [March 3, 2023, 3:15pm UTC](https://community.wandb.ai/t/wandb-watch-doesnt-log-anything-for-me/3996/2 "2023-03-03T15:15:17Z")

</div>

The issue was with log\_freq, which defaults to 1000(!) When I specified log\_freq=1, it logged everything.

Counter-intuitively, logging occurs after 1000 steps. I expected that it would log after the first step, then once every 1000 steps after that.

---

<div class="post-metadata">

**Author:** ![raphael-sanandres](https://avatars.discourse-cdn.com/v4/letter/r/7cd45c/32.png) [@raphael-sanandres](https://community.wandb.ai/u/raphael-sanandres)\
**Post date:** [March 6, 2023, 9:15pm UTC](https://community.wandb.ai/t/wandb-watch-doesnt-log-anything-for-me/3996/3 "2023-03-06T21:15:59Z")

</div>

Hello Sam!

Looks like you found the solution for your issue, which is great! For transparency (and for others who may come across this thread), here is our documentation on `watch` saying that our default is `log_freq: int = 1000`. Unfortunately, there is no current way to set the logging to start at the firs step (besides setting `log_freq = 1`). Would you like me to write in a feature request for logging to start at the first step?

---

<div class="post-metadata">

**Author:** ![raphael-sanandres](https://avatars.discourse-cdn.com/v4/letter/r/7cd45c/32.png) [@raphael-sanandres](https://community.wandb.ai/u/raphael-sanandres)\
**Post date:** [March 9, 2023, 11:30pm UTC](https://community.wandb.ai/t/wandb-watch-doesnt-log-anything-for-me/3996/4 "2023-03-09T23:30:43Z")

</div>

Hello! I wanted to follow up with you regarding your support request as I have not heard back from you. Please let me know if we can be of further assistance or if your issue has been resolved.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/wandb/original/1X/366b649231631dbab896843020da0056074ac79d.png) [@system](https://community.wandb.ai/u/system)\
**Post date:** [May 2, 2023, 3:15pm UTC](https://community.wandb.ai/t/wandb-watch-doesnt-log-anything-for-me/3996/5 "2023-05-02T15:15:58Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
