[W&B] Sanitize hyperparameters in WandbLogger
🐛 Bug

While using Weights & Biases, certain hyperparameters (non-primitives) are not usable in the W&B dashboard as expected. For example, I'm using a list of integers (denoting the filters in each block of a UNet) as a hyperparameter, but this does not show up in the parallel co-ordinates section of W&B.
I looked into the base logger and used this function to "sanitize" the hyperparameters before logging to W&B, and it worked correctly.

  
    
      pytorch-lightning/pytorch_lightning/loggers/base.py
    
    
         Line 233
      in
      ece09f0
    
  
  
    

        
          
           def _sanitize_params(params: Dict[str, Any]) -> Dict[str, Any]: 
        
    
  



To Reproduce

Unfortunately, the project I'm working on is private for now - so I couldn't share the results. However, if necessary, I could try and use the boring model to reproduce the issue.
Environment

PyTorch Version (e.g., 1.0): 1.7
OS (e.g., Linux): Windows
How you installed PyTorch (conda, pip, source): Conda
Build command you used (if compiling from source):
Python version: 3.7
CUDA/cuDNN version: 10.2
GPU models and configuration:
Any other relevant information:

Additional context

Following a logic similar to TensorboardLogger, I modified the log_hyperparams() of WandbLogger from:

  
    
      pytorch-lightning/pytorch_lightning/loggers/wandb.py
    
    
        Lines 138 to 143
      in
      ece09f0
    
  
  
    

        
          
           @rank_zero_only 
        

        
          
           def log_hyperparams(self, params: Union[Dict[str, Any], Namespace]) -> None: 
        

        
          
               params = self._convert_params(params) 
        

        
          
               params = self._flatten_dict(params) 
        

        
          
               params = self._sanitize_callable_params(params) 
        

        
          
               self.experiment.config.update(params, allow_val_change=True) 
        
    
  


to:
@rank_zero_only
def log_hyperparams(self, params):
    params = self._convert_params(params)
    params = self._flatten_dict(params)
    params = self._sanitize_callable_params(params)
    params = self._sanitize_params(params)
    self.experiment.config.update(params, allow_val_change=True)
And the (non-primitive) parameters were logged properly and became usable in the W&B dashboard. I could create a pull request with a fix if this makes sense.
@borisdayma