Tune: Format hyperparameter names picked up by tensorboard and wandb loggers

In RAY TUNE: Is there a way to modify hyperparameter names before they are used as part of the filename in tensorboard or as part of the config object in wandb (w/o modifying the wandb config object).For e.g. if I configure tune with:

# This results in tensorboard runs with folder names containing the string <class module1.module2.model_class1> or <class module1.module2.model_class2>
# I would like to remove '<class >' from the above strings
tune.run(config={"model": tune.grid_search([model_class1, model_class2])})

Note: wandb = the weights and biases module

Hi @deeplrng, there is no functionality for this in the tensorboard and wandb logger callbacks.

The problem here is that you pass a class to the grid search, and the string value of a class object is rendered as <class 'module.class_name'>.

A solution could be to pass a key to a model class instead, e.g. something like this:

models = {
    "model_1": model_class1,
    "model_2": model_class2

def train(config):
    model_cls = models[config["model"]]
    model_obj = model_cls(...)
    # ...

    config={"model": tune.grid_search(list(models.keys()))},
    # ...

1 Like

I have run into this same issue, and what I do is monkey patch __repr__:

model1 = ...
model1.name = 'MyModel1'
models = [model1, model2]
for model in models:
  model.__repr__ == lambda self: self.name
1 Like