"AttributeError: Caught AttributeError in DataLoader worker process 0" , "AttributeError: module 'torchvision.transforms' has no attribute 'Scale'"

"AttributeError: Caught AttributeError in DataLoader worker process 0" , "AttributeError: module 'torchvision.transforms' has no attribute 'Scale'"

我遇到了这 2 个错误, “AttributeError:在 DataLoader 工作进程 0 中捕获到 AttributeError”,“AttributeError:模块 'torchvision.transforms' 没有属性 'Scale'”

任何机构都可以提供帮助吗? TIA

Traceback (most recent call last):
  File "test.py", line 126, in <module>
    main()
  File "test.py", line 85, in main
    for i, data in enumerate(dataset):
  File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py", line 530, in __next__
    data = self._next_data()
  File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py", line 1224, in _next_data
    return self._process_data(data)
  File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py", line 1250, in _process_data
    data.reraise()
  File "/usr/local/lib/python3.7/dist-packages/torch/_utils.py", line 457, in reraise
    raise exception
AttributeError: Caught AttributeError in DataLoader worker process 0.
Original Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/worker.py", line 287, in _worker_loop
    data = fetcher.fetch(index)
  File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/fetch.py", line 49, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/fetch.py", line 49, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/content/ACGPN/data/aligned_dataset.py", line 133, in __getitem__
    self.opt, params, method=Image.NEAREST, normalize=False)
  File "/content/ACGPN/data/base_dataset.py", line 46, in get_transform
    transform_list.append(transforms.Scale(osize, method))
AttributeError: module 'torchvision.transforms' has no attribute 'Scale'

基本上不可能在没有看到任何代码的情况下提供帮助,但是,错误说找不到 torchvision.transforms.Scale 因为它是 deprecated 所以改用 torchvision.transforms.Resize.