When I am doing lab three, I met the error: module 'torch.nn' has no attribute 'Buffer' in the class below:
class MNISTSampler(nn.Module, Sampleable):
"""
Sampleable wrapper for the MNIST dataset
"""
def __init__(self):
super().__init__()
self.dataset = datasets.MNIST(
root='./data',
train=True,
download=True,
transform=transforms.Compose([
transforms.Resize((32, 32)),
transforms.ToTensor(),
transforms.Normalize((0.5,), (0.5,)),
])
)
self.dummy = nn.Buffer(
torch.zeros(1)
) # Will automatically be moved when self.to(...) is called...
My PyTorch version is 2.4.1+cu121.
I try to instead with the self.register_buffer('dummy', torch.zeros(1)), and it works.
When I am doing lab three, I met the error: module 'torch.nn' has no attribute 'Buffer' in the class below:
My PyTorch version is
2.4.1+cu121.I try to instead with the
self.register_buffer('dummy', torch.zeros(1)), and it works.