Skip to content
Advertisement

Tag: pytorch

How to solve “NotImplementedError”

I defined a three layer convolution layer(self.convs) ,the input tensor has the shape([100,10,24]) When I excuate x_convs = self.convs(Variable(torch.from_numpy(X).type(torch.FloatTensor))), it gives me the error The ConvBlock is defined as below The “forward” function has correct indent, so I cannot figure it out what is going on. Answer You are trying to call a ModuleList, which is a list (i.e. a

PyTorch DataLoader shuffle

I did an experiment and I did not get the result I was expecting. For the first part, I am using I save trainloader.dataset.targets to the variable a, and trainloader.dataset.data to the variable b before training my model. Then, I train the model using trainloader. After the training is finished, I save trainloader.dataset.targets to the variable c, and trainloader.dataset.data to

Gaussian filter in PyTorch

I am looking for a way to apply a Gaussian filter to an image (tensor) only using PyTorch functions. Using numpy, the equivalent code is The closest suggestion I found is based on this post: But it gives me the error NameError: name ‘gaussian_weights’ is not defined. How can I make it work? Answer There is a Pytorch class to

RuntimeError: Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the same

This: Gives the error: RuntimeError: Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the same Answer You get this error because your model is on the GPU, but your data is on the CPU. So, you need to send your input tensors to the GPU. Or like this, to stay consistent with the rest of your code: The same

Advertisement