microsoft / nni

An open source AutoML toolkit for automate machine learning lifecycle, including feature engineering, neural architecture search, model compression and hyper-parameter tuning.
https://nni.readthedocs.io
MIT License
14k stars 1.81k forks source link

TypeError: to() takes from 0 to 4 positional arguments but 5 were given #5657

Open RToF opened 1 year ago

RToF commented 1 year ago

When normalize my input images with following func:

def normalize(self, image):
    # image_mean = [0.485, 0.456, 0.406],  image_std = [0.229, 0.224, 0.225]
    dtype, device = image.dtype, image.device
    mean = torch.as_tensor(self.image_mean, dtype=dtype, device=device)  
    std = torch.as_tensor(self.image_std, dtype=dtype, device=device)
    return (image - mean[:, None, None]) / std[:, None, None]

TypeError: to() takes from 0 to 4 positional arguments but 5 were given

And the stack : call, jit_translate.py:244 init, infer_mask.py:80 update_direct_sparsity, compressor.py:235 infer_modules_masks, compressor.py:381 speedup_model, compressor.py:544

, prac.py:84