name
stringlengths
15
255
question
stringlengths
20
1.77k
questionUpvotes
int64
0
23
timeCreated
stringlengths
24
24
answer
stringlengths
9
1.09k
answerUpvotes
int64
0
75
timeAnswered
stringlengths
24
24
answerURL
stringlengths
50
285
context
stringlengths
244
1.73k
answer_start
int64
0
3.45k
answers
stringlengths
46
1.14k
3D CNN overfittting issue
Hi, I am trying to retrain a 3D CNN model from a research article and I run into overfitting issues even upon implementing data augmentation on the fly to avoid overfitting. I can see that my model learns and then starts to oscillate along the same loss numbers. Any suggestions on how to improve …
0
2021-11-05T14:12:21.054Z
To me it seems strange you are using softmax + mse loss. You are computing some sort of probabilities but then you use a cartesian distance? Strange Are you using the same dataset or a different one? You have convolutions with 512 filters which leads to a huge amount of a parameters for a 3D nn. B…
1
2021-11-06T03:47:46.613Z
https://discuss.pytorch.org/t/3d-cnn-overfittting-issue/136093/6
To me it seems strange you are using softmax + mse loss. You are computing some sort of probabilities but then you use a cartesian distance? Strange Are you using the same dataset or a different one? You have convolutions with 512 filters which leads to a huge amount of a parameters for a 3D nn. B… Hi, I thin...
1,610
{'text': ['To me it seems strange you are using softmax + mse loss.\n\nYou are computing some sort of probabilities but then you use a cartesian distance? Strange\n\nAre you using the same dataset or a different one? You have convolutions with 512 filters which leads to a huge amount of a parameters for a 3D nn. B&hell...
How to use autograd in the C++ api to compute a gradient of a multivalued function?
I would like to calculate y = sin(x), where x is a vector of length N and compute the corresponding derivative vector y’ = (dy_i / dx_i), i = 1,2,3,…,N using autograd. This is what I ended up doing: // Input vector x auto x = torch::linspace( 0, M_PI, 100, torch::requires_grad() …
0
2021-01-13T18:20:40.939Z
Hi, I think the best way to see what happens here is to write the Jacobian of your function and see what happens when you do the vector jacobian product (backward pass). For your sin function, it just applies the sin element-wise to the input. So the Jacobian matrix is a diagonal matrix with on ea…
1
2021-01-13T18:56:23.449Z
https://discuss.pytorch.org/t/how-to-use-autograd-in-the-c-api-to-compute-a-gradient-of-a-multivalued-function/108753/2
To me it seems strange you are using softmax + mse loss. You are computing some sort of probabilities but then you use a cartesian distance? Strange Are you using the same dataset or a different one? You have convolutions with 512 filters which leads to a huge amount of a parameters for a 3D nn. B… Hi, I thin...
1,114
{'text': ['Hi,\n\nI think the best way to see what happens here is to write the Jacobian of your function and see what happens when you do the vector jacobian product (backward pass).\n\nFor your sin function, it just applies the sin element-wise to the input. So the Jacobian matrix is a diagonal matrix with on ea&hell...
Expected scalar type Long but found Float
Hello! I have problem with my code: import numpy as np import os import torch from torch.utils.data import Dataset, DataLoader import torchvision.models as models import torchvision as trv import torch.nn as nn from sklearn.model_selection import train_test_split import torch.optim as optim import …
0
2021-06-11T19:17:49.803Z
I’m unsure how the kernel size is related to the input shape of the batchnorm layer. However, if the input contains only a single value for each channel (as is the case here), you won’t be able to use batchnorm layers in training mode, since they need to calculate the stats from the input. Since i…
0
2021-06-11T21:49:29.535Z
https://discuss.pytorch.org/t/expected-scalar-type-long-but-found-float/123921/18
To me it seems strange you are using softmax + mse loss. You are computing some sort of probabilities but then you use a cartesian distance? Strange Are you using the same dataset or a different one? You have convolutions with 512 filters which leads to a huge amount of a parameters for a 3D nn. B… Hi, I thin...
618
{'text': ['I’m unsure how the kernel size is related to the input shape of the batchnorm layer.\n\nHowever, if the input contains only a single value for each channel (as is the case here), you won’t be able to use batchnorm layers in training mode, since they need to calculate the stats from the input.\n\nSince i&hell...
How can I know the exact dimensions for a layer that I am adding (to an already existing architecture)
I am adding the following code in resnet18 custom code self.layer1 = self._make_layer(block, 64, layers[0]) ## code existed before self.layer2 = self._make_layer(block, 128, layers[1], stride=2) ## code existed before self.layer_attend1 = nn.Sequential(nn.Conv2d(layers[0], layers[0], stride=2, pad…
0
2021-08-31T23:06:41.164Z
[image] Mona_Jalal: For example, I want to print layers[0] information but nothing gets printed. What do you mean by “nothing gets printed”? If you add the line print("Hi") at the place where you were trying to print layers[0], does it print anything? (It should …) To know the dimensions t…
1
2021-09-01T00:29:14.390Z
https://discuss.pytorch.org/t/how-can-i-know-the-exact-dimensions-for-a-layer-that-i-am-adding-to-an-already-existing-architecture/130794/2
[image] Mona_Jalal: For example, I want to print layers[0] information but nothing gets printed. What do you mean by “nothing gets printed”? If you add the line print("Hi") at the place where you were trying to print layers[0], does it print anything? (It should …) To know the dimensions t… No, th...
1,852
{'text': ['[image] Mona_Jalal:\n\nFor example, I want to print layers[0] information but nothing gets printed.\n\nWhat do you mean by “nothing gets printed”? If you add the line\n\nprint("Hi")\n\nat the place where you were trying to print layers[0], does it print anything? (It should …)\n\nTo know the dimens...
Getting image name from tensor data after batch data loading
To debug my code I need to get name of images in my batch with its labels and prediction. As images in batch are in form of tensor, So I can not acess image name. In my dataloader below part of code is used- def getitem(self, i): data, label = self.data[i], self.label[i] #here data is actual fi…
0
2021-06-06T21:26:22.700Z
No, this should work: data, _, file_name = batch data = data.cuda() assuming batch contains 3 objects.
0
2021-06-08T23:56:29.463Z
https://discuss.pytorch.org/t/getting-image-name-from-tensor-data-after-batch-data-loading/123445/6
[image] Mona_Jalal: For example, I want to print layers[0] information but nothing gets printed. What do you mean by “nothing gets printed”? If you add the line print("Hi") at the place where you were trying to print layers[0], does it print anything? (It should …) To know the dimensions t… No, th...
1,240
{'text': ['No, this should work:\n\ndata, _, file_name = batch\n\ndata = data.cuda()\n\nassuming batch contains 3 objects.'], 'answer_start': [1240]}
Jit.trace not working for detecto model
I am using detecto model which is trained on custom data set, but the problem is when i try to use that model with jit.trace it throws an error. Code: from detecto.core import Model from detecto.utils import read_image import torch model = Model.load(model_path, classes) example = torch.rand(1…
0
2020-09-23T09:56:43.194Z
<a class="mention" href="/u/shisho_sama">@Shisho_Sama</a> I just got to know that MaskRCNN of Faster RCNN models doesn’t have support for torch.jit.trace() as they only support torch.jit.script()
1
2020-10-06T13:25:46.120Z
https://discuss.pytorch.org/t/jit-trace-not-working-for-detecto-model/97238/20
[image] Mona_Jalal: For example, I want to print layers[0] information but nothing gets printed. What do you mean by “nothing gets printed”? If you add the line print(&quot;Hi&quot;) at the place where you were trying to print layers[0], does it print anything? (It should …) To know the dimensions t&hellip; No, th...
420
{'text': ['<a class="mention" href="/u/shisho_sama">@Shisho_Sama</a> I just got to know that MaskRCNN of Faster RCNN models doesn’t have support for torch.jit.trace() as they only support torch.jit.script()'], 'answer_start': [420]}
Deleting Tensors in Context Save for Backward
Are the tensor saved for backward as below freed or deleted automatically after the backward pass? ctx.save_for_backward(input, weight, bias) I am trying to get around memory used problems.
0
2021-05-31T20:14:48.441Z
Yes, these tensors should be freed after the backward(). To double check it, you could use <a href="https://pytorch.org/tutorials/beginner/examples_autograd/two_layer_net_custom_function.html">this example</a> and add some print statements to check the memory: for t in range(5): # To apply our Function, we use Funct...
1
2021-06-01T07:57:23.466Z
https://discuss.pytorch.org/t/deleting-tensors-in-context-save-for-backward/122917/2
Yes, these tensors should be freed after the backward(). To double check it, you could use <a href="https://pytorch.org/tutorials/beginner/examples_autograd/two_layer_net_custom_function.html">this example</a> and add some print statements to check the memory: for t in range(5): # To apply our Function, we use Funct...
1,230
{'text': ['Yes, these tensors should be freed after the backward().\n\nTo double check it, you could use <a href="https://pytorch.org/tutorials/beginner/examples_autograd/two_layer_net_custom_function.html">this example</a> and add some print statements to check the memory:\n\nfor t in range(5):\n\n# To apply our Funct...
Decoder size mismatch error
Afternoon, I am hoping someone can help me i am getting the following error message: output = input.matmul(weight.t()) RuntimeError: size mismatch, m1: [2 x 10], m2: [2 x 10] at C:/w/1/s/tmp_conda_3.7_044431/conda/conda-bld/pytorch_1556686009173/work/aten/src\THC/generic/THCTensorMathBlas.cu:268 &hellip;
0
2019-07-10T12:49:31.823Z
I’m not familiar with your use case, but you could reshape the output of your linear layer before feeding it to the nn.ConvTranpose1d layer or just add a dummy channel dimension using: output = output.unsqueeze(1) Based on the number of input channels in co1, it seems the dummy channel dimension i&hellip;
0
2019-07-10T20:36:22.419Z
https://discuss.pytorch.org/t/decoder-size-mismatch-error/50254/11
Yes, these tensors should be freed after the backward(). To double check it, you could use <a href="https://pytorch.org/tutorials/beginner/examples_autograd/two_layer_net_custom_function.html">this example</a> and add some print statements to check the memory: for t in range(5): # To apply our Function, we use Funct...
1,028
{'text': ['I’m not familiar with your use case, but you could reshape the output of your linear layer before feeding it to the nn.ConvTranpose1d layer or just add a dummy channel dimension using:\n\noutput = output.unsqueeze(1)\n\nBased on the number of input channels in co1, it seems the dummy channel dimension i&hell...
Mini batches in a Pytorch custom model
Hi All, I have built a custom autoencoder and have it working reasonably well. In an attempt to improve speed/performance, I have attempted to implement batch training. Looking at the <a href="http://PyTorch.org" rel="noopener nofollow ugc">PyTorch.org</a> site, it appeared that setting the batch size in the dataload...
0
2022-06-23T08:05:27.406Z
It’s hard to tell if a speedup would be expected as the operations are quite small by themselves. While a loop would add a certain overhead, the actual dispatching of these workloads could also be visible. In any case, here is a draft of a code avoiding loops for the first operations (the higher p&hellip;
0
2022-06-25T23:36:10.742Z
https://discuss.pytorch.org/t/mini-batches-in-a-pytorch-custom-model/154866/6
Yes, these tensors should be freed after the backward(). To double check it, you could use <a href="https://pytorch.org/tutorials/beginner/examples_autograd/two_layer_net_custom_function.html">this example</a> and add some print statements to check the memory: for t in range(5): # To apply our Function, we use Funct...
722
{'text': ['It’s hard to tell if a speedup would be expected as the operations are quite small by themselves.\n\nWhile a loop would add a certain overhead, the actual dispatching of these workloads could also be visible.\n\nIn any case, here is a draft of a code avoiding loops for the first operations (the higher p&hell...
Trying to calculate gradient penalty with grad() detaches computational graph
I have a very simple discriminator for a toy GAN problem where I’m trying to find the magnitude of the gradient in order to apply a penalty to the gradient. In order to do that, I need the gradient norm to be differentiable. When I calculate the loss function for the generator I get the following c&hellip;
0
2020-10-21T00:57:37.434Z
Ah, I figured it out! The problem is that I’m using the pytorch-lightning package, and it was freezing the weights of the other model for each step. On the discriminator step, the gradient norm is actually fully a function of the generator weights, so that was causing the problem. So it looks like I&hellip;
1
2020-10-22T20:51:34.584Z
https://discuss.pytorch.org/t/trying-to-calculate-gradient-penalty-with-grad-detaches-computational-graph/100078/13
Ah, I figured it out! The problem is that I’m using the pytorch-lightning package, and it was freezing the weights of the other model for each step. On the discriminator step, the gradient norm is actually fully a function of the generator weights, so that was causing the problem. So it looks like I&hellip; Balancing t...
2,060
{'text': ['Ah, I figured it out! The problem is that I’m using the pytorch-lightning package, and it was freezing the weights of the other model for each step. On the discriminator step, the gradient norm is actually fully a function of the generator weights, so that was causing the problem. So it looks like I&hellip;'...
The accuracy of the convolutional neural network stays the same when the criterion is selected as CrossEntropyLoss
As the title clearly describes, the accuracy of my CNN stays the same when the criterion is selected as CrossEntropyLoss. I especially selected CrossEntropyLoss since only it achieves the test loss close to the training loss. No issues at all for the other loss functions. Here is the ov&hellip;
0
2019-08-08T09:09:25.029Z
Balancing the dataset should trace the accuracy of the majority class for an increase in the accuracy of the minority classes. I’ve created a tutorial a while ago <a href="https://github.com/ptrblck/tutorials/blob/imbalanced_tutorial/intermediate_source/imbalanced_data_tutorial.py" rel="nofollow noopener">here</a>, wh...
1
2019-08-11T11:06:05.806Z
https://discuss.pytorch.org/t/the-accuracy-of-the-convolutional-neural-network-stays-the-same-when-the-criterion-is-selected-as-crossentropyloss/52862/14
Ah, I figured it out! The problem is that I’m using the pytorch-lightning package, and it was freezing the weights of the other model for each step. On the discriminator step, the gradient norm is actually fully a function of the generator weights, so that was causing the problem. So it looks like I&hellip; Balancing t...
1,339
{'text': ['Balancing the dataset should trace the accuracy of the majority class for an increase in the accuracy of the minority classes.\n\nI’ve created a tutorial a while ago <a href="https://github.com/ptrblck/tutorials/blob/imbalanced_tutorial/intermediate_source/imbalanced_data_tutorial.py" rel="nofollow noopener"...
Torch.cuda.is_available() is False for cuda 9.0.176, cuda diver 390.77
nvidia-smi works, torch.backends.cudnn.enabled returns True, but torch.cuda.is_available() returns False. Reboot can’t do any help. I don’t know what’s wrong? CUDA path is as follows: export PATH=/home/ubuntu/cuda/bin${PATH:+:${PATH}} export LD_LIBRARY_PATH=/home/ubuntu/cuda/lib64${LD_LIBRARY_PA&hellip;
0
2018-12-06T01:31:03.339Z
Hi, If the cuda samples don’t run. Then the problem is with your cuda install. I would advice in that case to cleanly remove all cuda install from the system. And reinstall them from scratch with nvidia drivers that correspond. Then make sure that the cuda samples work properly. Once these work, y&hellip;
0
2018-12-12T10:11:24.424Z
https://discuss.pytorch.org/t/torch-cuda-is-available-is-false-for-cuda-9-0-176-cuda-diver-390-77/31398/10
Ah, I figured it out! The problem is that I’m using the pytorch-lightning package, and it was freezing the weights of the other model for each step. On the discriminator step, the gradient norm is actually fully a function of the generator weights, so that was causing the problem. So it looks like I&hellip; Balancing t...
687
{'text': ['Hi,\n\nIf the cuda samples don’t run. Then the problem is with your cuda install.\n\nI would advice in that case to cleanly remove all cuda install from the system. And reinstall them from scratch with nvidia drivers that correspond. Then make sure that the cuda samples work properly. Once these work, y&hell...
Bias are not updating in decoder model
class Framework(nn.Module): def __init__(self): super(Framework, self).__init__() self.fc1 = nn.Linear(input_shape, 512) self.fc21 = nn.Linear(512, 128) self.fc22 = nn.Linear(512, 128) self.fc3 = nn.Linear(128, 512) self.fc4 = nn.Linear(512, input_&hellip;
0
2020-05-12T17:27:08.182Z
[image] Anuj_Daga: +self.fc4.bias Have you tried removing the +self.fc*.bias parts from the above snippet, or plotting the bias value every epoch?
0
2020-05-12T21:52:41.323Z
https://discuss.pytorch.org/t/bias-are-not-updating-in-decoder-model/80897/5
[image] Anuj_Daga: +self.fc4.bias Have you tried removing the +self.fc*.bias parts from the above snippet, or plotting the bias value every epoch? It worked, thanks a lot. from torchvision.ops import misc model = torch.load(&quot;...&quot;) for name, layer in model.named_modules(): if isinstance(layer, misc.Froze...
1,990
{'text': ['[image] Anuj_Daga:\n\n+self.fc4.bias\n\nHave you tried removing the +self.fc*.bias parts from the above snippet, or plotting the bias value every epoch?'], 'answer_start': [1990]}
Load model from 1.5.1 and save/use it on 1.7.1
Hi, I have an old model saved from PyTorch 1.5.1 using torch.save(model, &quot;MyModel.pt&quot;). When I try to use it on PyTorch 1.7.1, I get the following error: torch.nn.modules.module.ModuleAttributeError: &#39;FrozenBatchNorm2d&#39; object has no attribute &#39;eps&#39; Unfortunately, I don’t know the architec...
0
2021-01-23T07:36:16.273Z
It worked, thanks a lot. from torchvision.ops import misc model = torch.load(&quot;...&quot;) for name, layer in model.named_modules(): if isinstance(layer, misc.FrozenBatchNorm2d): layer.eps = 0. torch.save(model, &quot;...&quot;)
1
2021-01-27T04:18:37.780Z
https://discuss.pytorch.org/t/load-model-from-1-5-1-and-save-use-it-on-1-7-1/109750/12
[image] Anuj_Daga: +self.fc4.bias Have you tried removing the +self.fc*.bias parts from the above snippet, or plotting the bias value every epoch? It worked, thanks a lot. from torchvision.ops import misc model = torch.load(&quot;...&quot;) for name, layer in model.named_modules(): if isinstance(layer, misc.Froze...
1,144
{'text': ['It worked, thanks a lot.\n\nfrom torchvision.ops import misc\n\nmodel = torch.load(&quot;...&quot;)\n\nfor name, layer in model.named_modules():\n\nif isinstance(layer, misc.FrozenBatchNorm2d):\n\nlayer.eps = 0.\n\ntorch.save(model, &quot;...&quot;)'], 'answer_start': [1144]}
Model Predictions are all Tensors Full of Zeros
Hi all, I want to preface this by saying I’m relatively new to this field, so I apologize in advance if the solution is trivial. I’m working to build a prediction model that is able to take general information about the weather and location of an accident to predict the severity of traffic caused a&hellip;
0
2022-06-29T21:00:10.745Z
The usage of a single output dimension with F.log_softmax(x, dim=1) and nn.MSELoss won’t work for several reasons: F.log_softmax(x, dim=1) on a tensor of the shape [batch_size, 1] will always create an all zero tensor (since each “row” would have a probability of 1, thus a log prob of 0) nn.MSEL&hellip;
0
2022-06-30T01:19:35.986Z
https://discuss.pytorch.org/t/model-predictions-are-all-tensors-full-of-zeros/155381/5
[image] Anuj_Daga: +self.fc4.bias Have you tried removing the +self.fc*.bias parts from the above snippet, or plotting the bias value every epoch? It worked, thanks a lot. from torchvision.ops import misc model = torch.load(&quot;...&quot;) for name, layer in model.named_modules(): if isinstance(layer, misc.Froze...
387
{'text': ['The usage of a single output dimension with F.log_softmax(x, dim=1) and nn.MSELoss won’t work for several reasons:\n\nF.log_softmax(x, dim=1) on a tensor of the shape [batch_size, 1] will always create an all zero tensor (since each “row” would have a probability of 1, thus a log prob of 0)\n\nnn.MSEL&hellip...
Speed up Jacobian matrix calculation in Pytorch
Hi all I use ‘torch.autograd.functional.jacobian(f,x)’ to calculate the partial derivatives of f with respect to x but when the dimension of f is incremented the time of calculation increases. does anyone know any solution to speed up the jacobian calculation in PyTorch? Thanks in advance.
0
2022-02-07T13:00:33.167Z
You might want to have a look at <a href="https://github.com/pytorch/functorch/blob/main/README.md" rel="noopener nofollow ugc">FuncTorch</a>
0
2022-02-07T13:22:34.533Z
https://discuss.pytorch.org/t/speed-up-jacobian-matrix-calculation-in-pytorch/143475/2
You might want to have a look at <a href="https://github.com/pytorch/functorch/blob/main/README.md" rel="noopener nofollow ugc">FuncTorch</a> You will need to subclass batchnorm to make that happen. Here is an example for the 2d version: Class MyLearntBatchnorm(nn. BatchNorm2d): def __init__(self, *args, **kwargs): ...
1,386
{'text': ['You might want to have a look at <a href="https://github.com/pytorch/functorch/blob/main/README.md" rel="noopener nofollow ugc">FuncTorch</a>'], 'answer_start': [1386]}
How to track and add autograd computation graphs for buffers
Hi! I’m trying to run a dataset distillation algorithm (see <a href="https://arxiv.org/pdf/1811.10959.pdf" rel="nofollow noopener">paper</a> here) and I’ve encountered an implementation problem. In case you’re not familiar with this paper, I will expalin its main idea briefly. Basically, dataset distillation aims at s...
0
2019-10-13T06:58:14.489Z
You will need to subclass batchnorm to make that happen. Here is an example for the 2d version: Class MyLearntBatchnorm(nn. BatchNorm2d): def __init__(self, *args, **kwargs): # Initialize the regular batchnorm super().__init__(*args, **kwargs) # Get the size of the runnning_* buffers&hellip;
1
2019-10-16T15:19:40.888Z
https://discuss.pytorch.org/t/how-to-track-and-add-autograd-computation-graphs-for-buffers/58080/8
You might want to have a look at <a href="https://github.com/pytorch/functorch/blob/main/README.md" rel="noopener nofollow ugc">FuncTorch</a> You will need to subclass batchnorm to make that happen. Here is an example for the 2d version: Class MyLearntBatchnorm(nn. BatchNorm2d): def __init__(self, *args, **kwargs): ...
835
{'text': ['You will need to subclass batchnorm to make that happen.\n\nHere is an example for the 2d version:\n\nClass MyLearntBatchnorm(nn. BatchNorm2d):\n\ndef __init__(self, *args, **kwargs):\n\n# Initialize the regular batchnorm\n\nsuper().__init__(*args, **kwargs)\n\n# Get the size of the runnning_* buffers&hellip...
Reshaping output to fit In CTC loss
Hi fellows, I have a doubt. I am working on 2D Cnn network for OCR. After my 6th CNN layer output, tensor shape will be (B, C, H, W). I have to pass this output to linear layer to map to number of classes(76) required to have for CTC loss. Now how should i reshape my CNN output tensor to pass to li&hellip;
0
2021-12-15T14:16:06.381Z
There are multiple possible approaches and it depends how the activation shape is interpreted. E.g. using [64, 512, 1, 28] you could squeeze dim3 and use dim4 as the “sequence” dimension (it’s one of the spatial dimension). In this case, you could permute the activation so that the linear layer wi&hellip;
0
2021-12-17T07:26:23.720Z
https://discuss.pytorch.org/t/reshaping-output-to-fit-in-ctc-loss/139459/2
You might want to have a look at <a href="https://github.com/pytorch/functorch/blob/main/README.md" rel="noopener nofollow ugc">FuncTorch</a> You will need to subclass batchnorm to make that happen. Here is an example for the 2d version: Class MyLearntBatchnorm(nn. BatchNorm2d): def __init__(self, *args, **kwargs): ...
441
{'text': ['There are multiple possible approaches and it depends how the activation shape is interpreted.\n\nE.g. using [64, 512, 1, 28] you could squeeze dim3 and use dim4 as the “sequence” dimension (it’s one of the spatial dimension).\n\nIn this case, you could permute the activation so that the linear layer wi&hell...
Pytorch Mobile iOS Resnet50 (Not Computing)
I am using torch.jit to trace a pretrained vanilla resnet50 to import over to iOS and call using Pytorch Mobile // C++ on iOS. - (NSInteger)predictImage:(void*)imageBuffer forLabels:(NSInteger)labelCount { int outputLabelIndex = -1; try { std::cout &lt;&lt; &quot;\npredictImage&quot;; at::Tenso&hellip;
0
2019-11-14T17:33:20.535Z
<a class="mention" href="/u/hussainharis">@HussainHaris</a> The master is back to normal. You can try recompiling from source code. Let me know if you have any questions.
0
2019-11-20T19:01:47.530Z
https://discuss.pytorch.org/t/pytorch-mobile-ios-resnet50-not-computing/61014/9
<a class="mention" href="/u/hussainharis">@HussainHaris</a> The master is back to normal. You can try recompiling from source code. Let me know if you have any questions. Yes ! I opened an issue there: <a href="https://github.com/pytorch/pytorch/issues/28370" rel="nofollow noopener">https://github.com/pytorch/pytorch...
1,498
{'text': ['<a class="mention" href="/u/hussainharis">@HussainHaris</a>\n\nThe master is back to normal. You can try recompiling from source code. Let me know if you have any questions.'], 'answer_start': [1498]}
Why am I getting this error about a Leaf Variable?
I’m trying to train some entity embeddings, but when doing a backward pass I get an error about Leaf Variables being moved into the graph interior. I saw there are other threads where people had that issue and it’s due to in-place operations or assigning to tensors, but I’m not doing anything like t&hellip;
0
2019-10-17T10:53:35.065Z
Yes ! I opened an issue there: <a href="https://github.com/pytorch/pytorch/issues/28370" rel="nofollow noopener">https://github.com/pytorch/pytorch/issues/28370</a>
1
2019-10-21T17:29:52.578Z
https://discuss.pytorch.org/t/why-am-i-getting-this-error-about-a-leaf-variable/58468/11
<a class="mention" href="/u/hussainharis">@HussainHaris</a> The master is back to normal. You can try recompiling from source code. Let me know if you have any questions. Yes ! I opened an issue there: <a href="https://github.com/pytorch/pytorch/issues/28370" rel="nofollow noopener">https://github.com/pytorch/pytorch...
921
{'text': ['Yes !\n\nI opened an issue there: <a href="https://github.com/pytorch/pytorch/issues/28370" rel="nofollow noopener">https://github.com/pytorch/pytorch/issues/28370</a>'], 'answer_start': [921]}
Data augmentation in semantic segmentation
Hi again I just want to ask about these lines in semantic segmentation data augmentation operation based on previews question discussion ptrblck said : [image] <a href="https://discuss.pytorch.org/t/data-augmentation-changed-the-mask-in-semantic-segmentation/129993/6">Data augmentation changed the mask in semantic ...
0
2021-08-23T15:37:04.794Z
this means we can add any type of augmentation in the function above and during these two lines: image_heavy = augmented[‘image’] mask_heavy = augmented[‘mask’] some operations will apply to images and others to mask based on the type of augmentation. is this right?
0
2021-08-25T08:02:51.803Z
https://discuss.pytorch.org/t/data-augmentation-in-semantic-segmentation/130060/16
<a class="mention" href="/u/hussainharis">@HussainHaris</a> The master is back to normal. You can try recompiling from source code. Let me know if you have any questions. Yes ! I opened an issue there: <a href="https://github.com/pytorch/pytorch/issues/28370" rel="nofollow noopener">https://github.com/pytorch/pytorch...
338
{'text': ['this means we can add any type of augmentation in the function above and during these two lines:\n\nimage_heavy = augmented[‘image’]\n\nmask_heavy = augmented[‘mask’]\n\nsome operations will apply to images and others to mask based on the type of augmentation.\n\nis this right?'], 'answer_start': [338]}
ValueError: Expected input batch_size (150) to match target batch_size (50)
iter = 0 for epoch in range(n_epoch): for i, (images, labels) in enumerate(train_loader): ####################### # USE GPU FOR MODEL # ####################### if torch.cuda.is_available(): images = Variable(images.view(-1, 28*28).cuda()) labels = Variable(label&hellip;
0
2020-02-09T20:35:59.915Z
The shape seems to be correct, but the labels should be zeros and ones.
0
2020-02-10T21:37:47.217Z
https://discuss.pytorch.org/t/valueerror-expected-input-batch-size-150-to-match-target-batch-size-50/69159/16
The shape seems to be correct, but the labels should be zeros and ones. For simplicity, suppose that your batch size is 1, and that you have 10 data points in your training set, and 1 data point in your validation set. Suppose that the loss is identical across all the data points, equal to 0.25 (to pick an arbitrary nu...
1,216
{'text': ['The shape seems to be correct, but the labels should be zeros and ones.'], 'answer_start': [1216]}
Validation loss much lower than training loss from the get go
Hi there, I am training a basic VAE on tabular data (standardized integers, real numbers, binary values and vectorized categories) and whatever I do, my validation loss is always considerably lower than my training loss. They also do not seem to get closer to each other whatsoever. Even from epoch &hellip;
0
2022-05-09T11:42:44.861Z
For simplicity, suppose that your batch size is 1, and that you have 10 data points in your training set, and 1 data point in your validation set. Suppose that the loss is identical across all the data points, equal to 0.25 (to pick an arbitrary number). Per your construction above, your overall tr&hellip;
0
2022-05-09T13:24:06.100Z
https://discuss.pytorch.org/t/validation-loss-much-lower-than-training-loss-from-the-get-go/151164/10
The shape seems to be correct, but the labels should be zeros and ones. For simplicity, suppose that your batch size is 1, and that you have 10 data points in your training set, and 1 data point in your validation set. Suppose that the loss is identical across all the data points, equal to 0.25 (to pick an arbitrary nu...
680
{'text': ['For simplicity, suppose that your batch size is 1, and that you have 10 data points in your training set, and 1 data point in your validation set. Suppose that the loss is identical across all the data points, equal to 0.25 (to pick an arbitrary number).\n\nPer your construction above, your overall tr&hellip...
Vectorization of a multiply function mymult(num1,num2) and myadd(num1,num2)
Convolution operation can be converted to matrix multiplication using <a href="https://discuss.pytorch.org/t/convolution-that-only-take-channel-wise-summation/21240/4">[1]</a> <a href="https://discuss.pytorch.org/t/custom-convolution-dot-product/14992/7">[2]</a> and then you can use torch.matmul() . My question is...
0
2019-12-10T05:23:24.319Z
Thanks for the code! What is mymult applying internally (if you don’t want to share it due to research etc., it’s OK)? If you are using some PyTorch methods internally, they should be able to use tensors (or batches of tensors) instead of scalar values. On the other hand, if you are using some ot&hellip;
1
2019-12-14T01:48:20.575Z
https://discuss.pytorch.org/t/vectorization-of-a-multiply-function-mymult-num1-num2-and-myadd-num1-num2/63571/4
The shape seems to be correct, but the labels should be zeros and ones. For simplicity, suppose that your batch size is 1, and that you have 10 data points in your training set, and 1 data point in your validation set. Suppose that the loss is identical across all the data points, equal to 0.25 (to pick an arbitrary nu...
381
{'text': ['Thanks for the code!\n\nWhat is mymult applying internally (if you don’t want to share it due to research etc., it’s OK)?\n\nIf you are using some PyTorch methods internally, they should be able to use tensors (or batches of tensors) instead of scalar values.\n\nOn the other hand, if you are using some ot&he...
Time to load training batch to GPU varying with model size
It looks like the time to copy one batch of data from cpu to gpu varies according to model size or maybe inference time. If model size or inference time is large, time taken is larger. I can’t understand why I am seeing this behavior. Below is the code to reproduce and results: import time import &hellip;
0
2019-12-17T21:14:57.076Z
CUDA operations are asynchronous, so you should synchronize via torch.cuda.synchronize() before starting and stopping the timer. Most likely, your code waits at the x = x.cuda() calls, while the model is still running in the background, which will accumulate the actual model time into the time to t&hellip;
0
2019-12-18T05:00:53.421Z
https://discuss.pytorch.org/t/time-to-load-training-batch-to-gpu-varying-with-model-size/64367/2
CUDA operations are asynchronous, so you should synchronize via torch.cuda.synchronize() before starting and stopping the timer. Most likely, your code waits at the x = x.cuda() calls, while the model is still running in the background, which will accumulate the actual model time into the time to t&hellip; The problem...
1,378
{'text': ['CUDA operations are asynchronous, so you should synchronize via torch.cuda.synchronize() before starting and stopping the timer.\n\nMost likely, your code waits at the x = x.cuda() calls, while the model is still running in the background, which will accumulate the actual model time into the time to t&hellip...
Only calling .backward() once, but I'm still getting an error telling me to set "retain_graph=True"
Hi, I am attempting to train a Siamese neural network that defines a particular embedding function f(x), while performing optimization simultaneously with a clustering model (Gaussian mixture model) on that embedding space. I want the NN weights to be updated with respect to both a loss function th&hellip;
0
2019-12-09T23:25:58.860Z
The problem is that in your loop, precisions (and other) are both used and written to. This means that the next iteration depends on the operations from the previous iteration (and thus all the ones before). If you only want backprop to compute gradients for the current iteration, you want to do s&hellip;
1
2019-12-10T21:33:36.181Z
https://discuss.pytorch.org/t/only-calling-backward-once-but-im-still-getting-an-error-telling-me-to-set-retain-graph-true/63542/12
CUDA operations are asynchronous, so you should synchronize via torch.cuda.synchronize() before starting and stopping the timer. Most likely, your code waits at the x = x.cuda() calls, while the model is still running in the background, which will accumulate the actual model time into the time to t&hellip; The problem...
998
{'text': ['The problem is that in your loop, precisions (and other) are both used and written to.\n\nThis means that the next iteration depends on the operations from the previous iteration (and thus all the ones before).\n\nIf you only want backprop to compute gradients for the current iteration, you want to do s&hell...
Am getting error trying to predict on a single image CNN pytorch
Traceback (most recent call last): File “pred.py”, line 134, in output = model(data) Runtime Error: Expected 4-dimensional input for 4-dimensional weight [16, 3, 3, 3], but got 3-dimensional input of size [1, 32, 32] instead. Also changed the dimension of the imge to something like this input_var =&hellip;
0
2021-02-25T16:24:08.115Z
No this shouldn’t change anything. In the transformations you should delete horizontal flip and do a resize instead of random crop.
1
2021-02-25T18:34:26.659Z
https://discuss.pytorch.org/t/am-getting-error-trying-to-predict-on-a-single-image-cnn-pytorch/113001/4
CUDA operations are asynchronous, so you should synchronize via torch.cuda.synchronize() before starting and stopping the timer. Most likely, your code waits at the x = x.cuda() calls, while the model is still running in the background, which will accumulate the actual model time into the time to t&hellip; The problem...
618
{'text': ['No this shouldn’t change anything. In the transformations you should delete horizontal flip and do a resize instead of random crop.'], 'answer_start': [618]}
Data Augmentation after creating Dataset
Hello there , I’m new to PyTorch, I’ve created a dataset that is having x-ray images and it is transformed but after creating the dataset I’m not getting good test accuracy so i have decided to do augmentation but I don’t know how to do augmentation on already created dataset . test_loader = data[&#39;&hellip;
0
2021-05-10T13:49:08.723Z
You can create a Compose of augmentations and then use it in the training loop itslelf. aug = Compose(&lt;the list of augmentations&gt;) for x,y in dataloader: x_aug = aug(x) I think this might do the trick.
1
2021-05-10T14:16:07.849Z
https://discuss.pytorch.org/t/data-augmentation-after-creating-dataset/120835/2
You can create a Compose of augmentations and then use it in the training loop itslelf. aug = Compose(&lt;the list of augmentations&gt;) for x,y in dataloader: x_aug = aug(x) I think this might do the trick. General advice, look at the docs! This will answer most of your questions. For example, <a href="https://pyt...
1,498
{'text': ['You can create a Compose of augmentations and then use it in the training loop itslelf.\n\naug = Compose(&lt;the list of augmentations&gt;)\n\nfor x,y in dataloader:\n\nx_aug = aug(x)\n\nI think this might do the trick.'], 'answer_start': [1498]}
ImageFolder return
Hi everyone second post here! I got this error TypeError: linear(): argument &#39;input&#39; (position 1) must be Tensor, not int This is my code - it runs pretty slow import torch import torch.nn as nn import torchvision import torchvision.transforms as transforms from torch.utils.data import DataLoade&hellip;
0
2021-05-10T23:12:15.987Z
General advice, look at the docs! This will answer most of your questions. For example, <a href="https://pytorch.org/vision/stable/transforms.html#torchvision.transforms.Resize" rel="noopener nofollow ugc">here</a>, it says that if you pass in a single parameter, it will resize the shortest side of the image to that (a...
0
2021-05-11T06:29:22.549Z
https://discuss.pytorch.org/t/imagefolder-return/120886/12
You can create a Compose of augmentations and then use it in the training loop itslelf. aug = Compose(&lt;the list of augmentations&gt;) for x,y in dataloader: x_aug = aug(x) I think this might do the trick. General advice, look at the docs! This will answer most of your questions. For example, <a href="https://pyt...
961
{'text': ['General advice, look at the docs! This will answer most of your questions. For example, <a href="https://pytorch.org/vision/stable/transforms.html#torchvision.transforms.Resize" rel="noopener nofollow ugc">here</a>, it says that if you pass in a single parameter, it will resize the shortest side of the image...
Extract features from CNN
Hello everyone, I’m doing a research project and I have a CNN model already trained. Now I want to extract features from this CNN to apply conventional Machine Learning algorithms. I have saved the CNN: torch.save(model.state_dict(), &#39;./cnn.pth&#39;) Now, how do I extract features from this model, to&hellip;
0
2021-01-04T23:14:38.620Z
Let’s assume that your CNN class looks like this: class CNN(nn.Module): def __init__(self, *args, **kwargs): super(CNN, self).__init__() self.feature_extractor = ... # CNN layers or whatever self.classifier = .... # Linear layers def forward(self, x): x&hellip;
1
2021-01-07T00:54:19.412Z
https://discuss.pytorch.org/t/extract-features-from-cnn/107931/4
You can create a Compose of augmentations and then use it in the training loop itslelf. aug = Compose(&lt;the list of augmentations&gt;) for x,y in dataloader: x_aug = aug(x) I think this might do the trick. General advice, look at the docs! This will answer most of your questions. For example, <a href="https://pyt...
643
{'text': ['Let’s assume that your CNN class looks like this:\n\nclass CNN(nn.Module):\n\ndef __init__(self, *args, **kwargs):\n\nsuper(CNN, self).__init__()\n\nself.feature_extractor = ... # CNN layers or whatever\n\nself.classifier = .... # Linear layers\n\ndef forward(self, x):\n\nx&hellip;'], 'answer_start': [643]}
TF-Keras to PyTorch Model conversion target and input size mismatch
I’m trying to convert a TensorFlow-Keras model to PyTorch, and encountered the following error: Traceback (most recent call last): File &quot;model.py&quot;, line 480, in &lt;module&gt; train_loop(model, device, train_dataloader, val_dataloader, optimizer, scheduler, model_name, epochs) File &quot;model.py&quot;, l...
0
2022-01-24T07:03:17.163Z
I guess the “reduction” in the temporal dimension is missing in your model or alternatively you could only use the last time step from the LSTM output. Currently your model is returning logits for a sequence, which doesn’t fit the target.
0
2022-01-26T05:02:10.886Z
https://discuss.pytorch.org/t/tf-keras-to-pytorch-model-conversion-target-and-input-size-mismatch/142379/6
I guess the “reduction” in the temporal dimension is missing in your model or alternatively you could only use the last time step from the LSTM output. Currently your model is returning logits for a sequence, which doesn’t fit the target. Hi, I’m afraid the softplus function only accepts a single beta value. But you c...
1,822
{'text': ['I guess the “reduction” in the temporal dimension is missing in your model or alternatively you could only use the last time step from the LSTM output. Currently your model is returning logits for a sequence, which doesn’t fit the target.'], 'answer_start': [1822]}
Efficiently applying per neuron activation functions
I want to use a custom activation function that has a random component that gets applied to every neuron individually. If I use the standard method and call the activation function on a layer, it applies the same value to every neuron in that layer. I am looking for the most efficient way to have &hellip;
0
2020-08-20T23:33:31.817Z
Hi, I’m afraid the softplus function only accepts a single beta value. But you can just re-implement it batch_size = x.size(0) # Generate one beta per sample beta = torch.empty(batch_size).uniform_(self.beta_lower, self.beta_higher) softplus = ((beta * x).exp() + 1).log() / beta res = x * torch.ta&hellip;
0
2020-08-21T00:14:20.129Z
https://discuss.pytorch.org/t/efficiently-applying-per-neuron-activation-functions/93550/6
I guess the “reduction” in the temporal dimension is missing in your model or alternatively you could only use the last time step from the LSTM output. Currently your model is returning logits for a sequence, which doesn’t fit the target. Hi, I’m afraid the softplus function only accepts a single beta value. But you c...
1,150
{'text': ['Hi,\n\nI’m afraid the softplus function only accepts a single beta value. But you can just re-implement it\n\nbatch_size = x.size(0)\n\n# Generate one beta per sample\n\nbeta = torch.empty(batch_size).uniform_(self.beta_lower, self.beta_higher)\n\nsoftplus = ((beta * x).exp() + 1).log() / beta\n\nres = x * t...
How to do in-place indexing?
Hi, I wonder if there is any method to do in-place indexing to “crop” the tensor without extra memory cost. For example, I have a tensor x = torch.rand(2,3,4, device=“cuda”), when we index x = x[:,:,0::2], in my opinion, we only return a view of the original data, and the memory cost is still O(2x3&hellip;
0
2021-11-09T16:33:48.119Z
well, let’s see… you want to compact a dimension in the middle, I’ll simplify this to dims representing (B*C,T,H*W) and sizes 2,4,3 x = torch.zeros(2,4,3) x[:,::2].copy_(torch.arange(12).view(2,2,3)) #values we want to extract y = x.view(2*4,3)[:4] #compact and truncated area to copy into y.co&hellip;
1
2021-11-13T00:39:56.261Z
https://discuss.pytorch.org/t/how-to-do-in-place-indexing/136406/8
I guess the “reduction” in the temporal dimension is missing in your model or alternatively you could only use the last time step from the LSTM output. Currently your model is returning logits for a sequence, which doesn’t fit the target. Hi, I’m afraid the softplus function only accepts a single beta value. But you c...
552
{'text': ['well, let’s see…\n\nyou want to compact a dimension in the middle, I’ll simplify this to dims representing (B*C,T,H*W) and sizes 2,4,3\n\nx = torch.zeros(2,4,3)\n\nx[:,::2].copy_(torch.arange(12).view(2,2,3)) #values we want to extract\n\ny = x.view(2*4,3)[:4] #compact and truncated area to copy into\n\ny.co...
Handling "Nones" in multilabel classification
I’m working on a multilabel classification problem. In my current version, I have four potential labels: “Hospitalized”, “Intubated”, “Deceased”, and “Pneumonia”. My model trains well and has provided some interesting insights on cases with at least one label, but none of my post-training analyses&hellip;
0
2020-09-17T16:53:23.758Z
Hi Sam! [image] shartzog: I’m working on a multilabel classification problem. I have four potential labels: “Hospitalized”, “Intubated”, “Deceased”, and “Pneumonia”. … Is adding in the 5th “None” label prior to training the right way forward? You do not need (or want) a “None” label. Th&hellip;
2
2020-09-17T21:41:59.036Z
https://discuss.pytorch.org/t/handling-nones-in-multilabel-classification/96647/2
Hi Sam! [image] shartzog: I’m working on a multilabel classification problem. I have four potential labels: “Hospitalized”, “Intubated”, “Deceased”, and “Pneumonia”. … Is adding in the 5th “None” label prior to training the right way forward? You do not need (or want) a “None” label. Th&hellip; Kinda, except it ...
1,718
{'text': ['Hi Sam!\n\n[image] shartzog:\n\nI’m working on a multilabel classification problem. I have four potential labels: “Hospitalized”, “Intubated”, “Deceased”, and “Pneumonia”.\n\n…\n\nIs adding in the 5th “None” label prior to training the right way forward?\n\nYou do not need (or want) a “None” label. Th&hell...
Customizing torch.autograd.Function
Hi there, hope all of you are fine. I am working on VQGAN+CLIP, and there they are doing this operation: class ReplaceGrad(torch.autograd.Function): @staticmethod def forward(ctx, x_forward, x_backward): ctx.shape = x_backward.shape return x_forward @staticmethod d&hellip;
0
2022-02-03T06:47:45.846Z
Kinda, except it has some methods of its own (more info <a href="https://discuss.pytorch.org/t/customizing-torch-autograd-function/143161/7">here</a>)
1
2022-02-04T18:08:48.772Z
https://discuss.pytorch.org/t/customizing-torch-autograd-function/143161/10
Hi Sam! [image] shartzog: I’m working on a multilabel classification problem. I have four potential labels: “Hospitalized”, “Intubated”, “Deceased”, and “Pneumonia”. … Is adding in the 5th “None” label prior to training the right way forward? You do not need (or want) a “None” label. Th&hellip; Kinda, except it ...
1,162
{'text': ['Kinda, except it has some methods of its own (more info <a href="https://discuss.pytorch.org/t/customizing-torch-autograd-function/143161/7">here</a>)'], 'answer_start': [1162]}
How pytorch simulates bias during quantization aware training
It seems that pytorch qat doesn’t simulate bias quantization error during qat. And I found that qat.Conv2d only fake-quantize weight and activation. So pytorch’s quantization strategy does not quantize the bias, right?
0
2020-09-24T12:57:47.119Z
We find modeling bias in qat is not very important since it doesn’t affect accuracy too much. one workaround you can do is to remove bias from Conv and add the bias explicitly outside of conv, so that adding bias can be modeled with add.
1
2020-10-15T18:04:32.795Z
https://discuss.pytorch.org/t/how-pytorch-simulates-bias-during-quantization-aware-training/97368/7
Hi Sam! [image] shartzog: I’m working on a multilabel classification problem. I have four potential labels: “Hospitalized”, “Intubated”, “Deceased”, and “Pneumonia”. … Is adding in the 5th “None” label prior to training the right way forward? You do not need (or want) a “None” label. Th&hellip; Kinda, except it ...
454
{'text': ['We find modeling bias in qat is not very important since it doesn’t affect accuracy too much. one workaround you can do is to remove bias from Conv and add the bias explicitly outside of conv, so that adding bias can be modeled with add.'], 'answer_start': [454]}
Exception in BCECriterion.cu:42
Is someone aware of this exception? Raised after 70th epoch (it does not depend on epoch… did it again and got the exception after 40th epoch) Train Epoch: 70 [0/6742 (0%)] Loss: -431231.800000 /opt/conda/conda-bld/pytorch_1579022060824/work/aten/src/THCUNN/BCECriterion.cu:42: Acctype bce_functor&lt;&hellip;
0
2020-04-14T15:05:37.355Z
(btw) I tried the same execution with smaller learning rates 1e-4/1e-5/1e-6 over 150 iterations and didn’t get any errors. Still waiting for help regarding this issue. (my replicated post in github <a href="https://github.com/pytorch/pytorch/issues/36647" rel="nofollow noopener">https://github.com/pytorch/pytorch/iss...
0
2020-04-15T21:01:20.506Z
https://discuss.pytorch.org/t/exception-in-bcecriterion-cu-42/76739/10
(btw) I tried the same execution with smaller learning rates 1e-4/1e-5/1e-6 over 150 iterations and didn’t get any errors. Still waiting for help regarding this issue. (my replicated post in github <a href="https://github.com/pytorch/pytorch/issues/36647" rel="nofollow noopener">https://github.com/pytorch/pytorch/iss...
1,382
{'text': ['(btw) I tried the same execution with smaller learning rates 1e-4/1e-5/1e-6 over 150 iterations and didn’t get any errors.\n\nStill waiting for help regarding this issue.\n\n(my replicated post in github <a href="https://github.com/pytorch/pytorch/issues/36647" rel="nofollow noopener">https://github.com/pyto...
How to fix: 'can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.'
Hi guys, I’m trying to make a plot and I get this error, here’s a summary of my code: ### Visualize x_arr = np.arange(len(model_sum[0])) + 1 fig = plt.figure(figsize=(12, 4)) ax = fig.add_subplot(1, 2, 1) ax.plot(x_arr, model_sum[0], &#39;-o&#39;, label=&#39;Train Loss&#39;) ax.plot(x_arr, model_sum[1], &#39;--&...
0
2022-08-20T21:46:26.168Z
So give this a go, and see if it solves your problem. [image] AlphaBetaGamma96: accuracy_hist_valid[epoch] += is_correct.sum().item() Can you do the same for accuracy_hist_train too? You currently have a list of Tensors on the GPU whereas matplotlib will require a list of scalars on the CPU. &hellip;
0
2022-08-21T15:22:41.889Z
https://discuss.pytorch.org/t/how-to-fix-cant-convert-cuda-0-device-type-tensor-to-numpy-use-tensor-cpu-to-copy-the-tensor-to-host-memory-first/159656/14
(btw) I tried the same execution with smaller learning rates 1e-4/1e-5/1e-6 over 150 iterations and didn’t get any errors. Still waiting for help regarding this issue. (my replicated post in github <a href="https://github.com/pytorch/pytorch/issues/36647" rel="nofollow noopener">https://github.com/pytorch/pytorch/iss...
1,026
{'text': ['So give this a go, and see if it solves your problem.\n\n[image] AlphaBetaGamma96:\n\naccuracy_hist_valid[epoch] += is_correct.sum().item()\n\nCan you do the same for accuracy_hist_train too?\n\nYou currently have a list of Tensors on the GPU whereas matplotlib will require a list of scalars on the CPU.\n\n&...
Cuda out of memory occurs while I have enough cuda memory
I am training my models(pretrained resnet and densenet) in rtx 2080ti, it works well. When I move the models to rtx a6000(i need lager batch size)the bug occurs, about 4.5GB is allocated and nearly 40GB is free! I have no idea about this bug, anything could help thank you very much.
0
2021-08-07T03:37:40.863Z
Thanks for the update to the code. I cannot reproduce the issue on an A6000 and the script runs fine for a few epochs: root@dc9def623dde:/workspace/src/OOM-occurs-while-I-have-enough-cuda-memory# python run2.py Namespace(base_path=&#39;/data/guest1/clothing1m/&#39;, batch_size=64, cuda_device=0, img_size&hellip;
0
2021-08-19T08:19:57.902Z
https://discuss.pytorch.org/t/cuda-out-of-memory-occurs-while-i-have-enough-cuda-memory/128806/14
(btw) I tried the same execution with smaller learning rates 1e-4/1e-5/1e-6 over 150 iterations and didn’t get any errors. Still waiting for help regarding this issue. (my replicated post in github <a href="https://github.com/pytorch/pytorch/issues/36647" rel="nofollow noopener">https://github.com/pytorch/pytorch/iss...
642
{'text': ['Thanks for the update to the code.\n\nI cannot reproduce the issue on an A6000 and the script runs fine for a few epochs:\n\nroot@dc9def623dde:/workspace/src/OOM-occurs-while-I-have-enough-cuda-memory# python run2.py\n\nNamespace(base_path=&#39;/data/guest1/clothing1m/&#39;, batch_size=64, cuda_device=0, img...
ConvTranspose1d extremely slow on GPU (T4), slower than CPU
Hi, I’m confused that torch.nn.ConvTranspose1d is extremely slow when running on GPU, even slower than CPU. Code to reproduce: $ cat test_trans_conv.py import torch x = torch.randn(1, 64, 40000) if torch.cuda.is_available(): x = x.cuda() trans_conv = torch.nn.ConvTranspose1d(64, 32, kernel_s&hellip;
0
2020-07-13T10:47:24.061Z
[image] swpd: Is there a way we can explicitly tell cudnn to select a faster kernel instead of the bad one? No, there is no user facing API to do so. [image] swpd: Have you tried this script on cudnn8 without setting torch.backends.cudnn.benchmark = True ? Yes, ran it with the default&hellip;
0
2020-07-15T05:16:04.476Z
https://discuss.pytorch.org/t/convtranspose1d-extremely-slow-on-gpu-t4-slower-than-cpu/88977/7
[image] swpd: Is there a way we can explicitly tell cudnn to select a faster kernel instead of the bad one? No, there is no user facing API to do so. [image] swpd: Have you tried this script on cudnn8 without setting torch.backends.cudnn.benchmark = True ? Yes, ran it with the default&hellip; I still find that the...
1,916
{'text': ['[image] swpd:\n\nIs there a way we can explicitly tell cudnn to select a faster kernel instead of the bad one?\n\nNo, there is no user facing API to do so.\n\n[image] swpd:\n\nHave you tried this script on cudnn8 without setting torch.backends.cudnn.benchmark = True ?\n\nYes, ran it with the default&hellip;'...
Why libtorch cannot get 'running_mean' and 'running_var' of BatchNormalization2D in .pt file?
I’ve found that the result of libtorch is very different from pytorch result. I save my model as .pt file using pytorch and load by libtorch, and all parameters are successfully copied which I double checked by loading it by pytorch again. After checking the module.parameter() in libtorch, I’ve fo&hellip;
0
2020-06-26T13:42:06.358Z
I still find that the output is very different since I’ve checked element sum of output feature maps are different each other (for c++ 180000 and for python 90000). But due to the project deadline, I priorly translate other modules of the entire model. I should use a constant input as you advice an&hellip;
0
2020-07-01T00:53:44.851Z
https://discuss.pytorch.org/t/why-libtorch-cannot-get-running-mean-and-running-var-of-batchnormalization2d-in-pt-file/87023/10
[image] swpd: Is there a way we can explicitly tell cudnn to select a faster kernel instead of the bad one? No, there is no user facing API to do so. [image] swpd: Have you tried this script on cudnn8 without setting torch.backends.cudnn.benchmark = True ? Yes, ran it with the default&hellip; I still find that the...
1,257
{'text': ['I still find that the output is very different since I’ve checked element sum of output feature maps are different each other (for c++ 180000 and for python 90000). But due to the project deadline, I priorly translate other modules of the entire model.\n\nI should use a constant input as you advice an&hellip...
Get different scores in different machine with the same torch version
<a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/4/b/4b703e6d20b4c270db350241111b9f8f08353b31.png" data-download-href="https://discuss.pytorch.org/uploads/default/4b703e6d20b4c270db350241111b9f8f08353b31" title="Screen_Shot_2021-05-11_at_3_25_37_PM">[Screen_Shot_2021-05-11_at_3_25_37_PM...
1
2021-05-11T07:30:41.701Z
Interesting, both CPUs have avx2 support and I’m not sure if PyTorch has any avx512 capabilities upstreamed (or in 1.6.0, for that matter). Can you try to see if using double precision initially is a usable workaround? a = torch.ones(512, 512, dtype=torch.float64)
0
2021-05-12T02:13:05.458Z
https://discuss.pytorch.org/t/get-different-scores-in-different-machine-with-the-same-torch-version/120907/4
[image] swpd: Is there a way we can explicitly tell cudnn to select a faster kernel instead of the bad one? No, there is no user facing API to do so. [image] swpd: Have you tried this script on cudnn8 without setting torch.backends.cudnn.benchmark = True ? Yes, ran it with the default&hellip; I still find that the...
608
{'text': ['Interesting, both CPUs have avx2 support and I’m not sure if PyTorch has any avx512 capabilities upstreamed (or in 1.6.0, for that matter). Can you try to see if using double precision initially is a usable workaround? a = torch.ones(512, 512, dtype=torch.float64)'], 'answer_start': [608]}
Error when running LBFGS to solve a non-linear inverse problem
This is my first time in these forums. Hence, please let me know if I could describe my issue with more clarity. I am only running on CPU right now, but will move on to powerful GPUs once I get it to work on CPU. I am using pytorch 1.6.0. My intention is to use LBFGS in PyTorch to iteratively solve&hellip;
0
2020-10-19T18:25:57.457Z
Thanks for the code. self.rec = torch.nn.Parameter(torch.from_numpy(init)) is creating a tensor, which is not contiguous due to the moveaxis operation on the numpy array. Use: self.rec = torch.nn.Parameter(torch.from_numpy(init).contiguous()) and the code should work. You can add code snippets &hellip;
0
2020-10-20T19:41:50.504Z
https://discuss.pytorch.org/t/error-when-running-lbfgs-to-solve-a-non-linear-inverse-problem/99911/4
Thanks for the code. self.rec = torch.nn.Parameter(torch.from_numpy(init)) is creating a tensor, which is not contiguous due to the moveaxis operation on the numpy array. Use: self.rec = torch.nn.Parameter(torch.from_numpy(init).contiguous()) and the code should work. You can add code snippets &hellip; Based on yo...
1,744
{'text': ['Thanks for the code.\n\nself.rec = torch.nn.Parameter(torch.from_numpy(init)) is creating a tensor, which is not contiguous due to the moveaxis operation on the numpy array.\n\nUse:\n\nself.rec = torch.nn.Parameter(torch.from_numpy(init).contiguous())\n\nand the code should work.\n\nYou can add code snippets...
AlexNet With ImageNet Testing
This is probably a human error but i would like to note down accuracy of AlexNet with already trained networks and then replace conv layers with my custom layers and note down results again. I can find AlexNet and pre_trained weights here <a href="https://pytorch.org/docs/stable/_modules/torchvision/models/alexnet.htm...
0
2020-01-28T04:18:39.912Z
Based on your code it looks like you are using ImageFolder on your validation directory, which seem to contain only the images without any subfolders. ImageFolder creates the targets based on subfolders, so your current Datasets might contains only a single class label. Could you check that?
0
2020-01-28T05:28:32.731Z
https://discuss.pytorch.org/t/alexnet-with-imagenet-testing/67853/6
Thanks for the code. self.rec = torch.nn.Parameter(torch.from_numpy(init)) is creating a tensor, which is not contiguous due to the moveaxis operation on the numpy array. Use: self.rec = torch.nn.Parameter(torch.from_numpy(init).contiguous()) and the code should work. You can add code snippets &hellip; Based on yo...
1,181
{'text': ['Based on your code it looks like you are using ImageFolder on your validation directory, which seem to contain only the images without any subfolders.\n\nImageFolder creates the targets based on subfolders, so your current Datasets might contains only a single class label. Could you check that?'], 'answer_st...
Iterate Folder that contains Images
Hi guys , Im new to pytorch I want to load my data from a folder that contains 9 images, but I can’t view my 9 images, I only managed to view 1 single image which changes each time when I compile my program class Data_set_Papy(Dataset): def __init__(self , csv_file ,root_directory_image , tra&hellip;
0
2022-05-19T09:38:44.679Z
In your output it says “Number of samples: 8” indicating you only have 8 images. So it seems like your dataset actually has 8 images, not 9 as you said previously. You can display them more nicely using plt.subplots(nrows=2, ncols=4) and then plt.gcf().set_size_inches(12, 6) now that you know they’r&hellip;
1
2022-05-19T13:48:07.794Z
https://discuss.pytorch.org/t/iterate-folder-that-contains-images/152090/15
Thanks for the code. self.rec = torch.nn.Parameter(torch.from_numpy(init)) is creating a tensor, which is not contiguous due to the moveaxis operation on the numpy array. Use: self.rec = torch.nn.Parameter(torch.from_numpy(init).contiguous()) and the code should work. You can add code snippets &hellip; Based on yo...
603
{'text': ['In your output it says “Number of samples: 8” indicating you only have 8 images. So it seems like your dataset actually has 8 images, not 9 as you said previously. You can display them more nicely using plt.subplots(nrows=2, ncols=4) and then plt.gcf().set_size_inches(12, 6) now that you know they’r&hellip;'...
RuntimeError: mat1 and mat2 shapes cannot be multiplied in regression neural network
I am trying to use a neural network to do regression on a large 5D dataset, however to try and get a working neural network first i have setup a random set of data points to try with. However I am running into this error and I am not sure why. Error Code: predicted = model(data.to(device)) File “&hellip;
0
2022-01-25T13:23:22.592Z
MSE takes inputs of float type. data = data.unsqueeze(1).type(torch.float) expected = expected.unsqueeze(1).type(torch.float) Then move them to GPU by .to(device)
1
2022-01-26T05:49:12.202Z
https://discuss.pytorch.org/t/runtimeerror-mat1-and-mat2-shapes-cannot-be-multiplied-in-regression-neural-network/142509/8
MSE takes inputs of float type. data = data.unsqueeze(1).type(torch.float) expected = expected.unsqueeze(1).type(torch.float) Then move them to GPU by .to(device) (FYI, unrelated to memory usage, you don’t need to set a manual SCALER value. <a href="https://pytorch.org/docs/stable/amp.html#gradient-scaling" rel="noo...
1,822
{'text': ['MSE takes inputs of float type.\n\ndata = data.unsqueeze(1).type(torch.float)\n\nexpected = expected.unsqueeze(1).type(torch.float)\n\nThen move them to GPU by .to(device)'], 'answer_start': [1822]}
Mixed precision increases memory in meta-learning?
In meta-learning you want to differentiate through (inner) gradient updates themselves, for example to get the (outer) gradient of the validation loss wrt some hyperparameter. I had issues with my outer gradients being nan in mixed precision (regardless of the loss scaler value) so I made a toy exa&hellip;
0
2021-03-22T17:18:34.067Z
(FYI, unrelated to memory usage, you don’t need to set a manual SCALER value. <a href="https://pytorch.org/docs/stable/amp.html#gradient-scaling" rel="noopener nofollow ugc">torch.cuda.amp.GradScaler</a> automatically and dynamically chooses the scale factor. You probably know that, but you may not know it can be used ...
3
2021-03-26T22:41:31.294Z
https://discuss.pytorch.org/t/mixed-precision-increases-memory-in-meta-learning/115608/10
MSE takes inputs of float type. data = data.unsqueeze(1).type(torch.float) expected = expected.unsqueeze(1).type(torch.float) Then move them to GPU by .to(device) (FYI, unrelated to memory usage, you don’t need to set a manual SCALER value. <a href="https://pytorch.org/docs/stable/amp.html#gradient-scaling" rel="noo...
1,077
{'text': ['(FYI, unrelated to memory usage, you don’t need to set a manual SCALER value. <a href="https://pytorch.org/docs/stable/amp.html#gradient-scaling" rel="noopener nofollow ugc">torch.cuda.amp.GradScaler</a> automatically and dynamically chooses the scale factor. You probably know that, but you may not know it c...
[Nightly] Packed params no longer returned via state_dict() method
Hi, I’ve installed the nightly build 1.6.0.dev20200607 today and ran my scripts that exercises quantization and jit. Until v1.5, I was able to get all packed params of a top level quantized module, say quantized resnet in torchvision, via state_dict() method. But now with nightly, I only get quant.&hellip;
0
2020-06-08T04:08:23.381Z
We (TVM) take jitted models as input, so we don’t get to see the original models. Fortunately, I found a workaround for this problem without the use of state_dict, so it is no longer a problem for us. Thanks.
1
2020-10-07T01:40:41.270Z
https://discuss.pytorch.org/t/nightly-packed-params-no-longer-returned-via-state-dict-method/84588/10
MSE takes inputs of float type. data = data.unsqueeze(1).type(torch.float) expected = expected.unsqueeze(1).type(torch.float) Then move them to GPU by .to(device) (FYI, unrelated to memory usage, you don’t need to set a manual SCALER value. <a href="https://pytorch.org/docs/stable/amp.html#gradient-scaling" rel="noo...
690
{'text': ['We (TVM) take jitted models as input, so we don’t get to see the original models. Fortunately, I found a workaround for this problem without the use of state_dict, so it is no longer a problem for us. Thanks.'], 'answer_start': [690]}
Access weights in RESTRICTED BOLTZMANN MACHINES
How to access weights
0
2020-07-22T15:37:57.045Z
Hy <a class="mention" href="/u/kunal_dapse">@Kunal_Dapse</a>, I would highly recommend you read some tutorials first, you’re totaly misunderstanding me here. The way we construct models in pytorch is by inheriting them through nn.Module class. Something like this import torch.nn as nn class Net(nn.Module): nn.Linea...
1
2020-07-25T15:21:02.753Z
https://discuss.pytorch.org/t/access-weights-in-restricted-boltzmann-machines/90154/8
Hy <a class="mention" href="/u/kunal_dapse">@Kunal_Dapse</a>, I would highly recommend you read some tutorials first, you’re totaly misunderstanding me here. The way we construct models in pytorch is by inheriting them through nn.Module class. Something like this import torch.nn as nn class Net(nn.Module): nn.Linea...
1,796
{'text': ['Hy <a class="mention" href="/u/kunal_dapse">@Kunal_Dapse</a>, I would highly recommend you read some tutorials first, you’re totaly misunderstanding me here. The way we construct models in pytorch is by inheriting them through nn.Module class.\n\nSomething like this\n\nimport torch.nn as nn\n\nclass Net(nn.M...
100x more time cost of DCGAN Hessian vector product
I found a weird computation cost when I was trying to compute Hessian vector product of DCGAN. The Hessian vector product for DCGAN costs 100x more than the other GAN , even though it contains less parameters. I’m confused because the problem seems not caused by one single module since the other &hellip;
0
2019-09-18T07:25:16.386Z
The solution is simple, use torch.backends.cudnn.benchmark=True. cudnn heuristics picks truly atrocious algorithm for couple layers (one of the kernels takes 600 ms, another 50 ms). When cudnn is actually forced to benchmark and pick the best algo, the hessian computation speed becomes reasonable.
2
2019-09-24T02:25:03.674Z
https://discuss.pytorch.org/t/100x-more-time-cost-of-dcgan-hessian-vector-product/56240/16
Hy <a class="mention" href="/u/kunal_dapse">@Kunal_Dapse</a>, I would highly recommend you read some tutorials first, you’re totaly misunderstanding me here. The way we construct models in pytorch is by inheriting them through nn.Module class. Something like this import torch.nn as nn class Net(nn.Module): nn.Linea...
1,247
{'text': ['The solution is simple, use torch.backends.cudnn.benchmark=True. cudnn heuristics picks truly atrocious algorithm for couple layers (one of the kernels takes 600 ms, another 50 ms). When cudnn is actually forced to benchmark and pick the best algo, the hessian computation speed becomes reasonable.'], 'answer...
CNN 1d: size mismatch, m1: [64 x 8], m2: [384 x 192]
Hi, I am using CNN 1d for my example and my data contain 12 columns and 36795 rows, Note: it is not an image it is data recorded from signals. and I am facing this error I don’t understand the problem what exactly means. Could you explain that and suggest a solution for me.? Thank you in advance. &hellip;
0
2020-02-03T13:25:34.833Z
So if each sensor provide different info you will have a Bx12xT input. You have to find the proper T depending on the sampling rate of each sensor. This is, how many elements of each signal do you want to input to the network. You can pass the entire signal, you can cut the signal int N elements et&hellip;
0
2020-02-03T16:28:18.403Z
https://discuss.pytorch.org/t/cnn-1d-size-mismatch-m1-64-x-8-m2-384-x-192/68518/8
Hy <a class="mention" href="/u/kunal_dapse">@Kunal_Dapse</a>, I would highly recommend you read some tutorials first, you’re totaly misunderstanding me here. The way we construct models in pytorch is by inheriting them through nn.Module class. Something like this import torch.nn as nn class Net(nn.Module): nn.Linea...
648
{'text': ['So if each sensor provide different info you will have a Bx12xT input.\n\nYou have to find the proper T depending on the sampling rate of each sensor. This is, how many elements of each signal do you want to input to the network. You can pass the entire signal, you can cut the signal int N elements et&hellip...
Problem with dimensions
I want to build a neural network classifier for binary class. trainset.shape = (41712, 231) testset.shape = (10429, 231) It outputs: ValueError Traceback (most recent call last) in () 10 running_loss = 0 11 —&gt; 12 for inputs, labels in trainloader: 13 &hellip;
0
2018-12-26T22:24:40.140Z
You don’t need to use torch.exp, if you’ve used F.sigmoid in your model. Also, you should use a threshold on the probabilities to get the corresponding class, e.g. 0.5. tensor.topk will return a zero tensor in your current setup.
1
2018-12-28T16:01:36.074Z
https://discuss.pytorch.org/t/problem-with-dimensions/33123/11
You don’t need to use torch.exp, if you’ve used F.sigmoid in your model. Also, you should use a threshold on the probabilities to get the corresponding class, e.g. 0.5. tensor.topk will return a zero tensor in your current setup. You usually call init_hidden() or detach() after each batch. Yes, without init_hidden()...
1,912
{'text': ['You don’t need to use torch.exp, if you’ve used F.sigmoid in your model.\n\nAlso, you should use a threshold on the probabilities to get the corresponding class, e.g. 0.5.\n\ntensor.topk will return a zero tensor in your current setup.'], 'answer_start': [1912]}
RNN many-to-One query
Hi I am pretty much new too pytorch and try to do sentimental analysis. My Input data is array([[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 8] [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1], [ 0, 0, 0, 0, 0, 0, 9, 5, 1, 6, 7], [ 0, 0, 0, 0, 9, 5, 1, 6, 7, 16, 17], [ 0, 0, 0, 0&hellip;
0
2020-03-07T00:18:35.554Z
You usually call init_hidden() or detach() after each batch. Yes, without init_hidden(), you given the last hidden state of the previous batch as first hidden state for the current batch. However, detach() ensures that the hidden state is a constant and the loss is not backpropagated to the previou&hellip;
1
2020-03-10T03:07:28.058Z
https://discuss.pytorch.org/t/rnn-many-to-one-query/72353/12
You don’t need to use torch.exp, if you’ve used F.sigmoid in your model. Also, you should use a threshold on the probabilities to get the corresponding class, e.g. 0.5. tensor.topk will return a zero tensor in your current setup. You usually call init_hidden() or detach() after each batch. Yes, without init_hidden()...
1,188
{'text': ['You usually call init_hidden() or detach() after each batch.\n\nYes, without init_hidden(), you given the last hidden state of the previous batch as first hidden state for the current batch. However, detach() ensures that the hidden state is a constant and the loss is not backpropagated to the previou&hellip...
Problem with training FCN for segmentation of multi-channel data
Hello dear programmers, I am very new to Pytorch with basic programming skills. My task consists of performing segmentation of seismic data. My training data consists of 9 channels and the labels are of one channel. I have managed to build up a network. However, it can not train and it shows the fo&hellip;
0
2020-02-17T01:47:13.562Z
Try to remove the numpy call for label_pred and label_true and pass the tensors to get_accuracy.
0
2020-02-17T06:44:09.330Z
https://discuss.pytorch.org/t/problem-with-training-fcn-for-segmentation-of-multi-channel-data/69982/10
You don’t need to use torch.exp, if you’ve used F.sigmoid in your model. Also, you should use a threshold on the probabilities to get the corresponding class, e.g. 0.5. tensor.topk will return a zero tensor in your current setup. You usually call init_hidden() or detach() after each batch. Yes, without init_hidden()...
541
{'text': ['Try to remove the numpy call for label_pred and label_true and pass the tensors to get_accuracy.'], 'answer_start': [541]}
How do I average photo feature outputs for later concatenation?
Hello. I have the following model schema where one set of photos go through an encoder, another set of photos go through an encoder and both get concatenated with a tabular data set for a final model to predict a binary target. How do I average the features of the image encoders? I want to average&hellip;
0
2019-11-01T16:50:56.836Z
Hi, You have a <a href="https://pytorch.org/docs/stable/tensors.html?highlight=tolist#torch.Tensor.tolist" rel="nofollow noopener">tolist()</a> method on tensors to do that
0
2019-11-04T19:10:53.223Z
https://discuss.pytorch.org/t/how-do-i-average-photo-feature-outputs-for-later-concatenation/59792/15
Hi, You have a <a href="https://pytorch.org/docs/stable/tensors.html?highlight=tolist#torch.Tensor.tolist" rel="nofollow noopener">tolist()</a> method on tensors to do that Hi, When using batchnorm in training mode, the running stats are always updated yes. You should be using the eval mode to use these stats and st...
1,274
{'text': ['Hi,\n\nYou have a <a href="https://pytorch.org/docs/stable/tensors.html?highlight=tolist#torch.Tensor.tolist" rel="nofollow noopener">tolist()</a> method on tensors to do that'], 'answer_start': [1274]}
Running mean and running stats
I have observed that batch normalization parameters such as running mean and running stats get update after we do the forward pass through the model ( as in just after we do output=model(input) ). So when we train the model and do the evaluation after every epoch is it recommended to put the model &hellip;
0
2021-03-22T06:26:52.232Z
Hi, When using batchnorm in training mode, the running stats are always updated yes. You should be using the eval mode to use these stats and stop updating them when evaluating indeed.
1
2021-03-22T17:59:23.833Z
https://discuss.pytorch.org/t/running-mean-and-running-stats/115554/2
Hi, You have a <a href="https://pytorch.org/docs/stable/tensors.html?highlight=tolist#torch.Tensor.tolist" rel="nofollow noopener">tolist()</a> method on tensors to do that Hi, When using batchnorm in training mode, the running stats are always updated yes. You should be using the eval mode to use these stats and st...
811
{'text': ['Hi,\n\nWhen using batchnorm in training mode, the running stats are always updated yes.\n\nYou should be using the eval mode to use these stats and stop updating them when evaluating indeed.'], 'answer_start': [811]}
When I train my network, The same number appears periodically on my my training acc , I don't konow the error come from
this is my train.py I use crosssentropy loss for my network , outputs size is [4,2,224,224] where 4 means batchsize, 2 means channels, 224 means h and w .output_c1 size is [4,224,224] ,labels size is [4,224,224] too. import torch import torch.nn as nn import torch.nn.functional as F from torch.au&hellip;
0
2020-03-24T13:12:27.603Z
Hello fyy! [image] fyy: <a class="mention" href="/u/kfrank">@KFrank</a>, I try to use U-net model to perform medical image segmentation At this point, the best I can offer you is some general advice. First: Independent of u-net or pytorch or machine learning, you need to understand the problem you are trying to ...
0
2020-03-26T13:47:45.214Z
https://discuss.pytorch.org/t/when-i-train-my-network-the-same-number-appears-periodically-on-my-my-training-acc-i-dont-konow-the-error-come-from/74237/10
Hi, You have a <a href="https://pytorch.org/docs/stable/tensors.html?highlight=tolist#torch.Tensor.tolist" rel="nofollow noopener">tolist()</a> method on tensors to do that Hi, When using batchnorm in training mode, the running stats are always updated yes. You should be using the eval mode to use these stats and st...
361
{'text': ['Hello fyy!\n\n[image] fyy:\n\n<a class="mention" href="/u/kfrank">@KFrank</a>,\n\nI try to use U-net model to perform medical image segmentation\n\nAt this point, the best I can offer you is some general advice.\n\nFirst: Independent of u-net or pytorch or machine learning, you\n\nneed to understand the pro...
Zero'ing one input's gradient for Matrix Multiply
Hi! the @ operator, or matrix multiply, is stateless and accepts 2 input tensors. During the backprop, my understanding is that it’ll calculate two gradients w.r.t. the 2 input tensors, which will each update any variables via the chain rule along the paths that produce them, respectively. In my ex&hellip;
0
2022-01-12T07:40:46.429Z
Hey, I figured out how to do it with autograd.Function after reading through the pages. Let me know if it makes sense. class TwoOpGradientController(torch.autograd.Function): @staticmethod def forward(ctx, *args): ctx.args_0_shape = args[0].shape return args[0] @ args[1] &hellip;
0
2022-01-19T09:02:03.570Z
https://discuss.pytorch.org/t/zeroing-one-inputs-gradient-for-matrix-multiply/141457/10
Hey, I figured out how to do it with autograd.Function after reading through the pages. Let me know if it makes sense. class TwoOpGradientController(torch.autograd.Function): @staticmethod def forward(ctx, *args): ctx.args_0_shape = args[0].shape return args[0] @ args[1] &hellip; The loading behavior is not defin...
1,408
{'text': ['Hey, I figured out how to do it with autograd.Function after reading through the pages. Let me know if it makes sense.\n\nclass TwoOpGradientController(torch.autograd.Function):\n\n@staticmethod\n\ndef forward(ctx, *args):\n\nctx.args_0_shape = args[0].shape\n\nreturn args[0] @ args[1]\n\n&hellip;'], 'answer...
Error deploying torchserve: model load failed
Here is the dropbox link to the zip containing log file, model.py, handler.py etc. <a href="https://www.dropbox.com/s/gi8wmyxmpy1zx84/Files.zip?dl=0" rel="noopener nofollow ugc">https://www.dropbox.com/s/gi8wmyxmpy1zx84/Files.zip?dl=0</a> Model trained: <a class="lightbox" href="https://discuss.pytorch.org/uploads/d...
0
2021-03-15T15:34:00.304Z
The loading behavior is not defined by torchserve but by PyTorch depending how you’ve stored the state_dict. You could either push the model to the CPU before storing the state_dict or use the map_location argument as explained <a href="https://pytorch.org/tutorials/beginner/saving_loading_models.html#saving-loading-mo...
1
2021-03-16T06:54:54.130Z
https://discuss.pytorch.org/t/error-deploying-torchserve-model-load-failed/114875/11
Hey, I figured out how to do it with autograd.Function after reading through the pages. Let me know if it makes sense. class TwoOpGradientController(torch.autograd.Function): @staticmethod def forward(ctx, *args): ctx.args_0_shape = args[0].shape return args[0] @ args[1] &hellip; The loading behavior is not defin...
991
{'text': ['The loading behavior is not defined by torchserve but by PyTorch depending how you’ve stored the state_dict. You could either push the model to the CPU before storing the state_dict or use the map_location argument as explained <a href="https://pytorch.org/tutorials/beginner/saving_loading_models.html#saving...
How can I build an RNN without using nn.RNN
Hi , I need to build an RNN (without using nn.RNN) with following specifications : It should have set of weights [ It is a chanracter RNN. It should have 1 hidden layer Wxh (from input layer to hidden layer ) Whh (from the recurrent connection in the hidden layer) W ho (from hidde&hellip;
0
2018-04-23T15:51:04.336Z
Sure, then you would have to call F.log_softmax(output) before passing it to NLLLoss or add it as a layer in your model. CrossEntropyLoss basically combines a log_softmax with NLLLoss.
1
2018-04-24T13:42:28.118Z
https://discuss.pytorch.org/t/how-can-i-build-an-rnn-without-using-nn-rnn/16841/15
Hey, I figured out how to do it with autograd.Function after reading through the pages. Let me know if it makes sense. class TwoOpGradientController(torch.autograd.Function): @staticmethod def forward(ctx, *args): ctx.args_0_shape = args[0].shape return args[0] @ args[1] &hellip; The loading behavior is not defin...
637
{'text': ['Sure, then you would have to call F.log_softmax(output) before passing it to NLLLoss or add it as a layer in your model.\n\nCrossEntropyLoss basically combines a log_softmax with NLLLoss.'], 'answer_start': [637]}
How to implement an updating weighted MSE Loss?
Hello everyone! I’m new here. :grinning: I’m an undergraduate student doing my research project. I’m not a native English speaker, so apologies to my weird grammar. My research topic is about wind power prediction using an LSTM-NN and its application in the power trading. I used only the time-seri&hellip;
0
2022-09-11T06:29:08.598Z
The error is most likely raised by using a list for the price_label assuming these are the weights: def weighted_mse_loss(input, target, weight): return (weight * (input - target) ** 2) x = torch.randn(10, 10, requires_grad=True) y = torch.randn(10, 10) weight = torch.randn(10, 1).tolist() lo&hellip;
0
2022-09-13T04:18:10.212Z
https://discuss.pytorch.org/t/how-to-implement-an-updating-weighted-mse-loss/161137/7
The error is most likely raised by using a list for the price_label assuming these are the weights: def weighted_mse_loss(input, target, weight): return (weight * (input - target) ** 2) x = torch.randn(10, 10, requires_grad=True) y = torch.randn(10, 10) weight = torch.randn(10, 1).tolist() lo&hellip; Hi, I think...
1,644
{'text': ['The error is most likely raised by using a list for the price_label assuming these are the weights:\n\ndef weighted_mse_loss(input, target, weight):\n\nreturn (weight * (input - target) ** 2)\n\nx = torch.randn(10, 10, requires_grad=True)\n\ny = torch.randn(10, 10)\n\nweight = torch.randn(10, 1).tolist()\n\n...
My first model - can't make it work
Hi everyone, I’m just starting out with NNs and for my first NN written from scratch, I was gonna try to replicate the net in this tutorial <a href="https://pytorch.org/tutorials/intermediate/char_rnn_classification_tutorial" class="inline-onebox" rel="noopener nofollow ugc">NLP From Scratch: Classifying Names with a ...
0
2021-01-01T16:19:56.115Z
Hi, I think the issue is that you are loading your data using numpy and by default numpy uses float64 data type which is double in PyTorch. I think if you add name = name.astype(np.float32) label = label.astype(np.float32) Before returning an item, would solve the issue. [image] neuralpat: d&hellip;
0
2021-01-01T17:18:29.132Z
https://discuss.pytorch.org/t/my-first-model-cant-make-it-work/107666/2
The error is most likely raised by using a list for the price_label assuming these are the weights: def weighted_mse_loss(input, target, weight): return (weight * (input - target) ** 2) x = torch.randn(10, 10, requires_grad=True) y = torch.randn(10, 10) weight = torch.randn(10, 1).tolist() lo&hellip; Hi, I think...
1,130
{'text': ['Hi,\n\nI think the issue is that you are loading your data using numpy and by default numpy uses float64 data type which is double in PyTorch. I think if you add\n\nname = name.astype(np.float32)\n\nlabel = label.astype(np.float32)\n\nBefore returning an item, would solve the issue.\n\n[image] neuralpat:\n\n...
Different runing time in nn.conv2d
I have encountered a problem about the forward propagation, the full code is as follows: I want to accurately record the runing time of nn.conv2d function, where time1 is about 0.00009901s, but time2 is about 0.00011235s. As can be seen in the code, the convolution flops is identical, I don’t kno&hellip;
0
2019-04-18T10:55:31.287Z
Unfortunately, GPUs are very good at doing large simple operations like element-wise ops or mm but very bad at smart things like indexing. For the time noise, I don’t see any way around this, as I said, this is most likely some hardware quirks and I don’t know GPU internals enough to have an idea w&hellip;
1
2019-04-23T07:56:32.114Z
https://discuss.pytorch.org/t/different-runing-time-in-nn-conv2d/42926/13
The error is most likely raised by using a list for the price_label assuming these are the weights: def weighted_mse_loss(input, target, weight): return (weight * (input - target) ** 2) x = torch.randn(10, 10, requires_grad=True) y = torch.randn(10, 10) weight = torch.randn(10, 1).tolist() lo&hellip; Hi, I think...
615
{'text': ['Unfortunately, GPUs are very good at doing large simple operations like element-wise ops or mm but very bad at smart things like indexing.\n\nFor the time noise, I don’t see any way around this, as I said, this is most likely some hardware quirks and I don’t know GPU internals enough to have an idea w&hellip...
Is the code correct for character level generation in lstm?
I started learning nlp on my own.Intially i started with movie review sentiment classification and it is working fine.Next I started working on text generation from shakespeare text.But it is not training at all.For every epoch i am printing the predicted results and they are same everytime. <a class="mention" href="/...
0
2020-10-16T05:38:07.282Z
[image] Sanjayvarma11: out = torch.sigmoid(activations) Should you be using a nn.Linear layer here instead of sigmoid activation? I see that CrossEntropyLoss being used. So, simply using the logit outputs from the linear should be fine.
1
2020-10-20T09:22:56.581Z
https://discuss.pytorch.org/t/is-the-code-correct-for-character-level-generation-in-lstm/99580/2
[image] Sanjayvarma11: out = torch.sigmoid(activations) Should you be using a nn.Linear layer here instead of sigmoid activation? I see that CrossEntropyLoss being used. So, simply using the logit outputs from the linear should be fine. Thanks again for the code snippet as well as the great debugging! I was able to...
1,846
{'text': ['[image] Sanjayvarma11:\n\nout = torch.sigmoid(activations)\n\nShould you be using a nn.Linear layer here instead of sigmoid activation?\n\nI see that CrossEntropyLoss being used. So, simply using the logit outputs from the linear should be fine.'], 'answer_start': [1846]}
Inconsistent results when printing variables
Hi, I ran into a really peculiar situation here. I have a pretrained network (weights frozen in training) that is supposed to take plane sweep volume (essentially stack of warped images) as input and produce intermediate results for other modules in the pipeline. My plan is to run the said networ&hellip;
0
2021-02-15T05:01:14.348Z
Thanks again for the code snippet as well as the great debugging! I was able to narrow it down to a sync issue using this “minimal” code snippet: x = torch.randn(1, 2, 4, 4, device=&#39;cuda&#39;) v = 2 m = torch.randn(1024, 1024, device=&#39;cuda&#39;) res = [] for _ in range(10): psv_tgt = x[:, 0:1].repeat&hel...
0
2021-02-21T10:35:33.015Z
https://discuss.pytorch.org/t/inconsistent-results-when-printing-variables/111902/19
[image] Sanjayvarma11: out = torch.sigmoid(activations) Should you be using a nn.Linear layer here instead of sigmoid activation? I see that CrossEntropyLoss being used. So, simply using the logit outputs from the linear should be fine. Thanks again for the code snippet as well as the great debugging! I was able to...
1,163
{'text': ['Thanks again for the code snippet as well as the great debugging!\n\nI was able to narrow it down to a sync issue using this “minimal” code snippet:\n\nx = torch.randn(1, 2, 4, 4, device=&#39;cuda&#39;)\n\nv = 2\n\nm = torch.randn(1024, 1024, device=&#39;cuda&#39;)\n\nres = []\n\nfor _ in range(10):\n\npsv_t...
Unable to install torch with gpu support
I am trying to setup torch on my local ubuntu 18.04 machine but so far i have been unsuccessful, any help to setup torch would be really really helpful. when i do torch.backends.cudnn.enabled it returns True but when i do torch.backends.cuda.is_built() it returns False and when i do torch.cuda.is_av&hellip;
0
2019-12-20T18:12:10.633Z
<a class="mention" href="/u/ptrblck">@ptrblck</a> so conda did not work, but I installed it via pip and that works. thanks.
0
2019-12-21T04:00:33.250Z
https://discuss.pytorch.org/t/unable-to-install-torch-with-gpu-support/64653/10
[image] Sanjayvarma11: out = torch.sigmoid(activations) Should you be using a nn.Linear layer here instead of sigmoid activation? I see that CrossEntropyLoss being used. So, simply using the logit outputs from the linear should be fine. Thanks again for the code snippet as well as the great debugging! I was able to...
565
{'text': ['<a class="mention" href="/u/ptrblck">@ptrblck</a> so conda did not work, but I installed it via pip and that works. thanks.'], 'answer_start': [565]}
Udacity lessons unknown syntax questions
Im new in these area. So i have too many defiencies. Firstly i say to sorry for easy questions. i can not find on internet. Can anybody tell me this codes: #how can unsqueeze add batch dimensions. what is the meaning of 0 and [:3,:,:] what is this? image = in_tansform (image)[:3,:,:].unsqueeze(0) &hellip;
0
2019-01-27T15:14:28.827Z
As I said I’m not familiar with the Udacity course, but I will try to answer your questions based on the code snippet you’ve provided. A try ... except block runs some code in the try section. If an exception is throws (e.g. due to an indexing error), the except section will be executed. Usually &hellip;
1
2019-02-12T22:58:02.613Z
https://discuss.pytorch.org/t/udacity-lessons-unknown-syntax-questions/35714/6
As I said I’m not familiar with the Udacity course, but I will try to answer your questions based on the code snippet you’ve provided. A try ... except block runs some code in the try section. If an exception is throws (e.g. due to an indexing error), the except section will be executed. Usually &hellip; No problem ! ...
1,378
{'text': ['As I said I’m not familiar with the Udacity course, but I will try to answer your questions based on the code snippet you’ve provided.\n\nA try ... except block runs some code in the try section. If an exception is throws (e.g. due to an indexing error), the except section will be executed. Usually &hellip;'...
Bug in autograd module?
Hello. Today I was performing some experiments using a variational autoencoder. I realized about something quite surprising that I did not expect. Hope someone can help me. I was sampling from the posterior distribution and wanted to save an image of the latent space. The image on the latent space&hellip;
0
2018-11-12T16:13:55.900Z
No problem ! In python, only number, strings and booleans (I might be missing things here like functions but I’m not sure) are passed by value, everything else is passed by reference.
1
2018-11-13T10:21:20.137Z
https://discuss.pytorch.org/t/bug-in-autograd-module/29398/19
As I said I’m not familiar with the Udacity course, but I will try to answer your questions based on the code snippet you’ve provided. A try ... except block runs some code in the try section. If an exception is throws (e.g. due to an indexing error), the except section will be executed. Usually &hellip; No problem ! ...
996
{'text': ['No problem !\n\nIn python, only number, strings and booleans (I might be missing things here like functions but I’m not sure) are passed by value, everything else is passed by reference.'], 'answer_start': [996]}
RuntimeError: Trying to backward through the graph a second time, but the buffers have already been freed. Specify retain_graph=True when calling backward the first time. Help appreciated!
I am trying to calculate the mutual information between the hidden layers’ output and input and output using the following code: def InfoNCE(X, Y, batch_size=256, num_epochs=200, dev=torch.device(“cpu”), model=None, rg=True): A = torch.tensor([float(batch_size)] * batch_size).reshape(batch_size, &hellip;
0
2019-09-16T22:42:51.272Z
Ho, looking at the code in a nice editor made me realise that you pass layer_2_log to your second training stage. But that Tensor has some history already from the first training stage. Is that expected that this will backward in the first part of the model as well? If no, you should add a .detach() &hellip;
0
2019-09-17T18:21:25.987Z
https://discuss.pytorch.org/t/runtimeerror-trying-to-backward-through-the-graph-a-second-time-but-the-buffers-have-already-been-freed-specify-retain-graph-true-when-calling-backward-the-first-time-help-appreciated/56098/9
As I said I’m not familiar with the Udacity course, but I will try to answer your questions based on the code snippet you’ve provided. A try ... except block runs some code in the try section. If an exception is throws (e.g. due to an indexing error), the except section will be executed. Usually &hellip; No problem ! ...
492
{'text': ['Ho, looking at the code in a nice editor made me realise that you pass layer_2_log to your second training stage. But that Tensor has some history already from the first training stage. Is that expected that this will backward in the first part of the model as well? If no, you should add a .detach() &hellip;...
RuntimeError: Error(s) in loading state_dict for SimCLR:
I am trying to replicate SimCLR model with link <a href="https://colab.research.google.com/github/phlippe/uvadlc_notebooks/blob/master/docs/tutorial_notebooks/tutorial17/SimCLR.ipynb" class="inline-onebox" rel="noopener nofollow ugc">Google Colab</a> using my dataset and model. When I execute using my model, it gives t...
0
2022-08-26T17:43:22.748Z
torch.save would accept any valid path with a (new) file name. Make sure the directories exist as torch.save will not recursively create them.
0
2022-09-02T07:04:58.572Z
https://discuss.pytorch.org/t/runtimeerror-error-s-in-loading-state-dict-for-simclr/160127/6
torch.save would accept any valid path with a (new) file name. Make sure the directories exist as torch.save will not recursively create them. Don’t take my word for it though. That might be a part. So if a, say, 10% speedup is worth writing it in C++, do try. But I think you don’t get 30% just from moving to C++, but ...
1,602
{'text': ['torch.save would accept any valid path with a (new) file name. Make sure the directories exist as torch.save will not recursively create them.'], 'answer_start': [1602]}
Writing a cpp extension
Hi, As mentioned in <a href="https://pytorch.org/tutorials/advanced/cpp_extension.html" rel="nofollow noopener">this tutorial</a> I currently have to provide a manual backward function in a cpp extension. From my understanding, this backward would be the same as it would be evaluated by autograd in python (just imple...
0
2018-07-28T16:37:25.949Z
Don’t take my word for it though. That might be a part. So if a, say, 10% speedup is worth writing it in C++, do try. But I think you don’t get 30% just from moving to C++, but a larger part of that is the custom backward (which you could do similarly in Python).
1
2018-07-31T12:19:23.551Z
https://discuss.pytorch.org/t/writing-a-cpp-extension/21901/12
torch.save would accept any valid path with a (new) file name. Make sure the directories exist as torch.save will not recursively create them. Don’t take my word for it though. That might be a part. So if a, say, 10% speedup is worth writing it in C++, do try. But I think you don’t get 30% just from moving to C++, but ...
944
{'text': ['Don’t take my word for it though. That might be a part. So if a, say, 10% speedup is worth writing it in C++, do try. But I think you don’t get 30% just from moving to C++, but a larger part of that is the custom backward (which you could do similarly in Python).'], 'answer_start': [944]}
How to get all the weight (not all paramerters)
Hi, I would like to know the max(abs(weight)) of every epoch. As show in figure. [bit位数]. I think I can get max(abs(weight)) in epoch loop, for example: for epoch in range(1, epochs + 1): train_loss,t_accuracy = train(model, train_loader, optimizer) test_loss, accuracy = test(model, test_l&hellip;
0
2020-03-31T11:23:05.265Z
[image] 111179: is comment in weight, I get the error: “bool value of Tensor with more than one value is ambiguous”… I can get the max(abs(bias))…maybe I know You can flatten the model then the max of the numpy aray. Just pass your net to below function it will give you fattened numpy array &hellip;
2
2020-04-03T04:02:39.482Z
https://discuss.pytorch.org/t/how-to-get-all-the-weight-not-all-paramerters/74897/8
torch.save would accept any valid path with a (new) file name. Make sure the directories exist as torch.save will not recursively create them. Don’t take my word for it though. That might be a part. So if a, say, 10% speedup is worth writing it in C++, do try. But I think you don’t get 30% just from moving to C++, but ...
407
{'text': ['[image] 111179:\n\nis comment in weight, I get the error: “bool value of Tensor with more than one value is ambiguous”…\n\nI can get the max(abs(bias))…maybe I know\n\nYou can flatten the model then the max of the numpy aray. Just pass your net to below function it will give you fattened numpy array &hellip;...
Multilabelmarginloss
Hi everyone, I seem to have problems making this loss function work. I feed it the output of the network and the labels from the dataset and after the first epoch it says that the loss is 0, but the accuracy is still low. Do you know where the problem should be?
0
2020-06-26T13:32:20.877Z
I think nn.MultiMarginLoss would be the suitable criterion: Creates a criterion that optimizes a multi-class classification hinge loss (margin-based loss) between input x (a 2D mini-batch Tensor) and output y Based on the shape information it should also work for your current output and target s&hellip;
1
2020-06-28T23:51:20.160Z
https://discuss.pytorch.org/t/multilabelmarginloss/87022/6
I think nn.MultiMarginLoss would be the suitable criterion: Creates a criterion that optimizes a multi-class classification hinge loss (margin-based loss) between input x (a 2D mini-batch Tensor) and output y Based on the shape information it should also work for your current output and target s&hellip; Oh and I forg...
1,420
{'text': ['I think nn.MultiMarginLoss would be the suitable criterion:\n\nCreates a criterion that optimizes a multi-class classification hinge loss (margin-based loss) between input x (a 2D mini-batch Tensor) and output y\n\nBased on the shape information it should also work for your current output and target s&hellip...
TypeError: avg_pool2d(): argument 'kernel_size' (position 2) must be tuple of ints, not tuple
Hi. I’m trying to implement a pre-trained Vision Transformer and perform gem pooling but I get this error. The code is: class GeM(nn.Module): def __init__(self, p=3, eps=1e-6): super(GeM,self).__init__() self.p = Parameter(torch.ones(1)*p) self.eps = eps def f&hellip;
0
2022-05-14T07:22:52.241Z
Oh and I forgot to address the error that you mentioned. [image] whatevername: But now I get the error: IndexError: Dimension out of range (expected to be in range of [-2, 1], but got -3) from line: return F.avg_pool2d(x.clamp(min=eps).pow(p), (x.size(-2), x.size(-1))).pow(1./p) As you &hellip;
0
2022-05-15T15:59:32.439Z
https://discuss.pytorch.org/t/typeerror-avg-pool2d-argument-kernel-size-position-2-must-be-tuple-of-ints-not-tuple/151655/10
I think nn.MultiMarginLoss would be the suitable criterion: Creates a criterion that optimizes a multi-class classification hinge loss (margin-based loss) between input x (a 2D mini-batch Tensor) and output y Based on the shape information it should also work for your current output and target s&hellip; Oh and I forg...
1,017
{'text': ['Oh and I forgot to address the error that you mentioned.\n\n[image] whatevername:\n\nBut now I get the error:\n\nIndexError: Dimension out of range (expected to be in range of [-2, 1], but got -3)\n\nfrom line:\n\nreturn F.avg_pool2d(x.clamp(min=eps).pow(p), (x.size(-2), x.size(-1))).pow(1./p)\n\nAs you &hel...
Custom layer gets same weights in every training iterations
Hello, everyone I want to make a custom regularization layer with Pytorch but something is wrong to my regularization layer because the loss output is all same when training. The real problem is that I found out myloss gets same net.parameters() in every training process but, I do not know why it &hellip;
0
2020-07-20T17:19:05.022Z
I made a simple model that has one layer (linear, so I adjusted your if condition) and the only objective function was yours. I did see that it was unchanging at 0.005 after an optimization step until I bumped up lambd, then I saw that it was changing. Even with bumping your lambd value up you don’&hellip;
2
2020-07-20T18:30:44.775Z
https://discuss.pytorch.org/t/custom-layer-gets-same-weights-in-every-training-iterations/89927/9
I think nn.MultiMarginLoss would be the suitable criterion: Creates a criterion that optimizes a multi-class classification hinge loss (margin-based loss) between input x (a 2D mini-batch Tensor) and output y Based on the shape information it should also work for your current output and target s&hellip; Oh and I forg...
609
{'text': ['I made a simple model that has one layer (linear, so I adjusted your if condition) and the only objective function was yours. I did see that it was unchanging at 0.005 after an optimization step until I bumped up lambd, then I saw that it was changing.\n\nEven with bumping your lambd value up you don’&hellip...
RuntimeError: size mismatch (got input: [6422528], target: [802816])
I’m trying to adjust a binary segmentation U-net model, to be able to train a multi-class U-net on the German Asfalt Pavement Distress (GAPs) dataset. Traceback (most recent call last): File &quot;/content/drive/Othercomputers/My Laptop/crack_segmentation_khanhha/crack_segmentation-master/train_unet_G&hellip;
0
2022-06-15T21:13:14.659Z
Hi Mohamed! [image] hedeya1980: The shape of masks_pred is [4, 8, 448, 448] not [4, 8, 1, 448, 448]. The shape of target_var is [4, 1, 448, 448]. That clears things up. masks_pred correctly has its nChannels dimension as its second dimension. But target_var has that extra singleton dimen&hellip;
0
2022-06-16T15:29:14.435Z
https://discuss.pytorch.org/t/runtimeerror-size-mismatch-got-input-6422528-target-802816/154254/6
Hi Mohamed! [image] hedeya1980: The shape of masks_pred is [4, 8, 448, 448] not [4, 8, 1, 448, 448]. The shape of target_var is [4, 1, 448, 448]. That clears things up. masks_pred correctly has its nChannels dimension as its second dimension. But target_var has that extra singleton dimen&hellip; The issue is tha...
1,834
{'text': ['Hi Mohamed!\n\n[image] hedeya1980:\n\nThe shape of masks_pred is [4, 8, 448, 448] not [4, 8, 1, 448, 448].\n\nThe shape of target_var is [4, 1, 448, 448].\n\nThat clears things up.\n\nmasks_pred correctly has its nChannels dimension as its second\n\ndimension. But target_var has that extra singleton dimen&h...
Non-deterministic tensor index arithmetic on cuda
The code in this <a href="https://gist.github.com/bgobbi/042bbee9b0bedf70995f88c6ce3a9208" rel="nofollow noopener">gist</a> does some indexing and simple arithmetic with the exact same inputs 20 000 times. It is supposed to find the index of the first and last elements in groups of consecutive elements. When run on a...
0
2018-08-19T15:14:01.647Z
The issue is that the line: b[:-1] = b[1:] reads and writes overlapping elements of b. There’s a similar issue in the original snippet, which <a class="mention" href="/u/bgobbi">@bgobbi</a> mentions in the original post. You can fix this by writing: b[:-1] = b[1:].clone() At some point in the future, I’d like to a...
1
2018-08-22T15:10:44.828Z
https://discuss.pytorch.org/t/non-deterministic-tensor-index-arithmetic-on-cuda/23446/11
Hi Mohamed! [image] hedeya1980: The shape of masks_pred is [4, 8, 448, 448] not [4, 8, 1, 448, 448]. The shape of target_var is [4, 1, 448, 448]. That clears things up. masks_pred correctly has its nChannels dimension as its second dimension. But target_var has that extra singleton dimen&hellip; The issue is tha...
1,221
{'text': ['The issue is that the line:\n\nb[:-1] = b[1:]\n\nreads and writes overlapping elements of b. There’s a similar issue in the original snippet, which <a class="mention" href="/u/bgobbi">@bgobbi</a> mentions in the original post.\n\nYou can fix this by writing:\n\nb[:-1] = b[1:].clone()\n\nAt some point in the ...
How do I sample images from a dataset having the no. of images to be greater than a specified threshold?
I am trying to use a dataset having nearly 5200 classes of images and total images to be somewhere around 14000, now some of these classes have only image per class i want to use only those images which have atleast say 3 or more images per class , one way could be by iterating over the entire direc&hellip;
0
2021-06-15T04:28:11.199Z
You would have to map these indices to [0, nb_classes-1] as described in the previous post. EDIT: here is a code snippet in case you get stuck: target = torch.randint(3, 6, (10,)) print(target) &gt; tensor([3, 4, 3, 3, 3, 5, 5, 4, 3, 4]) unique = torch.unique(target) for i, u in enumerate(unique): &hellip;
1
2021-06-22T05:39:14.744Z
https://discuss.pytorch.org/t/how-do-i-sample-images-from-a-dataset-having-the-no-of-images-to-be-greater-than-a-specified-threshold/124129/10
Hi Mohamed! [image] hedeya1980: The shape of masks_pred is [4, 8, 448, 448] not [4, 8, 1, 448, 448]. The shape of target_var is [4, 1, 448, 448]. That clears things up. masks_pred correctly has its nChannels dimension as its second dimension. But target_var has that extra singleton dimen&hellip; The issue is tha...
653
{'text': ['You would have to map these indices to [0, nb_classes-1] as described in the previous post.\n\nEDIT: here is a code snippet in case you get stuck:\n\ntarget = torch.randint(3, 6, (10,))\n\nprint(target)\n\n&gt; tensor([3, 4, 3, 3, 3, 5, 5, 4, 3, 4])\n\nunique = torch.unique(target)\n\nfor i, u in enumerate(u...
88 Character String Dataset Analysis
I have a collection of about 20K strings from a black box function, each string is 88 ascii characters in length, one string per line in a file. My initial thought was to convert each line in the file to its numerical ascii value, with an 88 neuron wide input layer; for example: &gt;&gt;&gt; s = &#39;AQCfRmKcn&hellip...
0
2018-01-07T22:39:05.799Z
The architecture surely matters, but usually formulation is what is most important. The approach I described is called Variational Autoencoder, or VAE. It uses two deep networks to represent a probabilistic model, and tries to get a high likelihood solution by optimizing a lower bound. Architectural&hellip;
0
2018-01-12T20:31:01.133Z
https://discuss.pytorch.org/t/88-character-string-dataset-analysis/11994/13
The architecture surely matters, but usually formulation is what is most important. The approach I described is called Variational Autoencoder, or VAE. It uses two deep networks to represent a probabilistic model, and tries to get a high likelihood solution by optimizing a lower bound. Architectural&hellip; retain_grap...
1,934
{'text': ['The architecture surely matters, but usually formulation is what is most important. The approach I described is called Variational Autoencoder, or VAE. It uses two deep networks to represent a probabilistic model, and tries to get a high likelihood solution by optimizing a lower bound. Architectural&hellip;'...
In-place operation error - PyTorch1.6.0
This is my class definition: class Tracker(nn.Module): def __init__(self): super(Tracker, self).__init__() self.bigru = nn.GRU(input_size=2, hidden_size=100, batch_first=True, bidirectional=True) self.fc1 = nn.Linear(200, 32) self.fc2 = nn.Linear(32, 2) def f&hellip;
0
2020-09-21T18:04:41.424Z
retain_graph is only needed if you call backward again without calling forward again. If you only call things once, there is no need for it.
0
2020-09-21T20:31:40.720Z
https://discuss.pytorch.org/t/in-place-operation-error-pytorch1-6-0/97032/11
The architecture surely matters, but usually formulation is what is most important. The approach I described is called Variational Autoencoder, or VAE. It uses two deep networks to represent a probabilistic model, and tries to get a high likelihood solution by optimizing a lower bound. Architectural&hellip; retain_grap...
1,276
{'text': ['retain_graph is only needed if you call backward again without calling forward again. If you only call things once, there is no need for it.'], 'answer_start': [1276]}
Hessian product slower in forward mode than reverse mode
Hi, I use forward mode differentiation and I get the same gradients as reverse mode but much slower. The bottlneck of my code is the Hessian vector product which uses a for loop, is there a more efficient way of doing it? D = n_weights K = n_hyperparams Z = torch.zeros((D, K)) # input that changes&hellip;
0
2020-03-23T12:33:21.470Z
The problem is not the product but that you only want to gradients corresponding to part of it. In some sense, you have K different loss functions. So if you want the gradients for each of them you need to do K backwards. I don’t think there is any way around this.
0
2020-03-23T19:20:39.543Z
https://discuss.pytorch.org/t/hessian-product-slower-in-forward-mode-than-reverse-mode/74133/10
The architecture surely matters, but usually formulation is what is most important. The approach I described is called Variational Autoencoder, or VAE. It uses two deep networks to represent a probabilistic model, and tries to get a high likelihood solution by optimizing a lower bound. Architectural&hellip; retain_grap...
450
{'text': ['The problem is not the product but that you only want to gradients corresponding to part of it. In some sense, you have K different loss functions. So if you want the gradients for each of them you need to do K backwards. I don’t think there is any way around this.'], 'answer_start': [450]}
StyleGAN2 retain_graph=False RuntimeError
Hi, when I start to train a simple version StyleGAN2 in PyTorch 1.0.1. Since I do not want to use retain_graph = True, A Runtime Error Trying to backward through the graph a second time, but the buffers have already been freed. Specify retain_graph=True when calling backward the first time. raised &hellip;
0
2019-12-24T09:42:11.031Z
It seems one BiasAdd module is reused somewhere in the code, but I cannot spot the line. This should be unrelated to your current issue, but I would recommend to setup the bias tensor and wrap it into nn.Parameter as the final step to create a leaf variable. Currently you are creating a non-leaf v&hellip;
1
2019-12-26T03:04:41.193Z
https://discuss.pytorch.org/t/stylegan2-retain-graph-false-runtimeerror/64883/7
It seems one BiasAdd module is reused somewhere in the code, but I cannot spot the line. This should be unrelated to your current issue, but I would recommend to setup the bias tensor and wrap it into nn.Parameter as the final step to create a leaf variable. Currently you are creating a non-leaf v&hellip; I would rec...
1,430
{'text': ['It seems one BiasAdd module is reused somewhere in the code, but I cannot spot the line.\n\nThis should be unrelated to your current issue, but I would recommend to setup the bias tensor and wrap it into nn.Parameter as the final step to create a leaf variable.\n\nCurrently you are creating a non-leaf v&hell...
Error "mat1 and mat2 shapes cannot be multiplied"
Hello, new to pytorch I am trying to create a model using the script found under <a href="https://codeshare.io/1Y4k8m" class="inline-onebox" rel="noopener nofollow ugc">Dec 01 9:08 AM - Codeshare</a> but when I run this code I get the error RuntimeError: mat1 and mat2 shapes cannot be multiplied (64x38850 and 259x512...
0
2022-12-01T09:09:35.220Z
I would recommend to check <a href="https://pytorch.org/tutorials/recipes/recipes/defining_a_neural_network.html">this tutorial</a> which explains how a neural network can be defined for the MNIST dataset and you could also play around with this dataset first to get familiar with the dimensions of the input tensors etc...
0
2022-12-06T07:09:33.848Z
https://discuss.pytorch.org/t/error-mat1-and-mat2-shapes-cannot-be-multiplied/167275/20
It seems one BiasAdd module is reused somewhere in the code, but I cannot spot the line. This should be unrelated to your current issue, but I would recommend to setup the bias tensor and wrap it into nn.Parameter as the final step to create a leaf variable. Currently you are creating a non-leaf v&hellip; I would rec...
1,024
{'text': ['I would recommend to check <a href="https://pytorch.org/tutorials/recipes/recipes/defining_a_neural_network.html">this tutorial</a> which explains how a neural network can be defined for the MNIST dataset and you could also play around with this dataset first to get familiar with the dimensions of the input ...
How can i create a single dataloader for my two csv files . I have tried this
data_file1 = “/Data_train_A.csv” rnaseq = pd.read_csv(data_file1, index_col=0, header=0) rnaseq_tensor1 = torch.FloatTensor(rnaseq.values) #print(rnaseq.shape) data_file2 = “/Data_train_B.csv” rnaseq = pd.read_csv(data_file2, index_col=0, header=0) rnaseq_tensor2 = torch.FloatTensor(rnaseq.val&hellip;
0
2019-10-24T08:06:58.266Z
Thanks it really helped. Thanks again
0
2019-11-06T08:14:17.381Z
https://discuss.pytorch.org/t/how-can-i-create-a-single-dataloader-for-my-two-csv-files-i-have-tried-this/59099/13
It seems one BiasAdd module is reused somewhere in the code, but I cannot spot the line. This should be unrelated to your current issue, but I would recommend to setup the bias tensor and wrap it into nn.Parameter as the final step to create a leaf variable. Currently you are creating a non-leaf v&hellip; I would rec...
709
{'text': ['Thanks it really helped. Thanks again'], 'answer_start': [709]}
Multi GPU backwards hook on wrong device
I have a backward hook function with ‘newLayer.register_backward_hook(hook_function)’ where I do not know how to control the inputs to it. The function contains a line like. def hook_function(self, grad_input, grad_output): self.average = self.average * 0.99 + grad_output[0].sum((0,2,3)) * 0.0&hellip;
0
2020-08-15T15:51:32.396Z
I don’t know how self.average is initialized, but would assume this should work: self.average = self.average.to(grad_output[0].device) * 0.99 + grad_output[0].sum((0,2,3)) * 0.01 Could you check it and see, if you are still getting an error? In that case, could you post a small code snippet to re&hellip;
1
2020-08-18T06:54:19.087Z
https://discuss.pytorch.org/t/multi-gpu-backwards-hook-on-wrong-device/92942/2
I don’t know how self.average is initialized, but would assume this should work: self.average = self.average.to(grad_output[0].device) * 0.99 + grad_output[0].sum((0,2,3)) * 0.01 Could you check it and see, if you are still getting an error? In that case, could you post a small code snippet to re&hellip; I figured o...
1,492
{'text': ['I don’t know how self.average is initialized, but would assume this should work:\n\nself.average = self.average.to(grad_output[0].device) * 0.99 + grad_output[0].sum((0,2,3)) * 0.01\n\nCould you check it and see, if you are still getting an error?\n\nIn that case, could you post a small code snippet to re&he...
Problem with visualizing multi-class predictions
I ran U-net (with softmax) on Camvid data to predict multi-class segmentation. Seems everything ran well but I am having trouble visualizing the predictions. They look flat as shown below. Full code can be accessed <a href="https://gist.github.com/gireeshkbogu/567cfa31417d63e58a45e4c8bc5ced06" rel="nofollow noopener">...
0
2020-03-25T18:08:24.646Z
I figured out the solution. This worked for me though I had to display masks in different figures. visualize( image=denormalize(image_vis.squeeze()), gt_mask_car=gt_mask[0].squeeze(), pr_mask_car=pr_mask[0].squeeze(), gt_mask_pedestrian=gt_mask[1].squeeze(), &hellip;
1
2020-03-27T03:57:00.227Z
https://discuss.pytorch.org/t/problem-with-visualizing-multi-class-predictions/74368/4
I don’t know how self.average is initialized, but would assume this should work: self.average = self.average.to(grad_output[0].device) * 0.99 + grad_output[0].sum((0,2,3)) * 0.01 Could you check it and see, if you are still getting an error? In that case, could you post a small code snippet to re&hellip; I figured o...
1,055
{'text': ['I figured out the solution. This worked for me though I had to display masks in different figures.\n\nvisualize(\n\nimage=denormalize(image_vis.squeeze()),\n\ngt_mask_car=gt_mask[0].squeeze(),\n\npr_mask_car=pr_mask[0].squeeze(),\n\ngt_mask_pedestrian=gt_mask[1].squeeze(),\n\n&hellip;'], 'answer_start': [105...
Strange behavior nn.Dataparallel
Hi all! I have 4 GPUs 1080 Ti, and when I run training inception_v3 net on multiple GPU model have strange behavior. I didnt rewrite my code much from training on 1 GPU, just add: model = nn.DataParallel(model, device_ids=[0,1,2,3]).cuda() When I run script with device_ids=[0,1] GPUs full utilized&hellip;
0
2020-02-06T08:11:23.365Z
Thanks for the information. This points towards some communication issues between the GPUs. Could you run the PyTorch code using NCCL_P2P_DISABLE=1 to use shared memory instead of p2p access?
0
2020-02-10T06:38:10.461Z
https://discuss.pytorch.org/t/strange-behavior-nn-dataparallel/68833/13
I don’t know how self.average is initialized, but would assume this should work: self.average = self.average.to(grad_output[0].device) * 0.99 + grad_output[0].sum((0,2,3)) * 0.01 Could you check it and see, if you are still getting an error? In that case, could you post a small code snippet to re&hellip; I figured o...
583
{'text': ['Thanks for the information. This points towards some communication issues between the GPUs.\n\nCould you run the PyTorch code using NCCL_P2P_DISABLE=1 to use shared memory instead of p2p access?'], 'answer_start': [583]}
Stack expects each tensor to be equal size, but got [163, 256, 256] at entry 0 and [160, 256, 256] at entry 1
I am working with the OAI MRI dataset for knee osteoarthritis classification. Each one of 435 MRIs I got has to be classified to a grade. For each MRI in a folder, there are 160 2D images. I created this function to read the dataset: def dicom2array(path): dicom = pydicom.read_file(path) data =&hellip;
0
2021-12-25T08:44:11.163Z
Based on the error message some samples seem to have 160 channels while others have 163. Due to this, the collate_fn cannot stack the samples to a single batch and raises the error. Check the shape of each sample and make sure the channel dimension as well as the spatial size are the same.
0
2021-12-29T21:35:33.191Z
https://discuss.pytorch.org/t/stack-expects-each-tensor-to-be-equal-size-but-got-163-256-256-at-entry-0-and-160-256-256-at-entry-1/140206/2
Based on the error message some samples seem to have 160 channels while others have 163. Due to this, the collate_fn cannot stack the samples to a single batch and raises the error. Check the shape of each sample and make sure the channel dimension as well as the spatial size are the same. Yes, CPU memory. [image] ...
1,550
{'text': ['Based on the error message some samples seem to have 160 channels while others have 163.\n\nDue to this, the collate_fn cannot stack the samples to a single batch and raises the error.\n\nCheck the shape of each sample and make sure the channel dimension as well as the spatial size are the same.'], 'answer_s...
Ram usage increases linearly
Hi, the below code increases the memory usage linearly, and at certain point I am not able to train the model. Surprisingly it is the first time I am facing problem with the following code? doubts: Vector images, Vector image is the only new data that is involved in the following code, commenting&hellip;
0
2019-08-18T03:19:03.631Z
Yes, CPU memory. [image] <a href="https://discuss.pytorch.org/t/dataloader-increases-ram-usage-every-iteration/6636/3">DataLoader increases RAM usage every iteration</a> Is there any reason why you load all of your images during init ? That was the error (and it makes lots of sense sweat) . Now, I store the image ...
0
2019-08-19T19:21:31.222Z
https://discuss.pytorch.org/t/ram-usage-increases-linearly/53637/10
Based on the error message some samples seem to have 160 channels while others have 163. Due to this, the collate_fn cannot stack the samples to a single batch and raises the error. Check the shape of each sample and make sure the channel dimension as well as the spatial size are the same. Yes, CPU memory. [image] ...
1,068
{'text': ['Yes, CPU memory.\n\n[image]\n\n<a href="https://discuss.pytorch.org/t/dataloader-increases-ram-usage-every-iteration/6636/3">DataLoader increases RAM usage every iteration</a>\n\nIs there any reason why you load all of your images during init ?\n\nThat was the error (and it makes lots of sense sweat) .\n\nNo...
Runtime Error : CUDA Error
RuntimeError: CUDA error: CUBLAS_STATUS_EXECUTION_FAILED when calling `cublasLtMatmul( ltHandle, computeDesc.descriptor(), &amp;alpha_val, mat1_ptr, Adesc.descriptor(), mat2_ptr, Bdesc.descriptor(), &amp;beta_val, result_ptr, Cdesc.descriptor(), result_ptr, Cdesc.descriptor(), &amp;heuristicResult.algo, workspa&hellip;
0
2023-02-12T05:57:24.449Z
[image] Suraj520: However, When I pass in the data loader for english and german language tokens(original ones from the dataset), They run for an hour or so before the error whose log is quoted below is generated Unfortunately, your current code does not reproduce the issue, so that I won’t b&hellip;
1
2023-02-15T06:07:34.165Z
https://discuss.pytorch.org/t/runtime-error-cuda-error/172376/14
Based on the error message some samples seem to have 160 channels while others have 163. Due to this, the collate_fn cannot stack the samples to a single batch and raises the error. Check the shape of each sample and make sure the channel dimension as well as the spatial size are the same. Yes, CPU memory. [image] ...
672
{'text': ['[image] Suraj520:\n\nHowever, When I pass in the data loader for english and german language tokens(original ones from the dataset), They run for an hour or so before the error whose log is quoted below is generated\n\nUnfortunately, your current code does not reproduce the issue, so that I won’t b&hellip;']...
How to avoid recalculating a function when we need to backpropagate through it twice?
I want to do the following calculation: l1 = f(x.detach(), y) l1.backward() l2 = -1*f(x, y.detach()) l2.backward() where f is some function, and x and y are tensors that require gradient. Notice that x and y may both be the results of previous calculations which utilize shared parameters (for exam&hellip;
0
2020-08-21T15:25:05.973Z
Ho sorry I think I misread the title of the topic and though it was an error :frowning: Does the function f has any parameter into it? If there is nothing else in there, and the only way to get to the parameters is via x and y, I would do: x, y = g(input, params) # f must have NO parameters # Equ&hellip;
0
2020-08-21T22:20:10.030Z
https://discuss.pytorch.org/t/how-to-avoid-recalculating-a-function-when-we-need-to-backpropagate-through-it-twice/93647/8
Ho sorry I think I misread the title of the topic and though it was an error :frowning: Does the function f has any parameter into it? If there is nothing else in there, and the only way to get to the parameters is via x and y, I would do: x, y = g(input, params) # f must have NO parameters # Equ&hellip; Your firs...
1,950
{'text': ['Ho sorry I think I misread the title of the topic and though it was an error :frowning:\n\nDoes the function f has any parameter into it?\n\nIf there is nothing else in there, and the only way to get to the parameters is via x and y, I would do:\n\nx, y = g(input, params)\n\n# f must have NO parameters\n\n# ...
Network pruning error
Hello, I am very new to this topic but I am trying to prune the model I am working with. For reference, I am using <a href="https://pytorch.org/tutorials/intermediate/pruning_tutorial.html" rel="nofollow noopener">this</a> page. The model is quite big, containing different encoders, ResNet modules, and decoders. So, I...
0
2020-07-09T11:57:47.483Z
Your first Conv layer in the Sequential module is at index 1. Try prune.random_unstructured(test[1], name=‘weight’, amount=0.3). I think that should work. Let me know if it doesn’t.
2
2020-07-09T19:43:12.539Z
https://discuss.pytorch.org/t/network-pruning-error/88553/5
Ho sorry I think I misread the title of the topic and though it was an error :frowning: Does the function f has any parameter into it? If there is nothing else in there, and the only way to get to the parameters is via x and y, I would do: x, y = g(input, params) # f must have NO parameters # Equ&hellip; Your firs...
1,286
{'text': ['Your first Conv layer in the Sequential module is at index 1. Try prune.random_unstructured(test[1], name=‘weight’, amount=0.3). I think that should work. Let me know if it doesn’t.'], 'answer_start': [1286]}
CUDNN_STATUS_MAPPING_ERROR using conv2d
Would be immensely grateful for some help. New GPUs not working on my conda environment In [2]: torch.version.cuda Out[2]: ‘10.1.243’ cudatoolkit 10.1.243 h6bb024c_0 anaconda cudnn 7.6.5.32 hc0a50b0_1 conda-forge python 3.7.5 h037&hellip;
0
2021-11-12T08:17:57.565Z
Got it working! Had to abandon the old environment and build from scratch. This ordering (followed by all the other packages) led to success. Thank you so much for your help! conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch conda list cuda conda install -c pytorch ignite &hellip;
0
2021-11-12T20:54:39.592Z
https://discuss.pytorch.org/t/cudnn-status-mapping-error-using-conv2d/136675/8
Ho sorry I think I misread the title of the topic and though it was an error :frowning: Does the function f has any parameter into it? If there is nothing else in there, and the only way to get to the parameters is via x and y, I would do: x, y = g(input, params) # f must have NO parameters # Equ&hellip; Your firs...
493
{'text': ['Got it working! Had to abandon the old environment and build from scratch. This ordering (followed by all the other packages) led to success. Thank you so much for your help!\n\nconda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch\n\nconda list cuda\n\nconda install -c pytorch ignite &he...
Loss increasing dramatically when running with multiple GPU
Hello, I run my model on a single GPU, the result of the test set is normal. But when I change to run on multiple GPU, the metrics evaluated on the test set (loss, RMSE,…) are not stable, they increase dramatically over time. I wonder why this problem happens, I thought the result must be the same &hellip;
0
2020-05-27T03:02:11.322Z
Thanks for the code. It seems your approach is similar to weight_norm, which uses the setattr and getattr to modify the weight parameter so you could try to adapt <a href="https://github.com/pytorch/pytorch/blob/master/torch/nn/utils/weight_norm.py">WeightNorm</a> to your use case. Alternatively, it might be easier t...
0
2020-05-31T05:23:38.163Z
https://discuss.pytorch.org/t/loss-increasing-dramatically-when-running-with-multiple-gpu/83040/12
Thanks for the code. It seems your approach is similar to weight_norm, which uses the setattr and getattr to modify the weight parameter so you could try to adapt <a href="https://github.com/pytorch/pytorch/blob/master/torch/nn/utils/weight_norm.py">WeightNorm</a> to your use case. Alternatively, it might be easier t...
1,602
{'text': ['Thanks for the code.\n\nIt seems your approach is similar to weight_norm, which uses the setattr and getattr to modify the weight parameter so you could try to adapt <a href="https://github.com/pytorch/pytorch/blob/master/torch/nn/utils/weight_norm.py">WeightNorm</a> to your use case.\n\nAlternatively, it mi...
RuntimeError: Expected object of type torch.FloatTensor but found type torch.cuda.FloatTensor
I am using pretrained Densenet121 from torch vision within my custom nn.module. However, the titled error happens even if I use .cuda(). I tried using .cuda within the init function of CustomNet but it still gives the same error. Please assume I would remove the last layer and replace the classifier&hellip;
0
2018-10-01T11:13:53.334Z
Did you forget to assign the tensor back? tensor = tensor.to(&#39;cuda&#39;)
0
2018-10-05T05:03:23.452Z
https://discuss.pytorch.org/t/runtimeerror-expected-object-of-type-torch-floattensor-but-found-type-torch-cuda-floattensor/26306/12
Thanks for the code. It seems your approach is similar to weight_norm, which uses the setattr and getattr to modify the weight parameter so you could try to adapt <a href="https://github.com/pytorch/pytorch/blob/master/torch/nn/utils/weight_norm.py">WeightNorm</a> to your use case. Alternatively, it might be easier t...
1,201
{'text': ['Did you forget to assign the tensor back?\n\ntensor = tensor.to(&#39;cuda&#39;)'], 'answer_start': [1201]}
Custom Dataset (Cannot load final batch of different size, cuDNN error all of a sudden)
Hi there, My custom dataset code (multilabel classifier): class MultiLabelDataset(Dataset): def __init__(self,csv_path,image_path,transform=None): super().__init__() self.data = pd.read_csv(csv_path) self.labels = np.asarray(self.data.drop([&#39;ID&#39;]&hellip;
0
2021-03-19T07:36:32.640Z
Thanks for the code! I cannot reproduce the cudnn issue on a 2080 using the 1.8.0+CUDA10.2+cudnn7.6.5 and 1.8.0+CUDA11.1+cudnn8.0.5 conda binaries for all shapes in [1, 32]: for bs in torch.arange(1, 33): x = torch.randn(bs, 3, 224, 224, device=device) out = model(x) print(out.device) &hellip;
0
2021-03-22T04:15:53.930Z
https://discuss.pytorch.org/t/custom-dataset-cannot-load-final-batch-of-different-size-cudnn-error-all-of-a-sudden/115311/8
Thanks for the code. It seems your approach is similar to weight_norm, which uses the setattr and getattr to modify the weight parameter so you could try to adapt <a href="https://github.com/pytorch/pytorch/blob/master/torch/nn/utils/weight_norm.py">WeightNorm</a> to your use case. Alternatively, it might be easier t...
478
{'text': ['Thanks for the code!\n\nI cannot reproduce the cudnn issue on a 2080 using the 1.8.0+CUDA10.2+cudnn7.6.5 and 1.8.0+CUDA11.1+cudnn8.0.5 conda binaries for all shapes in [1, 32]:\n\nfor bs in torch.arange(1, 33):\n\nx = torch.randn(bs, 3, 224, 224, device=device)\n\nout = model(x)\n\nprint(out.device)\n\n&hell...
RunTime Error due to tensors being on different devices
device = &quot;cuda&quot; if torch.cuda.is_available() else &quot;cpu&quot; class LSTM(nn.Module): def __init__(self, n_hidden = 128,): super(LSTM, self).__init__() self.n_hidden = n_hidden #self.linearIn = nn.Linear(6, 128) self.lstm1 = nn.LSTMCell(1, self.n_hidden,) self.ls&hellip;
0
2021-03-16T09:12:42.976Z
Did you put test data and train data on the gpu like this train_data = train_data.to(device) test_data = test_data.to(device) ```? Can you send your train loop too?
1
2021-03-16T18:20:58.611Z
https://discuss.pytorch.org/t/runtime-error-due-to-tensors-being-on-different-devices/114975/12
Did you put test data and train data on the gpu like this train_data = train_data.to(device) test_data = test_data.to(device) ```? Can you send your train loop too? Hi Rishi! [image] snau: I tried your version and getting the same error. The problem is that you have to rebuild the “computation graph” before you...
1,556
{'text': ['Did you put test data and train data on the gpu like this\n\ntrain_data = train_data.to(device)\n\ntest_data = test_data.to(device)\n\n```?\n\nCan you send your train loop too?'], 'answer_start': [1556]}
Autograd fails without giving any warning while doing matrix operations
I am trying to learn a parameter which is one element of a bigger matrix. The loss function does not directly use the learnable parameter, but a matrix having this parameter. Simplified code snippet is given below to reproduce the error import torch as t import torch from matplotlib import pyplot &hellip;
0
2021-10-21T13:33:22.980Z
Hi Rishi! [image] snau: I tried your version and getting the same error. The problem is that you have to rebuild the “computation graph” before you call .backward() for a second time. Both indexing into a and setting that “value” to param count as part of the computation graph. Consider&hellip;
0
2021-10-21T18:29:23.629Z
https://discuss.pytorch.org/t/autograd-fails-without-giving-any-warning-while-doing-matrix-operations/134785/8
Did you put test data and train data on the gpu like this train_data = train_data.to(device) test_data = test_data.to(device) ```? Can you send your train loop too? Hi Rishi! [image] snau: I tried your version and getting the same error. The problem is that you have to rebuild the “computation graph” before you...
947
{'text': ['Hi Rishi!\n\n[image] snau:\n\nI tried your version and getting the same error.\n\nThe problem is that you have to rebuild the “computation graph”\n\nbefore you call .backward() for a second time. Both indexing\n\ninto a and setting that “value” to param count as part of the\n\ncomputation graph.\n\nConsider...
Cannot import name Field from torchtext.data
from torchtext.data import Field I am using pytorch 1.13 and torchtext 0.12.0
0
2022-11-25T09:37:43.157Z
Version 1.13 just works quite different now. You will need to check the docs and most recent examples/tutorials. I would argue that it became more light-weight since it focuses on the important parts, and no longer on preprocessing steps like tokenization. In short, FIELD is gone now. And to be ho&hellip;
1
2022-11-25T11:09:05.699Z
https://discuss.pytorch.org/t/cannot-import-name-field-from-torchtext-data/166885/2
Did you put test data and train data on the gpu like this train_data = train_data.to(device) test_data = test_data.to(device) ```? Can you send your train loop too? Hi Rishi! [image] snau: I tried your version and getting the same error. The problem is that you have to rebuild the “computation graph” before you...
473
{'text': ['Version 1.13 just works quite different now. You will need to check the docs and most recent examples/tutorials.\n\nI would argue that it became more light-weight since it focuses on the important parts, and no longer on preprocessing steps like tokenization.\n\nIn short, FIELD is gone now. And to be ho&hell...
How to predict the matrix before the last layer?
I have trained model with layers stacks in nn.Sequential for classification problem. The ConvNet architecture look like this: class ConvNet(nn.Module): def __init__(self,num_classes=8): super(ConvNet,self).__init__() self.layer1 = nn.Sequential( nn.Conv2d(1,64,kerne&hellip;
0
2020-03-31T14:44:10.499Z
Sorry for being not clear enough. You won’t be able to copy the child modules directly to an nn.Sequential container, as all functional calls as well as locally defined modules in the original forward function will be missing. Also, removed contains the order of modules as they were created in the&hellip;
1
2020-04-03T05:51:12.278Z
https://discuss.pytorch.org/t/how-to-predict-the-matrix-before-the-last-layer/74908/6
Sorry for being not clear enough. You won’t be able to copy the child modules directly to an nn.Sequential container, as all functional calls as well as locally defined modules in the original forward function will be missing. Also, removed contains the order of modules as they were created in the&hellip; Found the i...
1,562
{'text': ['Sorry for being not clear enough.\n\nYou won’t be able to copy the child modules directly to an nn.Sequential container, as all functional calls as well as locally defined modules in the original forward function will be missing.\n\nAlso, removed contains the order of modules as they were created in the&hell...