Skip to content

Tag: pytorch

IndexError: Target 1 is out of bounds

When I run the program below, it gives me an error. The problem seems to be in the loss function but I can’t find it. I have read the Pytorch Documentation for nn.CrossEntropyLoss but still can’t find the problem. Image size is (1 x 256 x 256), Batch size is 1 I am new to PyTorch, thanks. Error: A…

How to create n-dimensional sparse tensor? (pytorch)

I want to initialize tensor to sparse tensor. When tensor’s dimensional is 2, I can use torch.nn.init.sparse(tensor, sparsity=0.1) Result But when tensor dimensions > 2, this function isn’t work. Result I need this because I want to use it to initialize the convolution weights. torch.nn.init.sp…