Skip to content

Conversation

CrafterKolyan
Copy link
Contributor

@CrafterKolyan CrafterKolyan commented Mar 23, 2020

Description

Add WandbLogger.

Tested it in some of my experiments. Found out there are a lot of ResourceWarnings in wandb library which were triggered after warning.simplefilter("always") in catalyst/contrib/dl/runner/wandb.py. All of these warnings are also reproducible using catalyst.dl.SupervisedWandbRunner in latest versions of catalyst (>= 20.03). Fixed most of warnings here. Artifacts logging is still not done but basic functionality works.

Type of Change

  • Examples / docs / tutorials / contributors update
  • Bug fix (non-breaking change which fixes an issue)
  • Improvement (non-breaking change which improves an existing feature)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the Code of Conduct document.
  • I have read the Contributing guide.
  • I have checked the code-style using make check-codestyle.
  • I have written tests for all new methods and classes that I created.
  • I have written the docstring in Google format for all the methods and classes that I used.
  • I have checked the docs using make check-docs.
  • I have read I need to click 'Login as guest' to see Teamcity build logs.

@Scitator
Copy link
Member

Thanks for your contribution!

@Scitator Scitator merged commit 725e928 into catalyst-team:master Mar 24, 2020
@pokidyshev
Copy link
Contributor

Adding name param to WandbLogger gives this error:

Traceback (most recent call last):
  File "/home/awecom/anaconda3/envs/workframe/bin/catalyst-dl", line 8, in <module>
    sys.exit(main())
  File "/home/awecom/anaconda3/envs/workframe/lib/python3.6/site-packages/catalyst/dl/__main__.py", line 41, in main
    COMMANDS[args.command].main(args, uargs)
  File "/home/awecom/anaconda3/envs/workframe/lib/python3.6/site-packages/catalyst/dl/scripts/run.py", line 117, in main
    distributed_run(args.distributed, main_worker, args, unknown_args)
  File "/home/awecom/anaconda3/envs/workframe/lib/python3.6/site-packages/catalyst/utils/distributed.py", line 192, in distributed_run
    worker_fn(*args, **kwargs)
  File "/home/awecom/anaconda3/envs/workframe/lib/python3.6/site-packages/catalyst/dl/scripts/run.py", line 112, in main_worker
    runner.run_experiment(experiment)
  File "/home/awecom/anaconda3/envs/workframe/lib/python3.6/site-packages/catalyst/core/runner.py", line 376, in run_experiment
    raise ex
  File "/home/awecom/anaconda3/envs/workframe/lib/python3.6/site-packages/catalyst/core/runner.py", line 361, in run_experiment
    self._run_stage(stage)
  File "/home/awecom/anaconda3/envs/workframe/lib/python3.6/site-packages/catalyst/core/runner.py", line 333, in _run_stage
    self._prepare_for_stage(stage)
  File "/home/awecom/anaconda3/envs/workframe/lib/python3.6/site-packages/catalyst/dl/core/runner.py", line 20, in _prepare_for_stage
    super()._prepare_for_stage(stage=stage)
  File "/home/awecom/anaconda3/envs/workframe/lib/python3.6/site-packages/catalyst/core/runner.py", line 224, in _prepare_for_stage
    callbacks = self._get_callbacks(stage)
  File "/home/awecom/anaconda3/envs/workframe/lib/python3.6/site-packages/catalyst/core/runner.py", line 191, in _get_callbacks
    callbacks = self.experiment.get_callbacks(stage)
  File "/home/awecom/anaconda3/envs/workframe/lib/python3.6/site-packages/catalyst/dl/experiment/config.py", line 526, in get_callbacks
    callback = self._get_callback(**callback_params)
  File "/home/awecom/anaconda3/envs/workframe/lib/python3.6/site-packages/catalyst/dl/experiment/config.py", line 512, in _get_callback
    callback = CALLBACKS.get_from_params(**params)
  File "/home/awecom/anaconda3/envs/workframe/lib/python3.6/site-packages/catalyst/utils/tools/registry.py", line 244, in get_from_params
    return self.get_instance(name, meta_factory=meta_factory, **kwargs)
TypeError: get_instance() got multiple values for argument 'name'

config:

    logger:
      callback: WandbLogger
      project: {{ project }}
      name: {{ name }}

@CrafterKolyan
Copy link
Contributor Author

@pokidyshev Can you please provide code example how you use this config?
Because:

from catalyst import dl
import torch
import torch.nn as nn
import torch.optim as optim
from torch.utils.data import DataLoader, TensorDataset

class Projector(nn.Module):
    def __init__(self, input_size):
        super().__init__()
        self.linear = nn.Linear(input_size, 1)
    def forward(self, X):
        return self.linear(X).squeeze(-1)

X = torch.rand(16, 10)
y = torch.rand(X.shape[0])
model = Projector(X.shape[1])
dataset = TensorDataset(X, y)
loader = DataLoader(dataset, batch_size=8)
runner = dl.SupervisedRunner()

runner.train(
    model=model,
    loaders={
        "train": loader,
        "valid": loader
    },
    criterion=nn.MSELoss(),
    optimizer=optim.Adam(model.parameters()),
    logdir="log_example",
    callbacks=[
        dl.callbacks.WandbLogger(
            name="some name",
            project="some project"
        )
    ],
    num_epochs=10
)

works fine even though it has name attribute

@pokidyshev
Copy link
Contributor

This happens only in config mode cause this method has a name parameter and kwargs also:

def get_instance(self, name: str, *args, meta_factory=None, **kwargs):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants