pytorch报错:AttributeError: module ‘torch.sparse‘ has no attribute ‘torch‘

错误:
File “E2Capsnet.py”, line 397, in test
target = torch.sparse.torch.eye(NUM_CLASSES).index_select(dim=0, index=label)
AttributeError: module ‘torch.sparse’ has no attribute ‘torch’

原版程序:

target = torch.sparse.torch.eye(NUM_CLASSES).index_select(dim=0, index=label)

改动后的程序:

target = torch.eye(NUM_CLASSES).index_select(dim=0, index=label)

OK!

你可能感兴趣的:(linux)