Avoid `AttributeError: 'torch.dtype' object has no attribute 'type'` …
Avoid AttributeError: 'torch.dtype' object has no attribute 'type' error. To make it compatible with new PyTorch versions
+1, currently the Docker image fails due to this since it always installs the latest version of PyTorch.
Hello, I ran into this issue as well, should have come by your PR sooner.
Not sure how performance compares, or which is best practice, but I edited the below in the logging file:
# defined a new method in the logging class
def average_list(self, k, window):
array = []
for stat in self.stats[k][-window:]:
item = stat[1]
if T.is_tensor(item):
item = item.cpu().numpy()
array.append(item)
return np.mean(array)
# edited the line throwing the errors
item = "{:.4f}".format(self.average_list(k, window))
Hi, I would like to mention that I tested the fix by @GoingMyWay because mine felt hacky, but it didn't work, still crashed when logging the stats. Reverted back to my fix.
Hi, I would like to mention that I tested the fix by @GoingMyWay because mine felt hacky, but it didn't work, still crashed when logging the stats. Reverted back to my fix.
Can you check which item in the stats caused this problem. Actually, for old Pytorch versions, the grad_norm caused this problem.