跑SCRN报错:AttributeError: 'torch.dtype' object has no attribute 'type' (已经解决)

跑SCRN报错:AttributeError: 'torch.dtype' object has no attribute 'type' (已经解决)_第1张图片

=>epoch: 0  |all epoch = 30    ||    =>iter: 1000
Traceback (most recent call last):
  File "train_SCRN.py", line 82, in
    format(datetime.now(), epoch, opt.epoch, i, total_step, loss_record1.show(), loss_record2.show()))
  File "/home/nk/zjc/PycharmProjects/nk_SCRN _loss/utils/func.py", line 59, in show
    return np.mean(self.losses[np.maximum(len(self.losses)-self.num, 0):])
  File "<__array_function__ internals>", line 6, in mean
  File "/home/nk/anaconda3/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 3257, in mean
    out=out, **kwargs)
  File "/home/nk/anaconda3/lib/python3.7/site-packages/numpy/core/_methods.py", line 161, in _mean
    ret = ret.dtype.type(ret / rcount)
AttributeError: 'torch.dtype' object has no attribute 'type'

解决办法:
format(datetime.now(), epoch, opt.epoch, i, total_step, loss_record1.show(), loss_record2.show()))
改为,绿色部分舍弃
format(datetime.now(), epoch, opt.epoch, i, total_step))

报错原因:
pytorch1.0貌似是直接 print(loss_record1)即可显示结果
pytorch0.4则是 print(loss_record1.show())
因而会报错

 

你可能感兴趣的:(遇到问题,SCRN中科院)