Category "pytorch"

Loss not decreasing - Pytorch

I am using dice loss for my implementation of a Fully Convolutional Network(FCN) which involves hypernetworks. The model has two inputs and one output which is

Loss not decreasing - Pytorch

I am using dice loss for my implementation of a Fully Convolutional Network(FCN) which involves hypernetworks. The model has two inputs and one output which is

What is the difference between Tensor.size and Tensor.shape in PyTorch?

What is the difference between Tensor.size and Tensor.shape in Pytorch? I want to get the number of elements and the dimensions of Tensor. For example for a ten

Compute maxima and minima of a 4D tensor in PyTorch

Suppose that we have a 4-dimensional tensor, for instance import torch X = torch.rand(2, 3, 4, 4)

how to modify resnet 50 with 4 channels as input using pre-trained weights in Pytorch?

I would like to change the resnet50 so that I can switch to 4 channel input, use the same weights for the rgb channels and initialize the last channel with a no

Multiclass semantic segmentation model evaluation

I am doing a project on multiclass semantic segmentation. I have formulated a model that outputs pretty descent segmented images by decreasing the loss value. H

How to reduce model size in Pytorch post training

I have created a pytorch model and I want to reduce the model size. Defining Model Architecture :- import torch import torch.quantization import torch.nn as nn

Replace torch.gather by other operator?

I have one script code, where x1 and x2 size of 1x68x8x8 tmp_batch, tmp_channel, tmp_height, tmp_width = x1.size() x1 = x1.view(tmp_batch*tmp_channel, -1)

version `GLIBC_2.28' not found

I'm trying to install PyTorch on ARMv7(32-bit) architecture but PyTorch doesn’t have official ARMv7 builds so i tried this unofficial build. It installed

Extracting labels after applying softmax

I have a multi class classification neural network. I apply softmax at the end to get probabilities for my classes. However, now I want to pick the maximum prob

PyTorch Model Training: RuntimeError: cuDNN error: CUDNN_STATUS_INTERNAL_ERROR

After training a PyTorch model on a GPU for several hours, the program fails with the error RuntimeError: cuDNN error: CUDNN_STATUS_INTERNAL_ERROR Trainin

TypeError: forward() takes 1 positional argument but 2 were given

class DeConv2d(nn.Module): def __init__(self, in_channel, out_channel, kernel_size, stride, padding, dilation): super().__init__() self.up

Is torch.as_tensor() the same as torch.from_numpy() for a numpy array on a CPU?

On a CPU, is torch.as_tensor(a) the same as torch.from_numpy(a) for a numpy array, a? If not, then why not? From the docs for torch.as_tensor if the data

'no module named cv2' import error on pytorch

I am currently studying Pytorch and trying to use the cv2 module. I am using Jupyter notebook and Windows. I have installed opencv like this: !pip install op

Asking gpt-2 to finish sentence with huggingface transformers

I am currently generating text from left context using the example script run_generation.py of the huggingface transformers library with gpt-2: $ python transf

How to apply max_length to truncate the token sequence from the left in a HuggingFace tokenizer?

In the HuggingFace tokenizer, applying the max_length argument specifies the length of the tokenized text. I believe it truncates the sequence to max_length-2 (

How to clean garbage from CUDA in Pytorch?

I teached my neural nets and realized that even after torch.cuda.empty_cache() and gc.collect() my cuda-device memory is filled. In Colab Notebooks we can see t

Pytorch Change the learning rate based on number of epochs

When I set the learning rate and find the accuracy cannot increase after training few epochs optimizer = optim.Adam(model.parameters(), lr = 1e-4) n_epochs = 1

Padding a tensor until reaching required size

I'm working with certian tensors with shape of (X,42) while X can be in a range between 50 to 70. I want to pad each tensor that I get until it reaches a size o

Exception when converting Unet from pytorch to onnx

I'm trying to convert a Unet model from PyTorch to ONNX. Running the following code: import torch from unets import Unet, thin_setup net = Unet(in_features=3,