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
Torch.empty doesn't work
When I try to create a tensor using torch.empty() i get the following: >>> torch.empty(5) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/diego/anaconda3/lib/python3.6/site-packages/torch/tensor.py", line 57, in __repr__ return torch._tens...
0
2018-04-27T20:59:03.488Z
And yes, that is correct. You can apply operations but can’t print the value. This happens because torch.empty initializes your tensor with “un-initialized” data. Some of this data happened to have very, very large float values. The tensor printing code attempts to convert this number to an int (to…
2
2018-04-27T21:37:39.559Z
https://discuss.pytorch.org/t/torch-empty-doesnt-work/17147/5
Yes, weight initialization is one crucial step in training a network from scratch. PyTorch has a lot of different <a href="http://pytorch.org/docs/master/nn.html#torch-nn-init" rel="nofollow noopener">init functions</a>. E.g. one popular method for conv layers is xavier_uniform. Depending on your architecture, differ...
551
{'text': ['And yes, that is correct. You can apply operations but can’t print the value.\n\nThis happens because torch.empty initializes your tensor with “un-initialized” data. Some of this data happened to have very, very large float values. The tensor printing code attempts to convert this number to an int (to&hellip...
What classification loss should I choose when I have used a softmax function?
Just as the title, I must use the result of softmax,then I want to use a loss. I found that NLLLoss must be after log_softmax,if I just compute a log for the result of softmax,is that right? As for nn.CrossEntropyLoss(),there can’t be a softmax. Could you please tell me which loss should I choos&hellip;
0
2019-12-27T07:15:13.601Z
Hello Chunchun! [image] chunchun: I must use the result of softmax [image] chunchun: That’s very clear,but I must use the layer which can supply propabilities. In general, there is no particular need to use probabilities to feed into your loss function. If your use case requires pro&hellip;
2
2020-01-02T02:18:44.592Z
https://discuss.pytorch.org/t/what-classification-loss-should-i-choose-when-i-have-used-a-softmax-function/65121/10
Hello Chunchun! [image] chunchun: I must use the result of softmax [image] chunchun: That’s very clear,but I must use the layer which can supply propabilities. In general, there is no particular need to use probabilities to feed into your loss function. If your use case requires pro&hellip; Try use pytorch_andro...
1,718
{'text': ['Hello Chunchun!\n\n[image] chunchun:\n\nI must use the result of softmax\n\n[image] chunchun:\n\nThat’s very clear,but I must use the layer which can supply propabilities.\n\nIn general, there is no particular need to use probabilities to feed\n\ninto your loss function.\n\nIf your use case requires pro&hell...
Unable to get pytorch 1.9 working on Android, couldn't find "libpytorch_jni.so"
Hi, I am super excited to see 1.9 release so I give a try, however I can’t get the hello world working. if I simple change dependencies from implementation &#39;org.pytorch:pytorch_android:1.8.0-SNAPSHOT&#39; implementation &#39;org.pytorch:pytorch_android_torchvision:1.8.0-SNAPSHOT&#39; to implemen&hellip;
0
2021-06-16T15:37:22.305Z
Try use pytorch_android_lite, Look the project (<a href="https://github.com/pytorch/android-demo-app/tree/master/ObjectDetection" class="inline-onebox" rel="noopener nofollow ugc">android-demo-app/ObjectDetection at master · pytorch/android-demo-app · GitHub</a>). The commit with update version. <a href="https://gith...
0
2021-06-19T17:14:31.086Z
https://discuss.pytorch.org/t/unable-to-get-pytorch-1-9-working-on-android-couldnt-find-libpytorch-jni-so/124280/3
Hello Chunchun! [image] chunchun: I must use the result of softmax [image] chunchun: That’s very clear,but I must use the layer which can supply propabilities. In general, there is no particular need to use probabilities to feed into your loss function. If your use case requires pro&hellip; Try use pytorch_andro...
1,158
{'text': ['Try use pytorch_android_lite,\n\nLook the project (<a href="https://github.com/pytorch/android-demo-app/tree/master/ObjectDetection" class="inline-onebox" rel="noopener nofollow ugc">android-demo-app/ObjectDetection at master · pytorch/android-demo-app · GitHub</a>). The commit with update version.\n\n<a hre...
Why we skip initialize running mean and running var while using pretrained resnet50?
Hi everyone I am new to pytorch and there’s one issue that really confuses me When I try to use transfer learning and take the resnet50 as base from this link <a href="https://github.com/pytorch/vision/blob/master/torchvision/models/resnet.py" rel="nofollow noopener">vision/torchvision/models/resnet.py </a> And do...
1
2019-12-12T03:49:35.760Z
You are only saving the parameters in these lines of code: names = {} for name,param in model_resnet.named_parameters(): names[name] = 0 while the running estimates are stored as buffers. You could append these buffers using: for name, buf in model_resnet.named_buffers(): names[name] = 0&hellip;
2
2019-12-12T04:06:57.077Z
https://discuss.pytorch.org/t/why-we-skip-initialize-running-mean-and-running-var-while-using-pretrained-resnet50/63815/2
Hello Chunchun! [image] chunchun: I must use the result of softmax [image] chunchun: That’s very clear,but I must use the layer which can supply propabilities. In general, there is no particular need to use probabilities to feed into your loss function. If your use case requires pro&hellip; Try use pytorch_andro...
840
{'text': ['You are only saving the parameters in these lines of code:\n\nnames = {}\n\nfor name,param in model_resnet.named_parameters():\n\nnames[name] = 0\n\nwhile the running estimates are stored as buffers.\n\nYou could append these buffers using:\n\nfor name, buf in model_resnet.named_buffers():\n\nnames[name] = 0...
Different Losses on 2 different machines
Hi, I came across a problem: I am running the same model on 2 different machines, one is a single GPU 1080Ti and the other one is 2x GPUs RTX2080Ti, but the model is running on a single 2080Ti. The problem is that the model runs just fine on my single 1080Ti GPU, however, when the model is run on &hellip;
0
2019-02-05T16:24:16.641Z
Both were 1.0.1 installed through conda. So, one of the cards always results in issues running the model, the other one runs just fine (I tried them both separate in different PCIe ports). I am not sure how CUDA processes the information on the device but it seems that something wrong with the GPU a&hellip;
1
2019-02-06T21:54:39.178Z
https://discuss.pytorch.org/t/different-losses-on-2-different-machines/36446/20
Both were 1.0.1 installed through conda. So, one of the cards always results in issues running the model, the other one runs just fine (I tried them both separate in different PCIe ports). I am not sure how CUDA processes the information on the device but it seems that something wrong with the GPU a&hellip; Hi, This m...
2,286
{'text': ['Both were 1.0.1 installed through conda. So, one of the cards always results in issues running the model, the other one runs just fine (I tried them both separate in different PCIe ports). I am not sure how CUDA processes the information on the device but it seems that something wrong with the GPU a&hellip;'...
Training with gradient checkpoints (torch.utils.checkpoint) appears to reduce performance of model
I have a snippet of code that uses gradient checkpoints from torch.utils.checkpoint to reduce GPU memory: if use_checkpointing: res2, res3, res4, res5 = checkpoint.checkpoint(self.resnet_backbone, data[&#39;data&#39;]) fpn_p2, fpn_p3, fpn_p4, fpn_p5, fpn_p6 = checkpoint.checkpoint(self.&hellip;
1
2020-04-23T17:48:38.330Z
Hi, This most likely happens because the first part of your model doesn’t get gradient because of some quirks of how checkpointing works. Can you try making data[&#39;data&#39;] require gradients before giving it to the checkpoint? (you can ignore the computed gradient, just add a data[&#39;data&#39;].requires_gr&hel...
2
2020-04-23T18:11:01.255Z
https://discuss.pytorch.org/t/training-with-gradient-checkpoints-torch-utils-checkpoint-appears-to-reduce-performance-of-model/78102/2
Both were 1.0.1 installed through conda. So, one of the cards always results in issues running the model, the other one runs just fine (I tried them both separate in different PCIe ports). I am not sure how CUDA processes the information on the device but it seems that something wrong with the GPU a&hellip; Hi, This m...
1,452
{'text': ['Hi,\n\nThis most likely happens because the first part of your model doesn’t get gradient because of some quirks of how checkpointing works.\n\nCan you try making data[&#39;data&#39;] require gradients before giving it to the checkpoint? (you can ignore the computed gradient, just add a data[&#39;data&#39;]....
TypeError: float() argument must be a string or a number, not 'ViolenceModel'
Hi can anyone help me how to solve this problem please :slight_smile: model = ViolenceModel(modelUsed,pretrained) svclassifier = SVC(kernel=&#39;linear&#39;) trainParams = [] for params in model.parameters(): if params.requires_grad: trainParams += [params] model.trai&hellip;
0
2019-07-05T17:32:12.007Z
features seems not to be detached, so could you call features = features.detach().cpu().numpy() before passing it to the svm?
0
2019-07-06T23:27:25.386Z
https://discuss.pytorch.org/t/typeerror-float-argument-must-be-a-string-or-a-number-not-violencemodel/49827/11
Both were 1.0.1 installed through conda. So, one of the cards always results in issues running the model, the other one runs just fine (I tried them both separate in different PCIe ports). I am not sure how CUDA processes the information on the device but it seems that something wrong with the GPU a&hellip; Hi, This m...
634
{'text': ['features seems not to be detached, so could you call features = features.detach().cpu().numpy() before passing it to the svm?'], 'answer_start': [634]}
Dataparallel model with custom functions
The dataparallel tutorial states that if we want to invoke custom functions we made in our model. We’d have to wrap our model into a subclass of data parallel where the subclass is supposed to look something like this. class MyDataParallel(nn.DataParallel): def __getattr__(self, name): &hellip;
0
2020-04-01T22:31:05.324Z
Sorry, it’s not like I’m not addressing it but I don’t recomend it. The main issue here is that module is a nn.Module. Then it’s hidden in _modules private dict. The way they designed to gather nn.Modules is through getattr. As you are overwritting getattr it gets into a infinity recursion. I rea&hellip;
2
2020-04-07T13:32:59.716Z
https://discuss.pytorch.org/t/dataparallel-model-with-custom-functions/75053/8
Sorry, it’s not like I’m not addressing it but I don’t recomend it. The main issue here is that module is a nn.Module. Then it’s hidden in _modules private dict. The way they designed to gather nn.Modules is through getattr. As you are overwritting getattr it gets into a infinity recursion. I rea&hellip; Yes your ap...
1,518
{'text': ['Sorry, it’s not like I’m not addressing it but I don’t recomend it.\n\nThe main issue here is that module is a nn.Module. Then it’s hidden in _modules private dict. The way they designed to gather nn.Modules is through getattr. As you are overwritting getattr it gets into a infinity recursion.\n\nI rea&hell...
Torch.argmax returns a tensor containing all zeros?
Ive trained my segmentation network using a U-Net model. I want to now visualize the result from the network output. Theshape of output is [1,2,256,256]. One channel for background and the other for foreground. Here is what I get for print(output.detach().squeeze()): tensor([[[ 6.1109, 6.1109, 6&hellip;
0
2019-01-08T19:23:17.787Z
Yes your approach is right and I still think that the zero tensor is a valid answer, if your model just overfits to class0. Have a look at this example: x = torch.cat((torch.ones(1, 1, 5, 5), torch.zeros(1, 1, 5, 5)), 1) print(x) &gt; tensor([[[[1., 1., 1., 1., 1.], [1., 1., 1., 1., 1.], &hellip;
1
2019-01-08T20:06:39.722Z
https://discuss.pytorch.org/t/torch-argmax-returns-a-tensor-containing-all-zeros/34161/5
Sorry, it’s not like I’m not addressing it but I don’t recomend it. The main issue here is that module is a nn.Module. Then it’s hidden in _modules private dict. The way they designed to gather nn.Modules is through getattr. As you are overwritting getattr it gets into a infinity recursion. I rea&hellip; Yes your ap...
1,068
{'text': ['Yes your approach is right and I still think that the zero tensor is a valid answer, if your model just overfits to class0.\n\nHave a look at this example:\n\nx = torch.cat((torch.ones(1, 1, 5, 5), torch.zeros(1, 1, 5, 5)), 1)\n\nprint(x)\n\n&gt; tensor([[[[1., 1., 1., 1., 1.],\n\n[1., 1., 1., 1., 1.],\n\n&h...
Speed of Custom RNN is SUPER SLOW
Hi, Based on code here <a href="https://github.com/pytorch/pytorch/blob/master/benchmarks/fastrnns/custom_lstms.py" rel="nofollow noopener">https://github.com/pytorch/pytorch/blob/master/benchmarks/fastrnns/custom_lstms.py</a> I write an example to compare the cumputation capability of native lstm and custom lstm. ...
0
2019-12-06T07:47:20.210Z
The TorchScript runtime does some optimizations on the first pass (it assumes you will be running your compiled model’s inference many times), so this is likely why it looks much slower. Could you try running custom_lstm a couple times before you benchmark it and comparing?
0
2019-12-06T18:03:26.231Z
https://discuss.pytorch.org/t/speed-of-custom-rnn-is-super-slow/63209/2
Sorry, it’s not like I’m not addressing it but I don’t recomend it. The main issue here is that module is a nn.Module. Then it’s hidden in _modules private dict. The way they designed to gather nn.Modules is through getattr. As you are overwritting getattr it gets into a infinity recursion. I rea&hellip; Yes your ap...
613
{'text': ['The TorchScript runtime does some optimizations on the first pass (it assumes you will be running your compiled model’s inference many times), so this is likely why it looks much slower. Could you try running custom_lstm a couple times before you benchmark it and comparing?'], 'answer_start': [613]}
Expected object of device type cuda but got device type cpu for argument #1 'self' in call to _th_mm
This is my model. Only showing the __ init __() and forward() functions class BERTplusAoA(nn.Module): def __init__(self, config, options): super(BERTplusAoA, self).__init__() self.bert = BertModel.from_pretrained( options.model_name_or_path, from_tf=bool(&quot;.ckpt&quot;&hellip;
0
2020-06-25T16:15:54.162Z
Hi, Try this in the line you defined Hq = self.lq(hq): self.lq = self.lq.float() Hq = self.lq(hq) Similar case: # no error linear = nn.Linear(1, 5).half().cuda() x = torch.randn(1, 5, 1).cuda() linear = linear.float() linear(x) # your error linear = nn.Linear(1, 5).half().cuda() x = torch.rand&hellip;
2
2020-06-26T13:44:37.771Z
https://discuss.pytorch.org/t/expected-object-of-device-type-cuda-but-got-device-type-cpu-for-argument-1-self-in-call-to-th-mm/86921/21
Hi, Try this in the line you defined Hq = self.lq(hq): self.lq = self.lq.float() Hq = self.lq(hq) Similar case: # no error linear = nn.Linear(1, 5).half().cuda() x = torch.randn(1, 5, 1).cuda() linear = linear.float() linear(x) # your error linear = nn.Linear(1, 5).half().cuda() x = torch.rand&hellip; Yes, ...
1,774
{'text': ['Hi,\n\nTry this in the line you defined Hq = self.lq(hq):\n\nself.lq = self.lq.float()\n\nHq = self.lq(hq)\n\nSimilar case:\n\n# no error\n\nlinear = nn.Linear(1, 5).half().cuda()\n\nx = torch.randn(1, 5, 1).cuda()\n\nlinear = linear.float()\n\nlinear(x)\n\n# your error\n\nlinear = nn.Linear(1, 5).half().cud...
My server crashed after running this code?
Hi guys, I am trying to fine tuning BERT with Pytorch. And I use torch.nn.Parallel to train the model in 8 GPUs. After the evalution I delete the model and using torch.cuda.empty_cache(). The most interesting is that when the script is running, my server is good. But one I click the “Interrupt the &hellip;
1
2020-01-06T03:20:26.558Z
Yes, the samples numbers are “correct”, but as you can see they are not fixed. I would recommend to store the randomly initialized state_dicts once and just reload them to the appropriate model during your experiments, to get reproducible results. This would at least reuse the same parameters. No&hellip;
2
2020-01-08T08:14:10.460Z
https://discuss.pytorch.org/t/my-server-crashed-after-running-this-code/65860/9
Hi, Try this in the line you defined Hq = self.lq(hq): self.lq = self.lq.float() Hq = self.lq(hq) Similar case: # no error linear = nn.Linear(1, 5).half().cuda() x = torch.randn(1, 5, 1).cuda() linear = linear.float() linear(x) # your error linear = nn.Linear(1, 5).half().cuda() x = torch.rand&hellip; Yes, ...
1,202
{'text': ['Yes, the samples numbers are “correct”, but as you can see they are not fixed.\n\nI would recommend to store the randomly initialized state_dicts once and just reload them to the appropriate model during your experiments, to get reproducible results.\n\nThis would at least reuse the same parameters.\n\nNo&he...
Died with <Signals.SIGKILL: 9>. When in first epoch, the program is killed
When the program was killed, there was no other information: The error info is like below: <a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/e/1/e12d887e3402061f332463a6658d7135c133df6a.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/e12d887e3402061f332463a6658d71...
0
2021-09-11T20:47:14.869Z
This problem has been solved now! The bug is that when you zip or cycle image DataLoader, there might be a memory leakage! So, the memory of the CPU taken by training will be increasing with time going. The code is updated: def train_one_epoch_dg(model, optimizer, data_loaders, device, epoch, war&hellip;
3
2021-09-12T16:20:35.162Z
https://discuss.pytorch.org/t/died-with-signals-sigkill-9-when-in-first-epoch-the-program-is-killed/131704/10
Hi, Try this in the line you defined Hq = self.lq(hq): self.lq = self.lq.float() Hq = self.lq(hq) Similar case: # no error linear = nn.Linear(1, 5).half().cuda() x = torch.randn(1, 5, 1).cuda() linear = linear.float() linear(x) # your error linear = nn.Linear(1, 5).half().cuda() x = torch.rand&hellip; Yes, ...
624
{'text': ['This problem has been solved now!\n\nThe bug is that when you zip or cycle image DataLoader, there might be a memory leakage! So, the memory of the CPU taken by training will be increasing with time going.\n\nThe code is updated:\n\ndef train_one_epoch_dg(model, optimizer, data_loaders, device, epoch, war&he...
How does pytorch’s batch norm know if the forward pass its doing is for inference or training?
how does pytorch’s batch norm know if the forward pass its doing is for inference or training? I am evaluating the the test performance of my net but realized that I’m not sure how my net knows if its training phase or inference phase. How does pytorch handle this?
1
2018-04-24T00:08:48.117Z
Hi, In the source code <a href="http://pytorch.org/docs/stable/_modules/torch/nn/modules/batchnorm.html#BatchNorm2d" rel="nofollow noopener">here</a>, the function F.batch_norm has the parameter self.training, when you train model, you use model.train() when you test, you use model.eval() the model.train() tells t...
1
2018-04-24T00:15:16.977Z
https://discuss.pytorch.org/t/how-does-pytorch-s-batch-norm-know-if-the-forward-pass-its-doing-is-for-inference-or-training/16857/2
Hi, In the source code <a href="http://pytorch.org/docs/stable/_modules/torch/nn/modules/batchnorm.html#BatchNorm2d" rel="nofollow noopener">here</a>, the function F.batch_norm has the parameter self.training, when you train model, you use model.train() when you test, you use model.eval() the model.train() tells t...
1,864
{'text': ['Hi,\n\nIn the source code <a href="http://pytorch.org/docs/stable/_modules/torch/nn/modules/batchnorm.html#BatchNorm2d" rel="nofollow noopener">here</a>,\n\nthe function F.batch_norm has the parameter self.training,\n\nwhen you train model, you use model.train()\n\nwhen you test, you use model.eval()\n\nthe ...
Expected cuda got cpu
TypeError: expected TensorOptions(dtype=long int, device=cpu, layout=Strided, requires_grad=false (default), pinned_memory=false (default), memory_format=(nullopt)) (got TensorOptions(dtype=long int, device=cuda:0, layout=Strided, requires_grad=false (default), pinned_memory=false (default), memory_&hellip;
0
2021-09-24T19:43:25.297Z
I don’t know where the code is coming from and if But still not sure why i am not able to convert to floatTensor. is a new issue or related to the device mismatch. Your current code is unfortunately still not executable. To debug further, check the stacktrace of the error message and narrow do&hellip;
1
2021-09-24T22:10:33.541Z
https://discuss.pytorch.org/t/expected-cuda-got-cpu/132747/11
Hi, In the source code <a href="http://pytorch.org/docs/stable/_modules/torch/nn/modules/batchnorm.html#BatchNorm2d" rel="nofollow noopener">here</a>, the function F.batch_norm has the parameter self.training, when you train model, you use model.train() when you test, you use model.eval() the model.train() tells t...
1,282
{'text': ['I don’t know where the code is coming from and if\n\nBut still not sure why i am not able to convert to floatTensor.\n\nis a new issue or related to the device mismatch.\n\nYour current code is unfortunately still not executable.\n\nTo debug further, check the stacktrace of the error message and narrow do&he...
Is torch.max same with doing maxpooling
Hi everyone, Assume, I have representation x = torch.rand(4,8) for my input sentence. (without batch dimension, it is just a single sentence containing 4 words). I want to get 1x8 dimensional tensor as output. I can obtain this with a maxpooling operation. However, since all of my sentences have di&hellip;
0
2019-05-14T20:14:24.888Z
If you would create the max pooling layer so that the kernel size equals the input size in the temporal or spatial dimension, then yes, you can alternatively use torch.max. Based on the input shape and your desired output shape of [1, 8], you could use torch.max(x, 0, keepdim=True)[0]. Alternative&hellip;
0
2019-05-14T21:31:40.302Z
https://discuss.pytorch.org/t/is-torch-max-same-with-doing-maxpooling/45239/2
Hi, In the source code <a href="http://pytorch.org/docs/stable/_modules/torch/nn/modules/batchnorm.html#BatchNorm2d" rel="nofollow noopener">here</a>, the function F.batch_norm has the parameter self.training, when you train model, you use model.train() when you test, you use model.eval() the model.train() tells t...
657
{'text': ['If you would create the max pooling layer so that the kernel size equals the input size in the temporal or spatial dimension, then yes, you can alternatively use torch.max.\n\nBased on the input shape and your desired output shape of [1, 8], you could use torch.max(x, 0, keepdim=True)[0].\n\nAlternative&hell...
Converting Tensorflow code to Pytorch help
I have this simple tensorflow code block, what is the equivalent in pytorch? I am stuck trying to code it. I have encountered multiple Runtime errors, due to the dimensions. This is the tensorflow code: conv1 = tf.nn.conv1d(x,f1,stride=1,padding=&quot;VALID&quot;) conv1 = tf.nn.bias_add(conv1, b1) conv1 = t&hellip;
0
2020-01-08T18:50:07.164Z
The tensorflow conv1d takes as input batch x width x channel no? So your Tensorflow code is wrong?
0
2020-01-09T14:41:06.594Z
https://discuss.pytorch.org/t/converting-tensorflow-code-to-pytorch-help/66123/18
The tensorflow conv1d takes as input batch x width x channel no? So your Tensorflow code is wrong? Update: The main error was due to the difference between floating point precision in cpu and gpu for float32 type. I converted all my operations to float64 type including the neural layers. The loss is reducing on cpu an...
1,930
{'text': ['The tensorflow conv1d takes as input batch x width x channel no? So your Tensorflow code is wrong?'], 'answer_start': [1930]}
Different loss for cpu and gpu
I am training a bilinear similarity model with a multi-label max-margin loss function. The problem I have is that the model trains perfectly fine on the cpu and returns expected results (close to the baseline). However, the model returns completely incorrect results when I train the system on the gp&hellip;
0
2019-09-17T16:12:48.835Z
Update: The main error was due to the difference between floating point precision in cpu and gpu for float32 type. I converted all my operations to float64 type including the neural layers. The loss is reducing on cpu and gpu at almost the same rate. The reason I say “almost” is because I am using n&hellip;
3
2019-09-22T19:01:35.955Z
https://discuss.pytorch.org/t/different-loss-for-cpu-and-gpu/56175/22
The tensorflow conv1d takes as input batch x width x channel no? So your Tensorflow code is wrong? Update: The main error was due to the difference between floating point precision in cpu and gpu for float32 type. I converted all my operations to float64 type including the neural layers. The loss is reducing on cpu an...
1,064
{'text': ['Update: The main error was due to the difference between floating point precision in cpu and gpu for float32 type.\n\nI converted all my operations to float64 type including the neural layers. The loss is reducing on cpu and gpu at almost the same rate. The reason I say “almost” is because I am using n&helli...
Support for AMD ROCm gpu
Is there ongoing work to try to bring PyTorch support for AMD gpus?
0
2020-07-24T13:04:33.421Z
You can choose which GPU archs you want to support by providing a comma separated list at build-time (I have instructions for <a href="https://lernapparat.de/pytorch-rocm/" rel="nofollow noopener">building for ROCm</a> on my blog) or use an <a href="https://rocmdocs.amd.com/en/latest/Deep_learning/Deep-learning.html#py...
2
2020-07-24T14:22:22.592Z
https://discuss.pytorch.org/t/support-for-amd-rocm-gpu/90404/6
The tensorflow conv1d takes as input batch x width x channel no? So your Tensorflow code is wrong? Update: The main error was due to the difference between floating point precision in cpu and gpu for float32 type. I converted all my operations to float64 type including the neural layers. The loss is reducing on cpu an...
409
{'text': ['You can choose which GPU archs you want to support by providing a comma separated list at build-time (I have instructions for <a href="https://lernapparat.de/pytorch-rocm/" rel="nofollow noopener">building for ROCm</a> on my blog) or use an <a href="https://rocmdocs.amd.com/en/latest/Deep_learning/Deep-learn...
How to save the gradient after each batch (or epoch)?
I have an MLP model and I want to save the gradient after each iteration and average it at the last. How I can do that? model: class MyModel(torch.nn.Module): def __init__(self, layers_size, input_size=784, num_classes=10): super(MyModel, self).__init__() # create input laye&hellip;
0
2020-09-30T16:56:57.868Z
Each backward() call will accumulate the gradients in the .grad attribute of the parameters. You could thus accumulate the gradients in your data loop and calculate the average afterwards by iterating all parameters and dividing the .grads by the number of steps. Alternatively you could also use t&hellip;
0
2020-10-01T04:12:17.736Z
https://discuss.pytorch.org/t/how-to-save-the-gradient-after-each-batch-or-epoch/97839/2
Each backward() call will accumulate the gradients in the .grad attribute of the parameters. You could thus accumulate the gradients in your data loop and calculate the average afterwards by iterating all parameters and dividing the .grads by the number of steps. Alternatively you could also use t&hellip; No sure why...
1,620
{'text': ['Each backward() call will accumulate the gradients in the .grad attribute of the parameters.\n\nYou could thus accumulate the gradients in your data loop and calculate the average afterwards by iterating all parameters and dividing the .grads by the number of steps.\n\nAlternatively you could also use t&hell...
Optimizing diagonal stripe code
I need to get a diagonal stripe of the matrix. Say, I have a matrix of size KxN, where K and N are arbitrary sizes and K&gt;N. Given a matrix: [[ 0 1 2] [ 3 4 5] [ 6 7 8] [ 9 10 11]] From it I would need to extract a diagonal stripe, in this case, a matrix MxV size that is created by truncat&hellip;
0
2018-05-09T06:16:53.507Z
No sure why you would like to set the argument dim=3 when the tensor a is of dimension 3 thus only has dimensions 0,1,2. Maybe this is what you want? import torch def flip(x, dim): indices = [slice(None)] * x.dim() indices[dim] = torch.arange(x.size(dim) - 1, -1, -1, &hellip;
1
2018-05-23T20:17:22.890Z
https://discuss.pytorch.org/t/optimizing-diagonal-stripe-code/17777/17
Each backward() call will accumulate the gradients in the .grad attribute of the parameters. You could thus accumulate the gradients in your data loop and calculate the average afterwards by iterating all parameters and dividing the .grads by the number of steps. Alternatively you could also use t&hellip; No sure why...
1,119
{'text': ['No sure why you would like to set the argument dim=3 when the tensor a is of dimension 3 thus only has dimensions 0,1,2. Maybe this is what you want?\n\nimport torch\n\ndef flip(x, dim):\n\nindices = [slice(None)] * x.dim()\n\nindices[dim] = torch.arange(x.size(dim) - 1, -1, -1,\n\n&hellip;'], 'answer_start'...
How to delete every grad after training?
Is there a way to delete all .grad attributes after training? I am currently implementing some pruning techniques that reduce the dimensions of the weight tensors in convolution layers. For this to work I need to set all gradients to None or delete them since they don’t match the size of the filter&hellip;
0
2019-12-10T17:33:25.243Z
Hooo one more proof for <a href="https://github.com/pytorch/pytorch/issues/30987">https://github.com/pytorch/pytorch/issues/30987</a> that .data is the source of all evil ! The short answer is: do not use .data :slight_smile: The longer answer is: m.weight= nn.Parameter(torch.cat((m.weight[:filter[1]], m.weight[fil...
3
2019-12-10T20:14:19.508Z
https://discuss.pytorch.org/t/how-to-delete-every-grad-after-training/63644/9
Each backward() call will accumulate the gradients in the .grad attribute of the parameters. You could thus accumulate the gradients in your data loop and calculate the average afterwards by iterating all parameters and dividing the .grads by the number of steps. Alternatively you could also use t&hellip; No sure why...
591
{'text': ['Hooo one more proof for <a href="https://github.com/pytorch/pytorch/issues/30987">https://github.com/pytorch/pytorch/issues/30987</a> that .data is the source of all evil !\n\nThe short answer is: do not use .data :slight_smile:\n\nThe longer answer is:\n\nm.weight= nn.Parameter(torch.cat((m.weight[:filter[...
RuntimeError: size mismatch, m1: [512 x 1], m2: [512 x 15] at /pytorch/aten/src/THC/generic/THCTensorMathBlas.cu:290
Hi I’m using Resnet18(Not Pre-trained) for training images with shape(1, 224, 224) I have 15 output classes. Hence I have modified the first conv2d and the last linear layer accordingly. Blockquote Sequential( (0): Conv2d(1, 64, kernel_size=(7, 7), stride=(2, 2), padding=(3, 3)) (1): BatchN&hellip;
0
2020-02-22T20:00:49.408Z
It seems you’ve wrapped all modules into an nn.Sequential block. If that’s the case, you are removing the flattening, which is used <a href="https://github.com/pytorch/vision/blob/6c2cda6a0eda4c835f96f18bb2b3be5043d96ad2/torchvision/models/resnet.py#L210">here</a> directly in the forward method. You could keep the or...
1
2020-02-22T20:31:59.111Z
https://discuss.pytorch.org/t/runtimeerror-size-mismatch-m1-512-x-1-m2-512-x-15-at-pytorch-aten-src-thc-generic-thctensormathblas-cu-290/70702/2
It seems you’ve wrapped all modules into an nn.Sequential block. If that’s the case, you are removing the flattening, which is used <a href="https://github.com/pytorch/vision/blob/6c2cda6a0eda4c835f96f18bb2b3be5043d96ad2/torchvision/models/resnet.py#L210">here</a> directly in the forward method. You could keep the or...
1,922
{'text': ['It seems you’ve wrapped all modules into an nn.Sequential block.\n\nIf that’s the case, you are removing the flattening, which is used <a href="https://github.com/pytorch/vision/blob/6c2cda6a0eda4c835f96f18bb2b3be5043d96ad2/torchvision/models/resnet.py#L210">here</a> directly in the forward method.\n\nYou co...
Forward and backward about pytorch
Hi, I want to ask about the difference between the following two pieces of code: class ModelOutputs(): &quot;&quot;&quot; Class for making a forward pass, and getting: 1. The network output. 2. Activations from intermeddiate targetted layers. 3. Gradients from intermeddiate targetted layers. &quot;&quot;&quot; &h...
0
2019-07-09T07:17:16.685Z
I’m not sure, why the shapes differ, but apparently the wrong gradients are stored. Here is a small dummy example using vgg16: grads = [] def save_grad(grad): grads.append(grad) # Create model model = models.vgg16() model.eval() # First approach x = torch.randn(1, 3, 224, 224) output = model&hellip;
1
2019-07-12T10:55:54.290Z
https://discuss.pytorch.org/t/forward-and-backward-about-pytorch/50089/8
It seems you’ve wrapped all modules into an nn.Sequential block. If that’s the case, you are removing the flattening, which is used <a href="https://github.com/pytorch/vision/blob/6c2cda6a0eda4c835f96f18bb2b3be5043d96ad2/torchvision/models/resnet.py#L210">here</a> directly in the forward method. You could keep the or...
1,399
{'text': ['I’m not sure, why the shapes differ, but apparently the wrong gradients are stored.\n\nHere is a small dummy example using vgg16:\n\ngrads = []\n\ndef save_grad(grad):\n\ngrads.append(grad)\n\n# Create model\n\nmodel = models.vgg16()\n\nmodel.eval()\n\n# First approach\n\nx = torch.randn(1, 3, 224, 224)\n\no...
[Newb] Is there a way to step into Variable._execution_engine.run_backward()
Hi I am trying to understand/instrument autograd in PyTorch. I’ve put a pdb.set_trace() before backward and traced the code until Variable._execution_engine.run_backward() is called which prevents pdb to step into. I presume this is where the code calls C++ extensions. If so, is there a way to con&hellip;
0
2019-02-25T23:36:28.734Z
The cpp engine is based on <a href="https://github.com/pytorch/pytorch/blob/master/torch/csrc/autograd/function.h" rel="nofollow noopener">Function</a> which are similar to the python ones. They are the elementary operations that are considered. The forward pass attaches a grad_fn to the Tensors during the forward pas...
0
2019-02-26T16:20:46.133Z
https://discuss.pytorch.org/t/newb-is-there-a-way-to-step-into-variable-execution-engine-run-backward/38230/4
It seems you’ve wrapped all modules into an nn.Sequential block. If that’s the case, you are removing the flattening, which is used <a href="https://github.com/pytorch/vision/blob/6c2cda6a0eda4c835f96f18bb2b3be5043d96ad2/torchvision/models/resnet.py#L210">here</a> directly in the forward method. You could keep the or...
749
{'text': ['The cpp engine is based on <a href="https://github.com/pytorch/pytorch/blob/master/torch/csrc/autograd/function.h" rel="nofollow noopener">Function</a> which are similar to the python ones. They are the elementary operations that are considered.\n\nThe forward pass attaches a grad_fn to the Tensors during th...
Getting "can't export a trace that didn't finish running" error with profiler
Hi I have a transformer encoder and I’m testing it with the following code: import torch import torch.autograd.profiler as profiler encoder = torch.jit.load(&#39;eval/encoder.zip&#39;) tmp = torch.ones([1, 7, 80]) len = torch.Tensor([7]) #Warmup encoder.forward(tmp, len) encoder.forward(tmp, len) prin&hellip;
1
2021-01-20T01:52:53.319Z
Solved: The print(prof) line should be outside the with block.
3
2021-01-20T04:30:09.150Z
https://discuss.pytorch.org/t/getting-cant-export-a-trace-that-didnt-finish-running-error-with-profiler/109386/2
Solved: The print(prof) line should be outside the with block. By having more processes simulatenously doing random access IO, good chance you’ll start overloading whatever IO device you’re reading from, it’s not a friendly read pattern and you’ll likely have a lot of processes blocked on IO. There will be a number of ...
2,346
{'text': ['Solved: The print(prof) line should be outside the with block.'], 'answer_start': [2346]}
The data loading time will always increase when increase the dataloader woker numbers?
In my imagenet task, I use lmdb file as dataset, here is my dataset: class ImageNetDataset(torch.utils.data.Dataset): def __init__(self, config, phase=&#39;train&#39;, transforms=None): data_root = config.DATASET.ROOT self.phase = phase self.lmdb_file = os.path.join(data_root, self.phase+&#39;.lmd&hellip;
1
2019-09-16T02:49:42.909Z
By having more processes simulatenously doing random access IO, good chance you’ll start overloading whatever IO device you’re reading from, it’s not a friendly read pattern and you’ll likely have a lot of processes blocked on IO. There will be a number of workers beyond which there is no point in i&hellip;
1
2019-09-17T00:48:25.531Z
https://discuss.pytorch.org/t/the-data-loading-time-will-always-increase-when-increase-the-dataloader-woker-numbers/56010/5
Solved: The print(prof) line should be outside the with block. By having more processes simulatenously doing random access IO, good chance you’ll start overloading whatever IO device you’re reading from, it’s not a friendly read pattern and you’ll likely have a lot of processes blocked on IO. There will be a number of ...
1,236
{'text': ['By having more processes simulatenously doing random access IO, good chance you’ll start overloading whatever IO device you’re reading from, it’s not a friendly read pattern and you’ll likely have a lot of processes blocked on IO. There will be a number of workers beyond which there is no point in i&hellip;'...
Autograd backward() call not updating loss
Hi I’m working on translating some style transfer Torch code to PyTorch and I’m running into some issues probably because I’m not using autograd correctly. I’m able to run all the way through the building of my network as well as optimization steps but the loss never decreases (it just outputs the s&hellip;
0
2018-09-29T13:33:14.145Z
Usualy yes (if you don’t use torch.no_grad or something similar. Could you provide a gist with a minimum working example? This would be helpful, since we would able to debug ourselves.
0
2018-10-05T12:53:47.885Z
https://discuss.pytorch.org/t/autograd-backward-call-not-updating-loss/26195/14
Solved: The print(prof) line should be outside the with block. By having more processes simulatenously doing random access IO, good chance you’ll start overloading whatever IO device you’re reading from, it’s not a friendly read pattern and you’ll likely have a lot of processes blocked on IO. There will be a number of ...
372
{'text': ['Usualy yes (if you don’t use torch.no_grad or something similar. Could you provide a gist with a minimum working example? This would be helpful, since we would able to debug ourselves.'], 'answer_start': [372]}
Custom Loss Function - Error: element 0 of tensors does not require grad and does not have grad_fn
Hi everyone! I’m trying to implement the global pair loss function from “Recognition of Action Units in the Wild with Deep Nets and a New Global-Local Loss”. I have to look at all possible pairs of the predictions. If the values in a pair are the same, then g_predictions = 1. If they are different,&hellip;
0
2020-07-04T13:16:19.425Z
Your initialization might be “unlucky”, as I’ve got some valid gradients in a couple of iterations (I also got a full zero gradient output): tensor([[ 0.0000, 0.0000, 0.0000], [ 6.8986, 10.3479, 10.3479], [ 0.0000, 0.0000, 0.0000], [13.0105, 19.5157, 19.5157], [ &hellip;
1
2020-07-07T03:02:54.850Z
https://discuss.pytorch.org/t/custom-loss-function-error-element-0-of-tensors-does-not-require-grad-and-does-not-have-grad-fn/87944/13
Your initialization might be “unlucky”, as I’ve got some valid gradients in a couple of iterations (I also got a full zero gradient output): tensor([[ 0.0000, 0.0000, 0.0000], [ 6.8986, 10.3479, 10.3479], [ 0.0000, 0.0000, 0.0000], [13.0105, 19.5157, 19.5157], [ &hellip; They key is the name that you assign to...
1,112
{'text': ['Your initialization might be “unlucky”, as I’ve got some valid gradients in a couple of iterations (I also got a full zero gradient output):\n\ntensor([[ 0.0000, 0.0000, 0.0000],\n\n[ 6.8986, 10.3479, 10.3479],\n\n[ 0.0000, 0.0000, 0.0000],\n\n[13.0105, 19.5157, 19.5157],\n\n[ &hellip;'], 'answer_start':...
Some detailed problem about torch.load_state_dict()
self.featureExtract = nn.Sequential( # 271 nn.Conv2d(configs[0], configs[1] , kernel_size=11, stride=2), # 131 nn.BatchNorm2d(configs[1]), nn.MaxPool2d(kernel_size=3, stride=2), #65 nn.ReLU(inplace=True), &hellip;
0
2018-12-12T15:04:03.987Z
They key is the name that you assign to the variable in the nn.Module, therefore class test(torch.nn.Module): def __init__(self): super(test,self).__init__() self.conv1 = torch.nn.Conv2d(10,15,10) self.customconv = torch.nn.Conv2d(100,1000,10) test() Out[7]: test( (c&hellip;
1
2018-12-13T08:10:49.257Z
https://discuss.pytorch.org/t/some-detailed-problem-about-torch-load-state-dict/31970/6
Your initialization might be “unlucky”, as I’ve got some valid gradients in a couple of iterations (I also got a full zero gradient output): tensor([[ 0.0000, 0.0000, 0.0000], [ 6.8986, 10.3479, 10.3479], [ 0.0000, 0.0000, 0.0000], [13.0105, 19.5157, 19.5157], [ &hellip; They key is the name that you assign to...
837
{'text': ['They key is the name that you assign to the variable in the nn.Module, therefore\n\nclass test(torch.nn.Module):\n\ndef __init__(self):\n\nsuper(test,self).__init__()\n\nself.conv1 = torch.nn.Conv2d(10,15,10)\n\nself.customconv = torch.nn.Conv2d(100,1000,10)\n\ntest()\n\nOut[7]:\n\ntest(\n\n(c&hellip;'], 'an...
Model with tensor and number operations errors in iOS
Traced a model and saved it using pytorch 1.3.1 with the following code. class TestModule(torch.nn.Module): def forward(self, W): g = 2 * W return g W = torch.rand(10) test_model = torch.jit.trace(test_model, [W]) test_model.save(&quot;test_model.pt&quot;) and loaded the model int&hellip;
1
2020-01-13T07:14:13.457Z
Hi <a class="mention" href="/u/mark_jimenez">@mark_jimenez</a>, can you add these two lines before running forward torch::autograd::AutoGradMode guard(false); at::AutoNonVariableTypeMode non_var_type_mode(true); The first one tells the engine to disable autograd, the second one is sort of a workaround. We can get ri...
0
2020-01-13T23:08:35.065Z
https://discuss.pytorch.org/t/model-with-tensor-and-number-operations-errors-in-ios/66482/2
Your initialization might be “unlucky”, as I’ve got some valid gradients in a couple of iterations (I also got a full zero gradient output): tensor([[ 0.0000, 0.0000, 0.0000], [ 6.8986, 10.3479, 10.3479], [ 0.0000, 0.0000, 0.0000], [13.0105, 19.5157, 19.5157], [ &hellip; They key is the name that you assign to...
566
{'text': ['Hi <a class="mention" href="/u/mark_jimenez">@mark_jimenez</a>, can you add these two lines before running forward\n\ntorch::autograd::AutoGradMode guard(false);\n\nat::AutoNonVariableTypeMode non_var_type_mode(true);\n\nThe first one tells the engine to disable autograd, the second one is sort of a workarou...
Implement a model similar to the UNet
I’m trying to implement a model which is similar to the Unet based the attached architecture. (Supplementary materials for: DeepLearningforSegmentationusinganOpenLarge-ScaleDatasetin2DEchocardiography) <a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/2X/8/8dc5c8ceb82f5f1e11f3e5c2d3920013...
0
2019-03-10T14:16:32.688Z
Edit: Think I got it wrong the first time. This time I’m concating asap in the UpConv and changed the out_channels in all the UpConv layers so it matches the kernel size from the picture (Kernel / Pool size). Also changed the order in the UpConv forward function. I haven’t doublechecked but let me k&hellip;
0
2019-03-10T18:29:14.509Z
https://discuss.pytorch.org/t/implement-a-model-similar-to-the-unet/39418/2
Edit: Think I got it wrong the first time. This time I’m concating asap in the UpConv and changed the out_channels in all the UpConv layers so it matches the kernel size from the picture (Kernel / Pool size). Also changed the order in the UpConv forward function. I haven’t doublechecked but let me k&hellip; After setti...
1,842
{'text': ['Edit: Think I got it wrong the first time. This time I’m concating asap in the UpConv and changed the out_channels in all the UpConv layers so it matches the kernel size from the picture (Kernel / Pool size). Also changed the order in the UpConv forward function. I haven’t doublechecked but let me k&hellip;'...
Expected tensor for argument #1 'input' to have the same type as tensor for argument #2 'weight'; but type CUDAType does not equal CUDAType (while checking arguments for cudnn_batch_norm)
I have a CNN and a LSTM that I want to connect together to form some sort of ConvLSTM. The first layer in the CNN has a batchnorm2d layer which is then connected to a convolutional layer. class ConvNet(nn.Module): def __init__(self, num_classes=20,flatten_size=2*5, inputs=3, recurrent=False): &hellip;
0
2019-08-26T10:44:02.536Z
After setting n_inputs=2560, the code runs fine on the CPU and the GPU and I get an output of shape [16, 4, 2560]. Could you check, if you are passing a ByteTensor as your input to the model? Make sure it’s a FloatTensor (or call .float() on it before passing to the model).
0
2019-08-26T12:52:40.110Z
https://discuss.pytorch.org/t/expected-tensor-for-argument-1-input-to-have-the-same-type-as-tensor-for-argument-2-weight-but-type-cudatype-does-not-equal-cudatype-while-checking-arguments-for-cudnn-batch-norm/54345/11
Edit: Think I got it wrong the first time. This time I’m concating asap in the UpConv and changed the out_channels in all the UpConv layers so it matches the kernel size from the picture (Kernel / Pool size). Also changed the order in the UpConv forward function. I haven’t doublechecked but let me k&hellip; After setti...
1,230
{'text': ['After setting n_inputs=2560, the code runs fine on the CPU and the GPU and I get an output of shape [16, 4, 2560].\n\nCould you check, if you are passing a ByteTensor as your input to the model?\n\nMake sure it’s a FloatTensor (or call .float() on it before passing to the model).'], 'answer_start': [1230]}
AttributeError: cannot assign module before Module.__init__() call even if initialized
I’m getting the following error: AttributeError: cannot assign module before Module.__init__() call. I’m trying to create an instance of my class : class ResNetGenerator(nn.Module): def __init__(self, input_nc=3, output_nc=3, n_residual_blocks=9, use_dropout=False): # super(ResNetGene&hellip;
0
2019-01-05T13:45:20.896Z
Oh, it seems I’ve missed an important line in the stack trace. File &quot;train.py&quot;, line 40, in &lt;module&gt; model = ColorizationCycleGAN(args) Could you check your definition of ColorizationCycleGAN? I would always recommend to update to the latest release, but this error seems unrelated to your PyT&hellip...
3
2019-01-05T21:35:39.161Z
https://discuss.pytorch.org/t/attributeerror-cannot-assign-module-before-module-init-call-even-if-initialized/33861/8
Edit: Think I got it wrong the first time. This time I’m concating asap in the UpConv and changed the out_channels in all the UpConv layers so it matches the kernel size from the picture (Kernel / Pool size). Also changed the order in the UpConv forward function. I haven’t doublechecked but let me k&hellip; After setti...
586
{'text': ['Oh, it seems I’ve missed an important line in the stack trace.\n\nFile &quot;train.py&quot;, line 40, in &lt;module&gt;\n\nmodel = ColorizationCycleGAN(args)\n\nCould you check your definition of ColorizationCycleGAN?\n\nI would always recommend to update to the latest release, but this error seems unrelated...
Can hook remove itself?
After it runs can hook remove itself from inside?
0
2019-09-05T14:56:24.418Z
You could try to access the handle from inside the hook: def hook(grad): print(grad) handle.remove() model = nn.Linear(1, 1) handle = model.weight.register_hook(hook) model(torch.randn(1, 1)).backward() model(torch.randn(1, 1)).backward() This code will print the gradient only once a&hellip;
5
2019-09-05T21:26:42.038Z
https://discuss.pytorch.org/t/can-hook-remove-itself/55266/4
You could try to access the handle from inside the hook: def hook(grad): print(grad) handle.remove() model = nn.Linear(1, 1) handle = model.weight.register_hook(hook) model(torch.randn(1, 1)).backward() model(torch.randn(1, 1)).backward() This code will print the gradient only once a&hellip; Yeah something like...
1,814
{'text': ['You could try to access the handle from inside the hook:\n\ndef hook(grad):\n\nprint(grad)\n\nhandle.remove()\n\nmodel = nn.Linear(1, 1)\n\nhandle = model.weight.register_hook(hook)\n\nmodel(torch.randn(1, 1)).backward()\n\nmodel(torch.randn(1, 1)).backward()\n\nThis code will print the gradient only once a&...
Learnable scalars
Hi, I am looking for mapping inputs by learnable scalars, this is correct? for batch_idx, (inputs, targets) in enumerate(trainloader): if use_cuda: inputs, targets = inputs.cuda(), targets.cuda() shape = torch.Size((batch_size, 3, 32, 32)) &hellip;
0
2020-02-06T00:36:34.190Z
Yeah something like this.
0
2020-02-07T13:33:47.843Z
https://discuss.pytorch.org/t/learnable-scalars/68797/11
You could try to access the handle from inside the hook: def hook(grad): print(grad) handle.remove() model = nn.Linear(1, 1) handle = model.weight.register_hook(hook) model(torch.randn(1, 1)).backward() model(torch.randn(1, 1)).backward() This code will print the gradient only once a&hellip; Yeah something like...
1,208
{'text': ['Yeah something like this.'], 'answer_start': [1208]}
Status of register_backward_hook
It appears that backward hooks are currently broken as the recent issue and PR below discuss. <a href="https://github.com/ezyang" rel="nofollow noopener"> [image] </a> <a href="https://github.com/pytorch/pytorch/issues/12331" target="_blank" rel="nofollow noopener">Issue: Feedback about PyTorch register_backward_ho...
0
2019-01-07T23:28:46.452Z
I’ve included some sample code below. I am trying to mask the gradients of layer1 in this example. As you can see, I’m zeroing out the weights upon initialisation. class MaskedLinear(nn.Module): # Currently unused. Intended for backward hook. def _zero_grad_mask(self, module, grad_input, gr&hellip;
1
2019-01-10T19:25:03.330Z
https://discuss.pytorch.org/t/status-of-register-backward-hook/34068/5
You could try to access the handle from inside the hook: def hook(grad): print(grad) handle.remove() model = nn.Linear(1, 1) handle = model.weight.register_hook(hook) model(torch.randn(1, 1)).backward() model(torch.randn(1, 1)).backward() This code will print the gradient only once a&hellip; Yeah something like...
327
{'text': ['I’ve included some sample code below. I am trying to mask the gradients of layer1 in this example. As you can see, I’m zeroing out the weights upon initialisation.\n\nclass MaskedLinear(nn.Module):\n\n# Currently unused. Intended for backward hook.\n\ndef _zero_grad_mask(self, module, grad_input, gr&hellip;'...
CPU is used despite all my tensors are moved to GPU
I have a CUDA supported GPU (Nvidia GeForce GTX 1070) and I have installed both of the CUDA (version 10) and the CUDA-supported version of PyTorch. Despite my GPU is detected, and I have moved all the tensors to GPU, my CPU is used instead of GPU as I see almost no GPU usage when I monitor it. Her&hellip;
0
2019-07-03T12:16:43.522Z
That’s strange, since the data loading time seem to be completely hidden behind the computation. I just tried your code on my machine and simplified it a bit: removed the test loop used random inputs (torch.randn as data and torch.randint as target) used an input batch of [20, 1, 100] Using thi&hellip;
1
2019-07-03T21:52:08.910Z
https://discuss.pytorch.org/t/cpu-is-used-despite-all-my-tensors-are-moved-to-gpu/49611/5
That’s strange, since the data loading time seem to be completely hidden behind the computation. I just tried your code on my machine and simplified it a bit: removed the test loop used random inputs (torch.randn as data and torch.randint as target) used an input batch of [20, 1, 100] Using thi&hellip; Sovled it b...
1,258
{'text': ['That’s strange, since the data loading time seem to be completely hidden behind the computation.\n\nI just tried your code on my machine and simplified it a bit:\n\nremoved the test loop\n\nused random inputs (torch.randn as data and torch.randint as target)\n\nused an input batch of [20, 1, 100]\n\nUsing th...
Well-formed input into a simple linear layer, output Nan
I input well-formed data into a simple linear layer with normal weights and bias, the output has some ‘nan’ in it. This only happens on Ubuntu18 + PyTorch1.4.0, but on Win10 + PyTorch1.4.0 or Colab, the linear layer works well. On Ubuntu: import torch import torch.nn as nn model = nn.Linear(6, 8) &hellip;
0
2020-03-29T17:40:38.446Z
Sovled it by upgrading numpy. Thanks for your help.
1
2020-03-30T05:45:54.477Z
https://discuss.pytorch.org/t/well-formed-input-into-a-simple-linear-layer-output-nan/74720/8
That’s strange, since the data loading time seem to be completely hidden behind the computation. I just tried your code on my machine and simplified it a bit: removed the test loop used random inputs (torch.randn as data and torch.randint as target) used an input batch of [20, 1, 100] Using thi&hellip; Sovled it b...
938
{'text': ['Sovled it by upgrading numpy. Thanks for your help.'], 'answer_start': [938]}
Convert segmentation mask of shape [224,224,3] to mask [224,224,classes]
Hi I am having problem while converting rgb mask of shape [224,224,3] to mask of shape [224,224,3]. I have attached the code below. I am getting masks of shape [224,224,classes] but lose information of classes in channels only one channel has some mask will others don’t Code: class CamVid_Dataset(&hellip;
0
2020-08-17T18:20:59.378Z
Since your current mask is a one-hot encoded tensor (each channel represents a class, where 1 denotes an active class), you could transform it into the desired class mask via: target = torch.argmax(mask, dim=1) Note that dim=1 is used, if your channel dimension (class channels) is in dim1.
0
2020-08-20T20:18:03.094Z
https://discuss.pytorch.org/t/convert-segmentation-mask-of-shape-224-224-3-to-mask-224-224-classes/93122/7
That’s strange, since the data loading time seem to be completely hidden behind the computation. I just tried your code on my machine and simplified it a bit: removed the test loop used random inputs (torch.randn as data and torch.randint as target) used an input batch of [20, 1, 100] Using thi&hellip; Sovled it b...
361
{'text': ['Since your current mask is a one-hot encoded tensor (each channel represents a class, where 1 denotes an active class), you could transform it into the desired class mask via:\n\ntarget = torch.argmax(mask, dim=1)\n\nNote that dim=1 is used, if your channel dimension (class channels) is in dim1.'], 'answer_s...
C++/Cuda extension with multiple GPUs
I followed the tutorial to create custom c++/cuda extensions <a href="https://pytorch.org/tutorials/advanced/cpp_extension.html" rel="nofollow noopener">https://pytorch.org/tutorials/advanced/cpp_extension.html</a>. What I have works locally (only 1 pytorch capable GPU), but I have problems running it on our cluster w...
1
2020-07-31T15:58:08.820Z
I was wrong and a device guard is needed for custom CUDA extensions. Here is the diff to make the example executable on a non-default device: diff --git a/cuda/lltm_cuda.cpp b/cuda/lltm_cuda.cpp index 2434776..62c9628 100644 --- a/cuda/lltm_cuda.cpp +++ b/cuda/lltm_cuda.cpp @@ -1,5 +1,5 @@ #inclu&hellip;
4
2020-08-05T09:24:11.467Z
https://discuss.pytorch.org/t/c-cuda-extension-with-multiple-gpus/91241/6
I was wrong and a device guard is needed for custom CUDA extensions. Here is the diff to make the example executable on a non-default device: diff --git a/cuda/lltm_cuda.cpp b/cuda/lltm_cuda.cpp index 2434776..62c9628 100644 --- a/cuda/lltm_cuda.cpp +++ b/cuda/lltm_cuda.cpp @@ -1,5 +1,5 @@ #inclu&hellip; I guess...
1,306
{'text': ['I was wrong and a device guard is needed for custom CUDA extensions.\n\nHere is the diff to make the example executable on a non-default device:\n\ndiff --git a/cuda/lltm_cuda.cpp b/cuda/lltm_cuda.cpp\n\nindex 2434776..62c9628 100644\n\n--- a/cuda/lltm_cuda.cpp\n\n+++ b/cuda/lltm_cuda.cpp\n\n@@ -1,5 +1,5 @@\...
How to manually set grad in a new layer's definition
I write a new loss in pytorch, and I define a nn.Parameter that should update with an expression. But I can’t get the right grad when setting with self.parameter.grad or self.parameter._grad. class Loss(nn.Module): def __init__(...): self.parameter = nn.Parameter(...) # init parameters&hellip;
0
2018-03-06T12:10:57.287Z
I guess what you want is: # Compute your loss as usual out = model(input) loss = loss_module(out, target) # zero all gradients and backward optimizer.zero_grad() loss.backward() # reset the gradients for the loss parameter loss_module.zero_grad() # compute the gradients for your loss parameters &hellip;
1
2018-03-06T16:17:19.632Z
https://discuss.pytorch.org/t/how-to-manually-set-grad-in-a-new-layers-definition/14452/6
I was wrong and a device guard is needed for custom CUDA extensions. Here is the diff to make the example executable on a non-default device: diff --git a/cuda/lltm_cuda.cpp b/cuda/lltm_cuda.cpp index 2434776..62c9628 100644 --- a/cuda/lltm_cuda.cpp +++ b/cuda/lltm_cuda.cpp @@ -1,5 +1,5 @@ #inclu&hellip; I guess...
966
{'text': ['I guess what you want is:\n\n# Compute your loss as usual\n\nout = model(input)\n\nloss = loss_module(out, target)\n\n# zero all gradients and backward\n\noptimizer.zero_grad()\n\nloss.backward()\n\n# reset the gradients for the loss parameter\n\nloss_module.zero_grad()\n\n# compute the gradients for your lo...
Error that I haven't understand and solve
Hi all, I get this error when I have write: batch_size = 3 train_loader = DataLoader(dataset = train_dataset ,batch_size = batch_size ,shuffle = False ,num_workers = 2) for original_img, noisy_img in train_loader: &hellip;
0
2020-07-10T11:26:30.306Z
Hi <a class="mention" href="/u/juanfmontesinos">@JuanFMontesinos</a> It’s the first time I’ve used this class, with: def __init__ def __len__(self): def __getitem__(self, index): I have solved this problem by writing def __len__(self): list = os.listdir(self.path_input_1) return len(list) Now I get no error. T...
0
2020-07-12T14:55:35.889Z
https://discuss.pytorch.org/t/error-that-i-havent-understand-and-solve/88676/13
I was wrong and a device guard is needed for custom CUDA extensions. Here is the diff to make the example executable on a non-default device: diff --git a/cuda/lltm_cuda.cpp b/cuda/lltm_cuda.cpp index 2434776..62c9628 100644 --- a/cuda/lltm_cuda.cpp +++ b/cuda/lltm_cuda.cpp @@ -1,5 +1,5 @@ #inclu&hellip; I guess...
627
{'text': ['Hi <a class="mention" href="/u/juanfmontesinos">@JuanFMontesinos</a>\n\nIt’s the first time I’ve used this class, with:\n\ndef __init__\n\ndef __len__(self):\n\ndef __getitem__(self, index):\n\nI have solved this problem by writing\n\ndef __len__(self):\n\nlist = os.listdir(self.path_input_1)\n\nreturn len(l...
CUDA is not available
I installed CUDA 10.1.105 and reinstall NVIDIA driver 430.64 , cuDnn 7.6.5 even Anaconda because of no available python -m torch.utils.collect_env Collecting environment information... PyTorch version: 1.3.1 Is debug build: No CUDA used to build PyTorch: Could not collect OS: Ubuntu 18.04.4 LTS GC&hellip;
0
2020-09-08T12:06:15.478Z
You don’t need local CUDA and cudnn installations, if you are using the conda binary. Only the NVIDIA driver will be used. Based on the output you are seeing, I assume you’ve installed the CPU binary. Could you reinstall PyTorch with the desired CUDA version using the install command from <a href="https://pytorch.or...
0
2020-09-11T06:17:48.094Z
https://discuss.pytorch.org/t/cuda-is-not-available/95550/2
You don’t need local CUDA and cudnn installations, if you are using the conda binary. Only the NVIDIA driver will be used. Based on the output you are seeing, I assume you’ve installed the CPU binary. Could you reinstall PyTorch with the desired CUDA version using the install command from <a href="https://pytorch.or...
1,922
{'text': ['You don’t need local CUDA and cudnn installations, if you are using the conda binary.\n\nOnly the NVIDIA driver will be used.\n\nBased on the output you are seeing, I assume you’ve installed the CPU binary.\n\nCould you reinstall PyTorch with the desired CUDA version using the install command from <a href="h...
How to run large images on gpu
I have 12000 1024512 images as dataset. Initially, I resize them to 224112, but the results are terrible. Since these images are scattering images (physics images), I think the resolution may have some information, So I decided to use large images to run the prediction model (predicting some paramet&hellip;
1
2020-07-20T14:07:00.899Z
That’s what I meant. Try changing: [image] yichao_Liu: loss_total+=loss to: loss_total+=loss.item()
1
2020-07-23T09:56:55.862Z
https://discuss.pytorch.org/t/how-to-run-large-images-on-gpu/89909/10
You don’t need local CUDA and cudnn installations, if you are using the conda binary. Only the NVIDIA driver will be used. Based on the output you are seeing, I assume you’ve installed the CPU binary. Could you reinstall PyTorch with the desired CUDA version using the install command from <a href="https://pytorch.or...
1,325
{'text': ['That’s what I meant.\n\nTry changing:\n\n[image] yichao_Liu:\n\nloss_total+=loss\n\nto:\n\nloss_total+=loss.item()'], 'answer_start': [1325]}
VGG16 using CIFAR10 not converging
I’m training VGG16 model from scratch on CIFAR10 dataset. The validation loss diverges from the start of the training. I have tried with Adam optimizer as well as SGD optimizer. I cannot figure out what it is that I am doing incorrectly. Please point me in the right direction. # Importing Dependen&hellip;
1
2021-03-13T18:17:19.419Z
Is it possible your validation accuracy is for a single batch instead of the entire validation set? If so the fluctuation would be perfectly normal since your accuracy is based on only 16 predictions which would fluctuate heavily. Otherwise, the heavy fluctuations in your validation set would not m&hellip;
0
2021-03-22T18:46:55.812Z
https://discuss.pytorch.org/t/vgg16-using-cifar10-not-converging/114693/7
You don’t need local CUDA and cudnn installations, if you are using the conda binary. Only the NVIDIA driver will be used. Based on the output you are seeing, I assume you’ve installed the CPU binary. Could you reinstall PyTorch with the desired CUDA version using the install command from <a href="https://pytorch.or...
469
{'text': ['Is it possible your validation accuracy is for a single batch instead of the entire validation set? If so the fluctuation would be perfectly normal since your accuracy is based on only 16 predictions which would fluctuate heavily.\n\nOtherwise, the heavy fluctuations in your validation set would not m&hellip...
Which parameter is pass in view function?
i want to ask u,pass hidden layer or input layer in view function?(x.view(-1,64)) and i am randomly choose the hidden layer and input layers? where as i have 3064 images with 512x512 dimensions. i am asking about this: self.fc1 = nn.Linear(262144, 64) self.fc2 = nn.Linear(64, 3) &hellip;
0
2019-03-01T15:48:55.810Z
The output sizes are beautifully explained in Stanford’s <a href="http://cs231n.github.io/convolutional-networks/" rel="nofollow noopener">CS231n</a>. In my architecture each conv layer will reduce the spatial size by two in both dimensions, while the pooling layers will divide them by two. For an input size of [batc...
0
2019-04-30T06:32:45.456Z
https://discuss.pytorch.org/t/which-parameter-is-pass-in-view-function/38655/6
The output sizes are beautifully explained in Stanford’s <a href="http://cs231n.github.io/convolutional-networks/" rel="nofollow noopener">CS231n</a>. In my architecture each conv layer will reduce the spatial size by two in both dimensions, while the pooling layers will divide them by two. For an input size of [batc...
1,554
{'text': ['The output sizes are beautifully explained in Stanford’s <a href="http://cs231n.github.io/convolutional-networks/" rel="nofollow noopener">CS231n</a>.\n\nIn my architecture each conv layer will reduce the spatial size by two in both dimensions, while the pooling layers will divide them by two.\n\nFor an inpu...
SentenceBERT cuda out of memory problems
Hello, I have cuda memory problems while trying to fine tune Siamese BERT on quora question dataset. I am using SentenceTransformers library (<a href="https://github.com/UKPLab/sentence-transformers" rel="nofollow noopener">https://github.com/UKPLab/sentence-transformers</a>). I launched VM on GCP with 4 GPUS (NVIDIA T...
0
2020-01-25T23:44:07.000Z
I tried using nn.DataParallel, but I ran into the same problem. The diagnostics of GPUs looks like this: Sun Jan 26 12:16:30 2020 +-----------------------------------------------------------------------------+ | NVIDIA-SMI 418.87.01 Driver Version: 418.87.01 CUDA Version: 10.1 | |&hellip;
0
2020-01-26T12:20:34.209Z
https://discuss.pytorch.org/t/sentencebert-cuda-out-of-memory-problems/67657/4
The output sizes are beautifully explained in Stanford’s <a href="http://cs231n.github.io/convolutional-networks/" rel="nofollow noopener">CS231n</a>. In my architecture each conv layer will reduce the spatial size by two in both dimensions, while the pooling layers will divide them by two. For an input size of [batc...
1,173
{'text': ['I tried using nn.DataParallel, but I ran into the same problem. The diagnostics of GPUs looks like this:\n\nSun Jan 26 12:16:30 2020\n\n+-----------------------------------------------------------------------------+\n\n| NVIDIA-SMI 418.87.01 Driver Version: 418.87.01 CUDA Version: 10.1 |\n\n|&helli...
Confusion about parameters of torch.addmm(...)
following is the definition of torch.addmm &#39;s parameters: torch. addmm ( beta=1 , mat , alpha=1 , mat1 , mat2 , out=None ) → Tensor from <a href="https://pytorch.org/docs/stable/torch.html?highlight=addmm#torch.addmm" rel="nofollow noopener">https://pytorch.org/docs/stable/torch.html?highlight=addmm#torch.ad...
0
2018-11-12T11:41:06.012Z
What happens here is that the addmm does have “overloads” to implement the behaviour that, as you correctly note, would not be possible using a single plain Python function. The twist is that the one using keyword only alpha and beta arguments is the preferred one (<a href="https://github.com/pytorch/pytorch/blob/8752...
1
2018-11-12T13:48:56.988Z
https://discuss.pytorch.org/t/confusion-about-parameters-of-torch-addmm/29377/15
The output sizes are beautifully explained in Stanford’s <a href="http://cs231n.github.io/convolutional-networks/" rel="nofollow noopener">CS231n</a>. In my architecture each conv layer will reduce the spatial size by two in both dimensions, while the pooling layers will divide them by two. For an input size of [batc...
700
{'text': ['What happens here is that the addmm does have “overloads” to implement the behaviour that, as you correctly note, would not be possible using a single plain Python function.\n\nThe twist is that the one using keyword only alpha and beta arguments is the preferred one (<a href="https://github.com/pytorch/pyto...
Best way to set all tensor elements to zero
Hello I am creating a zero tensor before a loop (lets call it “test_tensor”) and at each time step I want to reset the elements to zero. Currently I am doing it as in the code snippet below: auto test_tensor = torch::zeros_like({tensor_initializer}); auto test_tensor_2 = torch::zeros_like({tensor&hellip;
0
2020-07-17T15:40:46.991Z
Hi, I hope I do not sound pedantic, I can be wrong. Given your piece of code there are 2 reasons : Zero_ There are only assignments. Take this piece of code byte result[255]; memset(result,0, sizeof(result)); for(int i = 0; i &lt; limits; i++) result[i] += fct(i); // There is no reasons to u&hellip;
1
2020-07-20T22:07:51.799Z
https://discuss.pytorch.org/t/best-way-to-set-all-tensor-elements-to-zero/89618/11
Hi, I hope I do not sound pedantic, I can be wrong. Given your piece of code there are 2 reasons : Zero_ There are only assignments. Take this piece of code byte result[255]; memset(result,0, sizeof(result)); for(int i = 0; i &lt; limits; i++) result[i] += fct(i); // There is no reasons to u&hellip; Hi, And e...
2,352
{'text': ['Hi,\n\nI hope I do not sound pedantic, I can be wrong.\n\nGiven your piece of code there are 2 reasons :\n\nZero_\n\nThere are only assignments. Take this piece of code\n\nbyte result[255];\n\nmemset(result,0, sizeof(result));\n\nfor(int i = 0; i &lt; limits; i++)\n\nresult[i] += fct(i);\n\n// There is no re...
RuntimeError: cuda runtime error (710) : device-side assert triggered at /pytorch/aten/src/THCUNN/generic/ClassNLLCriterion.cu:110
Hi, Im trying to train resnet18 on tiny Imagenet dataset. But during the model training, the execution is failing at NLL Loss calculation with error message- RuntimeError: cuda runtime error (710) : device-side assert triggered at /pytorch/aten/src/THCUNN/generic/ClassNLLCriterion.cu:110. I have e&hellip;
0
2020-04-21T18:41:01.912Z
Hi, And error in this place is usually wrong labels. Can you try running your code on CPU to see what it says?
1
2020-04-21T20:52:26.550Z
https://discuss.pytorch.org/t/runtimeerror-cuda-runtime-error-710-device-side-assert-triggered-at-pytorch-aten-src-thcunn-generic-classnllcriterion-cu-110/77739/2
Hi, I hope I do not sound pedantic, I can be wrong. Given your piece of code there are 2 reasons : Zero_ There are only assignments. Take this piece of code byte result[255]; memset(result,0, sizeof(result)); for(int i = 0; i &lt; limits; i++) result[i] += fct(i); // There is no reasons to u&hellip; Hi, And e...
1,486
{'text': ['Hi,\n\nAnd error in this place is usually wrong labels.\n\nCan you try running your code on CPU to see what it says?'], 'answer_start': [1486]}
Backpropagation - Graph is reused while it shouldn't
Consider the following (made up) example snippet: import torch measure = torch.nn.MSELoss() x = torch.tensor([1, 0], dtype=torch.float64) t = torch.eye(2, dtype=torch.float64, requires_grad=True) a = torch.ones(2, dtype=torch.float64, requires_grad=True) y = t @ a for __ in range(2): x_out =&hellip;
0
2018-09-05T12:30:04.094Z
[image] Dominik: To what parts of the graph does this refer? This refers to every part of the graph that were visited during the backward pass. [image] Dominik: And what does “anything” mean in that context? What else than gradient computation would / could you use a graph for? Yes on&hellip;
2
2018-09-05T15:51:05.292Z
https://discuss.pytorch.org/t/backpropagation-graph-is-reused-while-it-shouldnt/24554/6
Hi, I hope I do not sound pedantic, I can be wrong. Given your piece of code there are 2 reasons : Zero_ There are only assignments. Take this piece of code byte result[255]; memset(result,0, sizeof(result)); for(int i = 0; i &lt; limits; i++) result[i] += fct(i); // There is no reasons to u&hellip; Hi, And e...
423
{'text': ['[image] Dominik:\n\nTo what parts of the graph does this refer?\n\nThis refers to every part of the graph that were visited during the backward pass.\n\n[image] Dominik:\n\nAnd what does “anything” mean in that context? What else than gradient computation would / could you use a graph for?\n\nYes on&hellip;'...
Efficient computation with multiple grad_output's in autograd.grad
I want to compute Jacobian matrices using pytorch’s autograd. Autograd natively computes Jacobian-vector products, so I’d simple like to pass an identity matrix to obtain the full Jacobian (ie, Jv = JI = J). One wrinkle: I’d like to implement both standard reverse-mode AD computation for the Jacobi&hellip;
0
2020-01-14T05:12:54.435Z
What if you use the same repeat trick for forward mode? IE, replicate x and v vector and do the same as in reverse mode? <a href="https://colab.research.google.com/drive/1tcm7Lvdv0krpPdaYHtWe7NA2bDbEQ0uj#scrollTo=-jwISHOycQ8x" class="onebox" target="_blank" rel="nofollow noopener">https://colab.research.google.com/dri...
0
2020-01-15T18:55:27.693Z
https://discuss.pytorch.org/t/efficient-computation-with-multiple-grad-outputs-in-autograd-grad/66594/6
What if you use the same repeat trick for forward mode? IE, replicate x and v vector and do the same as in reverse mode? <a href="https://colab.research.google.com/drive/1tcm7Lvdv0krpPdaYHtWe7NA2bDbEQ0uj#scrollTo=-jwISHOycQ8x" class="onebox" target="_blank" rel="nofollow noopener">https://colab.research.google.com/dri...
1,442
{'text': ['What if you use the same repeat trick for forward mode? IE, replicate x and v vector and do the same as in reverse mode?\n\n<a href="https://colab.research.google.com/drive/1tcm7Lvdv0krpPdaYHtWe7NA2bDbEQ0uj#scrollTo=-jwISHOycQ8x" class="onebox" target="_blank" rel="nofollow noopener">https://colab.research.g...
How can i use sklearn.Kfold with ImageFolder?
My code is… batch_size = 16 transform = transforms.Compose([transforms.Resize((299,299)) ,transforms.ToTensor() ,transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])]) dataset = ImageFolder(&#39;.data/&#39;,transf&hellip;
0
2019-02-07T06:21:44.832Z
kf.split will return the train and test indices as far as I know. Currently you are passing these indices to a DataLoader, which will just return a batch of indices. I think you should pass the train and test indices to a <a href="https://pytorch.org/docs/stable/data.html#torch.utils.data.Subset" rel="nofollow noopen...
2
2019-02-07T07:13:22.117Z
https://discuss.pytorch.org/t/how-can-i-use-sklearn-kfold-with-imagefolder/36577/2
What if you use the same repeat trick for forward mode? IE, replicate x and v vector and do the same as in reverse mode? <a href="https://colab.research.google.com/drive/1tcm7Lvdv0krpPdaYHtWe7NA2bDbEQ0uj#scrollTo=-jwISHOycQ8x" class="onebox" target="_blank" rel="nofollow noopener">https://colab.research.google.com/dri...
1,104
{'text': ['kf.split will return the train and test indices as far as I know.\n\nCurrently you are passing these indices to a DataLoader, which will just return a batch of indices.\n\nI think you should pass the train and test indices to a <a href="https://pytorch.org/docs/stable/data.html#torch.utils.data.Subset" rel="...
Multiple Output using Pytorch
Hello All, I’m using vgg_16 model and i’m modifying the classifier to have two outputs. (classifier): Sequential( (0): Linear(in_features=25088, out_features=4096, bias=True) (1): ReLU(inplace) (2): Dropout(p=0.5) (3): Linear(in_features=4096, out_features=4096, bias=True) (4): ReLU(inplace) &hellip;
0
2019-06-21T14:42:58.007Z
change the code as below: its better you write an another classifier (classifier): Sequential( (0): Linear(in_features=25088, out_features=4096, bias=True) (1): ReLU(inplace) (2): Dropout(p=0.5) (3): Linear(in_features=4096, out_features=4096, bias=True) (4): ReLU(inplace) (5): Dropout(p=0.5) (6):&hellip;
0
2019-06-21T17:19:46.042Z
https://discuss.pytorch.org/t/multiple-output-using-pytorch/48635/5
What if you use the same repeat trick for forward mode? IE, replicate x and v vector and do the same as in reverse mode? <a href="https://colab.research.google.com/drive/1tcm7Lvdv0krpPdaYHtWe7NA2bDbEQ0uj#scrollTo=-jwISHOycQ8x" class="onebox" target="_blank" rel="nofollow noopener">https://colab.research.google.com/dri...
796
{'text': ['change the code as below:\n\nits better you write an another classifier\n\n(classifier): Sequential(\n\n(0): Linear(in_features=25088, out_features=4096, bias=True)\n\n(1): ReLU(inplace)\n\n(2): Dropout(p=0.5)\n\n(3): Linear(in_features=4096, out_features=4096, bias=True)\n\n(4): ReLU(inplace)\n\n(5): Dropou...
When the parameters are set on cuda(), the backpropagation doesnt work
This is a follow up to my previous question asked here <a href="https://discuss.pytorch.org/t/how-can-i-insert-a-branch-variable-in-a-model-graph-in-pytorch/35199">How can I insert a branch variable in a model graph in pytorch?</a>, The problem is , I noticed when training, the GPU utilization is very bad, and at firs...
0
2019-01-22T16:45:41.592Z
Now if you have args.use_cuda=True, your model will use the GPU. Keep in mind that if your model or input is very small, you might not use the gpu very efficiently and thus gpu usage will remain small. You need to perform large enough ops for the gpu to be properly used. Increasing the batch size i&hellip;
2
2019-01-22T18:24:59.799Z
https://discuss.pytorch.org/t/when-the-parameters-are-set-on-cuda-the-backpropagation-doesnt-work/35318/6
Now if you have args.use_cuda=True, your model will use the GPU. Keep in mind that if your model or input is very small, you might not use the gpu very efficiently and thus gpu usage will remain small. You need to perform large enough ops for the gpu to be properly used. Increasing the batch size i&hellip; It’s actual...
2,222
{'text': ['Now if you have args.use_cuda=True, your model will use the GPU.\n\nKeep in mind that if your model or input is very small, you might not use the gpu very efficiently and thus gpu usage will remain small. You need to perform large enough ops for the gpu to be properly used. Increasing the batch size i&hellip...
Solving the linear system of linear equations, when given the initial point
Hi, I want to know, is there function in pytorch, which can solving the linear system of linear equations by iteration after given the initial point? Thank you for your attention.
0
2018-08-24T13:25:35.062Z
It’s actually from the torch.optim package (you can see all the optimizers here, in addition to SGD, Adam, there’s also LBFGS, and more…) <a href="https://pytorch.org/docs/stable/optim.html" class="onebox" target="_blank" rel="nofollow noopener">https://pytorch.org/docs/stable/optim.html</a> To use LBFGS, your optimi...
1
2018-08-26T04:37:42.887Z
https://discuss.pytorch.org/t/solving-the-linear-system-of-linear-equations-when-given-the-initial-point/23815/15
Now if you have args.use_cuda=True, your model will use the GPU. Keep in mind that if your model or input is very small, you might not use the gpu very efficiently and thus gpu usage will remain small. You need to perform large enough ops for the gpu to be properly used. Increasing the batch size i&hellip; It’s actual...
1,420
{'text': ['It’s actually from the torch.optim package (you can see all the optimizers here, in addition to SGD, Adam, there’s also LBFGS, and more…)\n\n<a href="https://pytorch.org/docs/stable/optim.html" class="onebox" target="_blank" rel="nofollow noopener">https://pytorch.org/docs/stable/optim.html</a>\n\nTo use LBF...
Ninja error when building PyTorch from sources
Hello there! I’ve tried to build PyTorch from sources. The following error occurs in the process: ninja: build stopped: subcommand failed. Traceback (most recent call last): File &quot;setup.py&quot;, line 743, in &lt;module&gt; build_deps() File &quot;setup.py&quot;, line 316, in build_deps cmake=cmake) File&h...
0
2020-03-18T15:16:06.903Z
I guess installing CUDA 9.2 is a good choice.
0
2020-03-23T08:23:51.767Z
https://discuss.pytorch.org/t/ninja-error-when-building-pytorch-from-sources/73649/19
Now if you have args.use_cuda=True, your model will use the GPU. Keep in mind that if your model or input is very small, you might not use the gpu very efficiently and thus gpu usage will remain small. You need to perform large enough ops for the gpu to be properly used. Increasing the batch size i&hellip; It’s actual...
668
{'text': ['I guess installing CUDA 9.2 is a good choice.'], 'answer_start': [668]}
Custom Top-eigenvector Function
I am trying to write a custom function that computes the dominant eigenvector and its derivative of a symmetric matrix using <a href="http://www2.imm.dtu.dk/pubdb/views/edoc_download.php/3274/pdf/imm3274.pdf" rel="nofollow noopener">Eq. (68) in the matrix cookbook</a> and numpy. Here is my code: import torch from to...
0
2018-04-16T20:23:33.960Z
Hi <a class="mention" href="/u/tom">@tom</a>. I found the issue. Eigen-decomposition requires a symmetric matrix as its input. But the perturbations by gradcheck() makes the input asymmetric and eigen-decomposition fails. I wrote my own numerical gradient checking function and the above function worked.
2
2018-08-09T17:23:32.644Z
https://discuss.pytorch.org/t/custom-top-eigenvector-function/16510/8
Hi <a class="mention" href="/u/tom">@tom</a>. I found the issue. Eigen-decomposition requires a symmetric matrix as its input. But the perturbations by gradcheck() makes the input asymmetric and eigen-decomposition fails. I wrote my own numerical gradient checking function and the above function worked. I put num_w...
1,426
{'text': ['Hi <a class="mention" href="/u/tom">@tom</a>. I found the issue. Eigen-decomposition requires a symmetric matrix as its input. But the perturbations by gradcheck() makes the input asymmetric and eigen-decomposition fails. I wrote my own numerical gradient checking function and the above function worked.']...
Pytorch Cannot allocate memory
I am trying to load the huge coco dataset (120000-image) and do some training. I am using my docker container for the task. For faster training I try to load the whole data using pytorch dataloader into a python array (on the system memory not the gpu memory), and feed the model with that python ar&hellip;
0
2021-10-21T08:35:01.881Z
I put num_worker = 0 and solved the problem!
0
2021-10-21T11:15:46.282Z
https://discuss.pytorch.org/t/pytorch-cannot-allocate-memory/134754/2
Hi <a class="mention" href="/u/tom">@tom</a>. I found the issue. Eigen-decomposition requires a symmetric matrix as its input. But the perturbations by gradcheck() makes the input asymmetric and eigen-decomposition fails. I wrote my own numerical gradient checking function and the above function worked. I put num_w...
1,021
{'text': ['I put\n\nnum_worker = 0\n\nand solved the problem!'], 'answer_start': [1021]}
One of the variables needed for gradient computation has been modified by an in-place operation
Greetings everyone, I am trying to define a loss and use backward() on it. However, I am getting the error: One of the variables needed for gradient computation has been modified by an inplace operation. Here is the code: for displaying the target image, intermittently show_every = 400 iteration&hellip;
0
2018-12-19T01:32:17.545Z
Hi, You can try adding this at the beginning of your code: for mod in modulelist: if hasattr(mod, &quot;inplace&quot;): print(mod) mod.inplace=False All the ReLU in vgg are inplace :wink: And they modify your img1/img2 inplace.
1
2020-05-12T16:38:36.579Z
https://discuss.pytorch.org/t/one-of-the-variables-needed-for-gradient-computation-has-been-modified-by-an-in-place-operation/32516/19
Hi <a class="mention" href="/u/tom">@tom</a>. I found the issue. Eigen-decomposition requires a symmetric matrix as its input. But the perturbations by gradcheck() makes the input asymmetric and eigen-decomposition fails. I wrote my own numerical gradient checking function and the above function worked. I put num_w...
355
{'text': ['Hi,\n\nYou can try adding this at the beginning of your code:\n\nfor mod in modulelist:\n\nif hasattr(mod, &quot;inplace&quot;):\n\nprint(mod)\n\nmod.inplace=False\n\nAll the ReLU in vgg are inplace :wink: And they modify your img1/img2 inplace.'], 'answer_start': [355]}
Grad is None even when I set requires_grad=True
Hi, I got a problem when I want to get the grad for input features with a pre-trained model. The source code is H_Features = output[0].clone().detach().requires_grad_(True) V_Features = output[0].clone().detach().requires_grad_(True) print(&quot;Features:&quot;) pr&hellip;
0
2020-08-17T15:32:29.093Z
Hi, It is expected that requires_grad=False inside the custom Function. These are built explicitly so that you specify what the backward should be. So there is no reason to track the gradients during the forward. You’re missing a return statement there btw. Why are you using a custom Function her&hellip;
1
2020-08-18T14:12:57.631Z
https://discuss.pytorch.org/t/grad-is-none-even-when-i-set-requires-grad-true/93106/12
Hi, It is expected that requires_grad=False inside the custom Function. These are built explicitly so that you specify what the backward should be. So there is no reason to track the gradients during the forward. You’re missing a return statement there btw. Why are you using a custom Function her&hellip; i am having...
1,176
{'text': ['Hi,\n\nIt is expected that requires_grad=False inside the custom Function. These are built explicitly so that you specify what the backward should be. So there is no reason to track the gradients during the forward.\n\nYou’re missing a return statement there btw.\n\nWhy are you using a custom Function her&he...
Loss.backward() failure due to contiguous issue
Hi, I found this error when I backprop the loss <a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/6/c/6c7c195910ea7bd9357417b17e241010b114ef73.png" data-download-href="https://discuss.pytorch.org/uploads/default/6c7c195910ea7bd9357417b17e241010b114ef73" title="image">[image]</a> I sup...
0
2020-09-16T01:11:09.743Z
i am having hte same error when trying to use deconvolutions with the following arch: ModuleList( (0): Sequential( (0): ConvTranspose1d(512, 512, kernel_size=(2,), stride=(2,), output_padding=(1,)) ) (1): Sequential( (0): ConvTranspose1d(512, 512, kernel_size=(2,), stride=(2,), output_padding=&hellip;
1
2020-09-18T00:19:38.103Z
https://discuss.pytorch.org/t/loss-backward-failure-due-to-contiguous-issue/96416/9
Hi, It is expected that requires_grad=False inside the custom Function. These are built explicitly so that you specify what the backward should be. So there is no reason to track the gradients during the forward. You’re missing a return statement there btw. Why are you using a custom Function her&hellip; i am having...
897
{'text': ['i am having hte same error when trying to use deconvolutions with the following arch:\n\nModuleList(\n\n(0): Sequential(\n\n(0): ConvTranspose1d(512, 512, kernel_size=(2,), stride=(2,), output_padding=(1,))\n\n)\n\n(1): Sequential(\n\n(0): ConvTranspose1d(512, 512, kernel_size=(2,), stride=(2,), output_paddi...
[ONNX] Quantized fused Conv2d won't trace
#onnx <a class="hashtag" href="/c/jit/13">#jit</a> <a class="hashtag" href="/c/quantization/17">#quantization</a> Hi, I am very confused. While tracing to ONNX my quantized model faced an error. This happens with fused QuantizedConvReLU2d. I use OperatorExportTypes.ONNX_ATEN_FALLBACK. Pytorch version is 1.6.0.dev202...
0
2020-05-20T21:28:02.355Z
we are not working on onnx conversions, feel free to submit PRs to add the support.
0
2020-07-30T15:50:03.464Z
https://discuss.pytorch.org/t/onnx-quantized-fused-conv2d-wont-trace/82244/19
Hi, It is expected that requires_grad=False inside the custom Function. These are built explicitly so that you specify what the backward should be. So there is no reason to track the gradients during the forward. You’re missing a return statement there btw. Why are you using a custom Function her&hellip; i am having...
618
{'text': ['we are not working on onnx conversions, feel free to submit PRs to add the support.'], 'answer_start': [618]}
Cannot handle multiple inputs to forward
I am having problems with this: # hidden features n_hidden = 256 # input activation factor n_fac = 42 # batch size bs = 512 class Model007(nn.Module): def __init__(self, vocab_size, n_fac): super().__init__() self.l1 = nn.Embedding(vocab_size, n_fac) self.l2 = nn.Line&hellip;
0
2019-03-05T16:35:13.308Z
I don’t think so. Wasn’t he doing m(*mb) ? Notice the *.
0
2019-03-05T16:49:21.452Z
https://discuss.pytorch.org/t/cannot-handle-multiple-inputs-to-forward/38999/6
I don’t think so. Wasn’t he doing m(*mb) ? Notice the *. Both approaches will yield the same result, but the method using two losses is wasteful, since you need to call the backward method twice. Here is a small code snippet to demonstrate the behavior: # Setup torch.manual_seed(2809) modelA = nn.Linear(1, 1) mode...
1,402
{'text': ['I don’t think so. Wasn’t he doing m(*mb) ? Notice the *.'], 'answer_start': [1402]}
Using a combined loss to update two different models
Hi all, I’m trying to accomplish an event detection task with 2 models where model_a will produce the event tag and model_b will produce the event localization (aka label at each time frame). Basically, I’m trying to do update the two models according to the combined loss of these two models. I tri&hellip;
0
2020-03-21T02:50:41.099Z
Both approaches will yield the same result, but the method using two losses is wasteful, since you need to call the backward method twice. Here is a small code snippet to demonstrate the behavior: # Setup torch.manual_seed(2809) modelA = nn.Linear(1, 1) modelB = nn.Linear(1, 1) criterion = nn.MS&hellip;
1
2020-03-21T04:51:35.443Z
https://discuss.pytorch.org/t/using-a-combined-loss-to-update-two-different-models/73925/2
I don’t think so. Wasn’t he doing m(*mb) ? Notice the *. Both approaches will yield the same result, but the method using two losses is wasteful, since you need to call the backward method twice. Here is a small code snippet to demonstrate the behavior: # Setup torch.manual_seed(2809) modelA = nn.Linear(1, 1) mode...
758
{'text': ['Both approaches will yield the same result, but the method using two losses is wasteful, since you need to call the backward method twice.\n\nHere is a small code snippet to demonstrate the behavior:\n\n# Setup\n\ntorch.manual_seed(2809)\n\nmodelA = nn.Linear(1, 1)\n\nmodelB = nn.Linear(1, 1)\n\ncriterion = ...
How to push data with Dataloader ni LibTorch
Hi, I trained and traced a Model in Python. Now I want to predict outpouts with c++. I read the tutorial code and was fine with it. the problem was the batch size of one. To fix this, I created a cutsom dataset and made data loader. How do I push the data from the dataloader to the network? I tried &hellip;
0
2019-08-06T11:31:31.503Z
The problem with your images may be resolved by changing the way you convert the cv::Mat to a torch::Tensor, e.g. // Replace this torch::Tensor tensor_image = torch::from_blob(img.data, { img.rows, img.cols,1}, at::kFloat); // By this torch::Tensor tensor_image = torch::from_blob(img.data, { img.ro&hellip;
1
2019-08-08T11:28:33.266Z
https://discuss.pytorch.org/t/how-to-push-data-with-dataloader-ni-libtorch/52664/7
I don’t think so. Wasn’t he doing m(*mb) ? Notice the *. Both approaches will yield the same result, but the method using two losses is wasteful, since you need to call the backward method twice. Here is a small code snippet to demonstrate the behavior: # Setup torch.manual_seed(2809) modelA = nn.Linear(1, 1) mode...
368
{'text': ['The problem with your images may be resolved by changing the way you convert the cv::Mat to a torch::Tensor, e.g.\n\n// Replace this\n\ntorch::Tensor tensor_image = torch::from_blob(img.data, { img.rows, img.cols,1}, at::kFloat);\n\n// By this\n\ntorch::Tensor tensor_image = torch::from_blob(img.data, { img....
How to avoid sending input one by one for LSTM siamese?
Hi, I have been trying to implement the LSTM siamese for sentence similarity as introduced in the initial <a href="https://www.aaai.org/ocs/index.php/AAAI/AAAI16/paper/download/12195/12023" rel="nofollow noopener">paper</a> on my own but I am struggling to get the last hidden layer for each iterations without using a ...
1
2018-12-14T02:34:53.686Z
I’m not sure I understand your doubts? If you run a torch.nn.LSTM on seq x batch x feature - Tensors, it will have the same result as if you iterate over the seq (and keep track of the state (h,c)) as the unrolled loop in your first link does. The final state could be taken either from the output o&hellip;
0
2019-02-06T21:50:44.246Z
https://discuss.pytorch.org/t/how-to-avoid-sending-input-one-by-one-for-lstm-siamese/32097/5
I’m not sure I understand your doubts? If you run a torch.nn.LSTM on seq x batch x feature - Tensors, it will have the same result as if you iterate over the seq (and keep track of the state (h,c)) as the unrolled loop in your first link does. The final state could be taken either from the output o&hellip; You would f...
1,358
{'text': ['I’m not sure I understand your doubts?\n\nIf you run a torch.nn.LSTM on seq x batch x feature - Tensors, it will have the same result as if you iterate over the seq (and keep track of the state (h,c)) as the unrolled loop in your first link does. The final state could be taken either from the output o&hellip...
Image Generation with LSTM
I want to use a LSTM to generate images, I have inputs images of (30,2,32,32) and target images of (30,1,32,32), How should I structure my data such I will be able generate images using the following architecture ? Or is it even possible to use this simple architecture to get reasonable results? <a class="lightbox" hr...
1
2020-03-05T22:08:01.480Z
You would first have to convert the image into a series of data; for example, flatten the image in some way(or flatten it using Unfold). Then reshape the tensor into the shape that match the input.
0
2020-03-15T05:08:24.460Z
https://discuss.pytorch.org/t/image-generation-with-lstm/72198/10
I’m not sure I understand your doubts? If you run a torch.nn.LSTM on seq x batch x feature - Tensors, it will have the same result as if you iterate over the seq (and keep track of the state (h,c)) as the unrolled loop in your first link does. The final state could be taken either from the output o&hellip; You would f...
988
{'text': ['You would first have to convert the image into a series of data; for example, flatten the image in some way(or flatten it using Unfold). Then reshape the tensor into the shape that match the input.'], 'answer_start': [988]}
How to compile binary with libtorch without CUDA
Is that possible somehow? I looked at the Caffe2 and Torch cmake files and there did not seem to be a straightforward way to do it (but I’m a newbie with C++ compilation and cmake).
0
2018-10-16T09:28:19.122Z
I am not sure what you want. But the NO_CUDA=1 flag will disable all cuda stuff.
1
2018-10-16T09:40:35.600Z
https://discuss.pytorch.org/t/how-to-compile-binary-with-libtorch-without-cuda/27362/2
I’m not sure I understand your doubts? If you run a torch.nn.LSTM on seq x batch x feature - Tensors, it will have the same result as if you iterate over the seq (and keep track of the state (h,c)) as the unrolled loop in your first link does. The final state could be taken either from the output o&hellip; You would f...
507
{'text': ['I am not sure what you want. But the NO_CUDA=1 flag will disable all cuda stuff.'], 'answer_start': [507]}
Training a linear layer with a 2D input
If the first linear layer has in_features = 1 and I input [1, 2, 3] into the model, how will that linear layer be trained? Will it train it independently on 1, 2, and 3 so the layer keeps track of the gradient for each input, and then the optimizer will use the average of all their gradients? If so,&hellip;
0
2020-07-27T02:58:30.493Z
[image] agt: Can you point me to the pytorch docs that implies the gradients of the first layers (before aggregation) will be averaged? Don’t know if such a thing exists. That’s just how gradients work with tensor broadcasting (if scalar from one of inputs is used multiple times, you sum rele&hellip;
1
2020-07-29T22:02:02.159Z
https://discuss.pytorch.org/t/training-a-linear-layer-with-a-2d-input/90625/12
[image] agt: Can you point me to the pytorch docs that implies the gradients of the first layers (before aggregation) will be averaged? Don’t know if such a thing exists. That’s just how gradients work with tensor broadcasting (if scalar from one of inputs is used multiple times, you sum rele&hellip; Hi, You can use...
1,174
{'text': ['[image] agt:\n\nCan you point me to the pytorch docs that implies the gradients of the first layers (before aggregation) will be averaged?\n\nDon’t know if such a thing exists. That’s just how gradients work with tensor broadcasting (if scalar from one of inputs is used multiple times, you sum rele&hellip;']...
Manually set gradient of tensor that is not being calculated automatically
I am working on a project that requires me to write a method that is not differentiable. Hence I have calculated the gradient w.r.t the input of this method. Now I have tried to use register_hook to return the calculated grad to be able to flow the gradient backwards from there. But register_hook is&hellip;
1
2020-04-20T22:47:26.756Z
Hi, You can use a custom Function to specify a backward for a given forward. You can see <a href="https://pytorch.org/docs/stable/notes/extending.html">here</a> how to do this.
1
2020-04-21T15:13:10.541Z
https://discuss.pytorch.org/t/manually-set-gradient-of-tensor-that-is-not-being-calculated-automatically/77619/2
[image] agt: Can you point me to the pytorch docs that implies the gradients of the first layers (before aggregation) will be averaged? Don’t know if such a thing exists. That’s just how gradients work with tensor broadcasting (if scalar from one of inputs is used multiple times, you sum rele&hellip; Hi, You can use...
891
{'text': ['Hi,\n\nYou can use a custom Function to specify a backward for a given forward. You can see <a href="https://pytorch.org/docs/stable/notes/extending.html">here</a> how to do this.'], 'answer_start': [891]}
Difference between batch_input and "for loop"
I have a question. For pytorch0.3.0s. (I)I use the following code: total_loss = net([batch_size, input_size]) #means all batch_size train samples total_loss.backward() optimizer.step() (II)I use the following code: total_loss = 0 for i in range(batch_size): loss = net([(i)input_size]) #mean&hellip;
1
2018-05-25T14:39:57.703Z
OK, the batch_size is the same. And I have know it does work if I use the “for loop”. Thanks a lot.
0
2018-05-25T15:32:22.486Z
https://discuss.pytorch.org/t/difference-between-batch-input-and-for-loop/18680/8
[image] agt: Can you point me to the pytorch docs that implies the gradients of the first layers (before aggregation) will be averaged? Don’t know if such a thing exists. That’s just how gradients work with tensor broadcasting (if scalar from one of inputs is used multiple times, you sum rele&hellip; Hi, You can use...
482
{'text': ['OK, the batch_size is the same. And I have know it does work if I use the “for loop”.\n\nThanks a lot.'], 'answer_start': [482]}
Strange behavior in Pytorch
I saw a very strange behavior during training. The Training slows down after a few steps (generally after 50% steps in the first epoch). At this point the GPU utilization (of 6 or 7 out of 8 GPUs) goes to 100% from 90%. While the remaining 1 or 2 of the GPUs go down to 0% utilization. No matter what&hellip;
1
2021-06-15T11:58:50.159Z
<a class="mention" href="/u/ptrblck">@ptrblck</a> Well, i moved the data from HDD to SSD and it solved my problem. I didn’t know HDD can be such a bottleneck. Anyway, now on SSD the training is very smooth as expected, both on single- and multi-GPU devices.
0
2021-06-28T07:11:10.078Z
https://discuss.pytorch.org/t/strange-behavior-in-pytorch/124168/13
<a class="mention" href="/u/ptrblck">@ptrblck</a> Well, i moved the data from HDD to SSD and it solved my problem. I didn’t know HDD can be such a bottleneck. Anyway, now on SSD the training is very smooth as expected, both on single- and multi-GPU devices. Injecting noise into the model might act as a regularizer, but...
1,164
{'text': ['<a class="mention" href="/u/ptrblck">@ptrblck</a> Well, i moved the data from HDD to SSD and it solved my problem. I didn’t know HDD can be such a bottleneck. Anyway, now on SSD the training is very smooth as expected, both on single- and multi-GPU devices.'], 'answer_start': [1164]}
Add gaussian noise to parameters while training
I tried to add gaussian noise to the parameters using the code below but the network won’t converge. Any though why? I used cifar10 dataset with lr=0.001 import torch.nn as nn &hellip;
0
2021-01-19T01:51:08.781Z
Injecting noise into the model might act as a regularizer, but note that your current noise is static and you would most likely want to resample it in each forward pass. I don’t know how large the stddev should be to work properly.
2
2021-01-20T07:21:56.228Z
https://discuss.pytorch.org/t/add-gaussian-noise-to-parameters-while-training/109260/6
<a class="mention" href="/u/ptrblck">@ptrblck</a> Well, i moved the data from HDD to SSD and it solved my problem. I didn’t know HDD can be such a bottleneck. Anyway, now on SSD the training is very smooth as expected, both on single- and multi-GPU devices. Injecting noise into the model might act as a regularizer, but...
840
{'text': ['Injecting noise into the model might act as a regularizer, but note that your current noise is static and you would most likely want to resample it in each forward pass. I don’t know how large the stddev should be to work properly.'], 'answer_start': [840]}
Normalization in custom Dataset class
Hello fellow Pytorchers, I am trying to add normalization to the custom Dataset class Pytorch provides inside <a href="https://pytorch.org/tutorials/beginner/data_loading_tutorial.html" rel="nofollow noopener">this</a> tutorial. The problem is that it gives always the same error: TypeError: tensor is not a torch ima...
0
2019-07-20T15:02:50.148Z
<a class="mention" href="/u/nikronic">@Nikronic</a> Final and working class ToTensor(object): &quot;&quot;&quot;Convert ndarrays in sample to Tensors.&quot;&quot;&quot; def __call__(self, sample): image, landmarks = sample[&#39;image&#39;], np.array(sample[&#39;masks&#39;]) # swap color axis because # numpy imag...
1
2019-07-21T06:46:04.297Z
https://discuss.pytorch.org/t/normalization-in-custom-dataset-class/51165/10
<a class="mention" href="/u/ptrblck">@ptrblck</a> Well, i moved the data from HDD to SSD and it solved my problem. I didn’t know HDD can be such a bottleneck. Anyway, now on SSD the training is very smooth as expected, both on single- and multi-GPU devices. Injecting noise into the model might act as a regularizer, but...
490
{'text': ['<a class="mention" href="/u/nikronic">@Nikronic</a>\n\nFinal and working\n\nclass ToTensor(object):\n\n&quot;&quot;&quot;Convert ndarrays in sample to Tensors.&quot;&quot;&quot;\n\ndef __call__(self, sample):\n\nimage, landmarks = sample[&#39;image&#39;], np.array(sample[&#39;masks&#39;])\n\n# swap color axi...
Making custom image to image dataset using collate_fn and dataloader
I have made a dataset using pytoch dataloader and Imagefolder, my dataset class has two Imagefolder dataset. These two datasets are paired(original and ground truth image). I want to feed these to pytorch neural network. Dataset class: class bsds_dataset(Dataset): def __init__(self, ds_main, ds&hellip;
0
2019-09-15T08:57:22.523Z
You could unsqueeze the batch dimension via original = original.unsqueeze(0) before passing it to the model.
0
2019-09-19T09:18:50.629Z
https://discuss.pytorch.org/t/making-custom-image-to-image-dataset-using-collate-fn-and-dataloader/55951/7
You could unsqueeze the batch dimension via original = original.unsqueeze(0) before passing it to the model. So if you run anomaly mode, the error might be thrown between the producing of NaN and before the hook is applied. (I must admit I don’t know and in lieu of a simple snippet I can copy-paste into PyTorch, I’m no...
1,700
{'text': ['You could unsqueeze the batch dimension via original = original.unsqueeze(0) before passing it to the model.'], 'answer_start': [1700]}
How to fix this nan bug?
Hi, I’m trying to modify the mean/std of one feature with the mean/std calculated from another feature. It looks like this (certain simplification is made since original code is much more complicated) def exchange(vs, vt): # vs and vt are of the same size NxCxHxW vs_mean = torch.mean(vs, d&hellip;
0
2020-07-23T14:43:36.750Z
So if you run anomaly mode, the error might be thrown between the producing of NaN and before the hook is applied. (I must admit I don’t know and in lieu of a simple snippet I can copy-paste into PyTorch, I’m not going to start experiments, sorry.) One way around this might be to define your own au&hellip;
1
2020-07-28T08:47:12.926Z
https://discuss.pytorch.org/t/how-to-fix-this-nan-bug/90291/9
You could unsqueeze the batch dimension via original = original.unsqueeze(0) before passing it to the model. So if you run anomaly mode, the error might be thrown between the producing of NaN and before the hook is applied. (I must admit I don’t know and in lieu of a simple snippet I can copy-paste into PyTorch, I’m no...
959
{'text': ['So if you run anomaly mode, the error might be thrown between the producing of NaN and before the hook is applied. (I must admit I don’t know and in lieu of a simple snippet I can copy-paste into PyTorch, I’m not going to start experiments, sorry.)\n\nOne way around this might be to define your own au&hellip...
Validation accuracy weirdly dependent on validation batch size
Hi, I’m doing a medical image segmentation task, and using dice score to validate the performance of my model after every epoch. Everything is going as expected (i.e. training is converging, results look good), except for the fact that my validation set dice score seems to vary lot based on my vali&hellip;
0
2019-09-05T00:24:34.956Z
Hmm, I don’t see anything wrong with these pieces of code. For the dice score, I would advise having a dice_score function that returns the dice for each element of the batch, and then doing a mean on the concatenations of all the dices. val_dices = [] for val_batch, val_sample in enumerate(val_da&hellip;
0
2019-09-06T14:27:33.467Z
https://discuss.pytorch.org/t/validation-accuracy-weirdly-dependent-on-validation-batch-size/55191/9
You could unsqueeze the batch dimension via original = original.unsqueeze(0) before passing it to the model. So if you run anomaly mode, the error might be thrown between the producing of NaN and before the hook is applied. (I must admit I don’t know and in lieu of a simple snippet I can copy-paste into PyTorch, I’m no...
418
{'text': ['Hmm, I don’t see anything wrong with these pieces of code.\n\nFor the dice score, I would advise having a dice_score function that returns the dice for each element of the batch, and then doing a mean on the concatenations of all the dices.\n\nval_dices = []\n\nfor val_batch, val_sample in enumerate(val_da&h...
When to use detach
If I have two different neural networks (parametrized by model1 and model2) and corresponding two optimizers, would the below operation using model1.parameters without detach() lead to change in its gradients? My requirement is that I want to just compute the mean squared loss between the two model &hellip;
0
2020-10-03T19:29:41.247Z
Detach is used to break the graph to mess with the gradient computation. In 99% of the cases, you never want to do that. The only weird cases where it can be useful are the ones I mentioned above where you want to use a Tensor that was used in a differentiable function for a function that is not e&hellip;
1
2020-10-05T16:02:31.934Z
https://discuss.pytorch.org/t/when-to-use-detach/98147/6
Detach is used to break the graph to mess with the gradient computation. In 99% of the cases, you never want to do that. The only weird cases where it can be useful are the ones I mentioned above where you want to use a Tensor that was used in a differentiable function for a function that is not e&hellip; I found a p...
1,454
{'text': ['Detach is used to break the graph to mess with the gradient computation.\n\nIn 99% of the cases, you never want to do that.\n\nThe only weird cases where it can be useful are the ones I mentioned above where you want to use a Tensor that was used in a differentiable function for a function that is not e&hell...
Efficient train/dev sets evaluation?
Hello everybody, What is the most efficient way to log train set and dev set accuracy and loss? Now I use the same function for both sets after training, i.e for epoch in range(1, N): train(epoch) evaluate(train_loader) evaluate(dev_loader) I thought that there should be a more concis&hellip;
0
2018-05-04T14:04:30.291Z
I found a problem with my code. I added with torch.no_grad(): before for-loop in evaluate function and it works fine. And I also calculate my training accuracy in the evaluate function. So I didn’t find an accurate and better solution rather to not to use the evaluate function on train_loader after t&hellip;
0
2018-05-22T15:11:00.885Z
https://discuss.pytorch.org/t/efficient-train-dev-sets-evaluation/17514/10
Detach is used to break the graph to mess with the gradient computation. In 99% of the cases, you never want to do that. The only weird cases where it can be useful are the ones I mentioned above where you want to use a Tensor that was used in a differentiable function for a function that is not e&hellip; I found a p...
1,036
{'text': ['I found a problem with my code. I added with torch.no_grad(): before for-loop in evaluate function and it works fine. And I also calculate my training accuracy in the evaluate function. So I didn’t find an accurate and better solution rather to not to use the evaluate function on train_loader after t&hellip;...
Torch training is taking way too long time
Hi, I have just built my first torch model which was originally written tensorflow/keras. But, it seems like the training is taking 4x longer in pytorch. Any suggestion would be a great help: class Env2Acl(nn.Module): def __init__(self, input_length, n_class, sr): super(Env2Acl, self).&hellip;
0
2020-04-14T05:02:08.003Z
Hi, I think we can’t do too much with this slowness of pytorch in cpu. I had to do some fixes in my code like while using KLDIVLoss as loss function you either use log_softmax as your output activation or do a loss = KLDIVLoss(reduction=‘batchmean’)(output.log(), target) to make sure that you follow&hellip;
1
2020-04-17T01:37:28.244Z
https://discuss.pytorch.org/t/torch-training-is-taking-way-too-long-time/76683/16
Detach is used to break the graph to mess with the gradient computation. In 99% of the cases, you never want to do that. The only weird cases where it can be useful are the ones I mentioned above where you want to use a Tensor that was used in a differentiable function for a function that is not e&hellip; I found a p...
619
{'text': ['Hi, I think we can’t do too much with this slowness of pytorch in cpu. I had to do some fixes in my code like while using KLDIVLoss as loss function you either use log_softmax as your output activation or do a loss = KLDIVLoss(reduction=‘batchmean’)(output.log(), target) to make sure that you follow&hellip;'...
Pytorch net from: Striving for Simplicity: The All Convolutional Net
Is there an implementation of: <a href="https://arxiv.org/abs/1412.6806" class="onebox" target="_blank" rel="nofollow noopener">https://arxiv.org/abs/1412.6806</a> in pytorch?
0
2018-06-06T20:57:31.383Z
I’ve used this, and it works fine on Cifar10 class AllConvNet(nn.Module): def __init__(self, dropout=True, nc=3, num_classes=10): super(AllConvNet, self).__init__() self.dropout = dropout self.conv1 = nn.Conv2d(nc, 96, 3, padding=1) self.conv2 = nn.Conv2d(96, 96&hellip;
1
2018-06-06T21:15:01.736Z
https://discuss.pytorch.org/t/pytorch-net-from-striving-for-simplicity-the-all-convolutional-net/19297/2
I’ve used this, and it works fine on Cifar10 class AllConvNet(nn.Module): def __init__(self, dropout=True, nc=3, num_classes=10): super(AllConvNet, self).__init__() self.dropout = dropout self.conv1 = nn.Conv2d(nc, 96, 3, padding=1) self.conv2 = nn.Conv2d(96, 96&hellip; You can just map values to 0-1 in a linear ...
1,854
{'text': ['I’ve used this, and it works fine on Cifar10\n\nclass AllConvNet(nn.Module):\n\ndef __init__(self, dropout=True, nc=3, num_classes=10):\n\nsuper(AllConvNet, self).__init__()\n\nself.dropout = dropout\n\nself.conv1 = nn.Conv2d(nc, 96, 3, padding=1)\n\nself.conv2 = nn.Conv2d(96, 96&hellip;'], 'answer_start': [...
Why do images look weird after (Imagenet) normalization?
Hey, I am using a pretrained network and wanted to normalize my images according to the ImageNet. For some reason however the images look really weird after the normalization. Can someone explain to me why this is happening? <a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/e/6/e639d...
0
2020-08-08T11:39:54.139Z
You can just map values to 0-1 in a linear way. <a href="https://stackoverflow.com/questions/4154969/how-to-map-numbers-in-range-099-to-range-1-01-0" rel="nofollow noopener">https://stackoverflow.com/questions/4154969/how-to-map-numbers-in-range-099-to-range-1-01-0</a>
1
2020-08-08T12:10:48.266Z
https://discuss.pytorch.org/t/why-do-images-look-weird-after-imagenet-normalization/92071/4
I’ve used this, and it works fine on Cifar10 class AllConvNet(nn.Module): def __init__(self, dropout=True, nc=3, num_classes=10): super(AllConvNet, self).__init__() self.dropout = dropout self.conv1 = nn.Conv2d(nc, 96, 3, padding=1) self.conv2 = nn.Conv2d(96, 96&hellip; You can just map values to 0-1 in a linear ...
1,204
{'text': ['You can just map values to 0-1 in a linear way. <a href="https://stackoverflow.com/questions/4154969/how-to-map-numbers-in-range-099-to-range-1-01-0" rel="nofollow noopener">https://stackoverflow.com/questions/4154969/how-to-map-numbers-in-range-099-to-range-1-01-0</a>'], 'answer_start': [1204]}
Install PyTorch from source with Cuda 10.2
I have a compatibility 3.0 card so I always have to install from source for it. But there is no magma for 10.2 so what do people do if they want to install from source? When installing cuda on fedora it installs the latest, downgrading it would be a major hassle. Edit: When proceeding without mag&hellip;
0
2020-01-16T16:14:11.594Z
PyTroch is now successfully installed and functioning. Solution: dnf install https://negativo17.org/repos/nvidia/fedora-31/x86_64/cuda-gcc-8.3.0-1.fc31.x86_64.rpm dnf install https://negativo17.org/repos/nvidia/fedora-31/x86_64/cuda-gcc-c++-8.3.0-1.fc31.x86_64.rpm CC=cuda-gcc CXX=cuda-g++ python s&hellip;
1
2020-01-16T21:19:45.826Z
https://discuss.pytorch.org/t/install-pytorch-from-source-with-cuda-10-2/66869/10
I’ve used this, and it works fine on Cifar10 class AllConvNet(nn.Module): def __init__(self, dropout=True, nc=3, num_classes=10): super(AllConvNet, self).__init__() self.dropout = dropout self.conv1 = nn.Conv2d(nc, 96, 3, padding=1) self.conv2 = nn.Conv2d(96, 96&hellip; You can just map values to 0-1 in a linear ...
547
{'text': ['PyTroch is now successfully installed and functioning.\n\nSolution:\n\ndnf install https://negativo17.org/repos/nvidia/fedora-31/x86_64/cuda-gcc-8.3.0-1.fc31.x86_64.rpm\n\ndnf install https://negativo17.org/repos/nvidia/fedora-31/x86_64/cuda-gcc-c++-8.3.0-1.fc31.x86_64.rpm\n\nCC=cuda-gcc CXX=cuda-g++ python ...
Channel wise cross entropy issue
Hi, I am trying to do semantic segmentation. I have label encoded the rgb masks and hence have a ground truth of shape [batch, height, width]. When I try to use cross-entropy loss with my predictions, which are [batch, channels, height, width], I get “cuda runtime error (59) : device-side assert t&hellip;
0
2019-02-12T13:09:37.805Z
Your target is probably all zeros. I would recommend to avoid narmalizing the target and rescaling it again. Instead just keep the class indices and remove the transformation for your target. If you call target.long() on small numbers, they will be all zeros. Scaling with 255 won’t change that. A&hellip;
0
2019-02-14T11:45:13.380Z
https://discuss.pytorch.org/t/channel-wise-cross-entropy-issue/36994/21
Your target is probably all zeros. I would recommend to avoid narmalizing the target and rescaling it again. Instead just keep the class indices and remove the transformation for your target. If you call target.long() on small numbers, they will be all zeros. Scaling with 255 won’t change that. A&hellip; NMS is one ...
1,714
{'text': ['Your target is probably all zeros.\n\nI would recommend to avoid narmalizing the target and rescaling it again. Instead just keep the class indices and remove the transformation for your target.\n\nIf you call target.long() on small numbers, they will be all zeros. Scaling with 255 won’t change that.\n\nA&he...
NMS implementation slower in pytorch compared to numpy
Hi team, I am using MTCNN in pytorch, and it looks like pure non-max suppression implementation in pytorch(cuda) is waaay slower than numpy implementation on cpu. I ended up running just the nms part on cpu to get decent frame rates. Could someone please correct any obvious mistakes, here is the co&hellip;
0
2019-02-08T05:18:48.200Z
NMS is one of those operations where it is common to write custom kernels because, as you note, implementing this in PyTorch directly is not so fast. In the MaskRCNN-Benchmark-Implementation there is are CPU and GPU kernels for NMS, e.g.: <a href="https://github.com/facebookresearch/maskrcnn-benchmark/blob/master/mas...
1
2019-02-08T10:37:52.327Z
https://discuss.pytorch.org/t/nms-implementation-slower-in-pytorch-compared-to-numpy/36665/7
Your target is probably all zeros. I would recommend to avoid narmalizing the target and rescaling it again. Instead just keep the class indices and remove the transformation for your target. If you call target.long() on small numbers, they will be all zeros. Scaling with 255 won’t change that. A&hellip; NMS is one ...
1,166
{'text': ['NMS is one of those operations where it is common to write custom kernels because, as you note, implementing this in PyTorch directly is not so fast.\n\nIn the MaskRCNN-Benchmark-Implementation there is are CPU and GPU kernels for NMS, e.g.:\n\n<a href="https://github.com/facebookresearch/maskrcnn-benchmark/...
Unable to load model state_dict using torch.utils.model_zoo.load_url()
Hello ! I save a PyTorch model state dict saved in github. Whenever I try to load .pth file using torch.utils.model_zoo.load_url(), I get this error : File &quot;/Users/ayushman/Desktop/retinanet_pet_detector/utils.py&quot;, line 17, in get_model state_dict = model_zoo.load_url(url, map_location=&quot;cpu&quot;&he...
0
2020-09-04T10:27:03.736Z
Could it be possible then that the torch.hub.load_state_dict( ) is using the new serialization mode to load the model state? If what I’m thinking is the case u might want to upgrade to v1.6 The error is obviously a serialization error b4 u update to v1.6 try setting the serialization to true in th&hellip;
0
2020-09-04T13:27:14.939Z
https://discuss.pytorch.org/t/unable-to-load-model-state-dict-using-torch-utils-model-zoo-load-url/95172/9
Your target is probably all zeros. I would recommend to avoid narmalizing the target and rescaling it again. Instead just keep the class indices and remove the transformation for your target. If you call target.long() on small numbers, they will be all zeros. Scaling with 255 won’t change that. A&hellip; NMS is one ...
770
{'text': ['Could it be possible then that the torch.hub.load_state_dict( ) is using the new serialization mode to load the model state?\n\nIf what I’m thinking is the case u might want to upgrade to v1.6\n\nThe error is obviously a serialization error b4 u update to v1.6 try setting the serialization to true in th&hell...
Debugging runtime error module->forward(inputs) libtorch 1.4
I have a question related to this project <a href="https://github.com/NathanUA/U-2-Net/blob/7e5ff7d4c3becfefbb6e3d55916f48c7f7f5858d/u2net_test.py#L104" rel="nofollow noopener">https://github.com/NathanUA/U-2-Net/blob/7e5ff7d4c3becfefbb6e3d55916f48c7f7f5858d/u2net_test.py#L104</a> I can trace the net like this: trace...
0
2020-05-22T03:00:57.735Z
It was an issue with DLLs… TouchDesigner has its own DLLs in C:/Program Files/Derivative/TouchDesigner/bin. These DLLs get loaded when TouchDesigner opens. My custom plugin is in Documents/Derivative/Plugins and all of the libtorch DLLs are also there. My thought was that having everything in this&hellip;
0
2020-07-29T23:29:29.075Z
https://discuss.pytorch.org/t/debugging-runtime-error-module-forward-inputs-libtorch-1-4/82415/11
It was an issue with DLLs… TouchDesigner has its own DLLs in C:/Program Files/Derivative/TouchDesigner/bin. These DLLs get loaded when TouchDesigner opens. My custom plugin is in Documents/Derivative/Plugins and all of the libtorch DLLs are also there. My thought was that having everything in this&hellip; You could r...
2,156
{'text': ['It was an issue with DLLs…\n\nTouchDesigner has its own DLLs in C:/Program Files/Derivative/TouchDesigner/bin. These DLLs get loaded when TouchDesigner opens.\n\nMy custom plugin is in Documents/Derivative/Plugins and all of the libtorch DLLs are also there. My thought was that having everything in this&hell...
How to plot training and testing graphs for this pytorch model here?
Hi there I am training a model for the function train and test given here, finally called the main function. I need to see the training and testing graphs as per the epochs for observing the model performance. Can someone extend the code here? import torch from torch.utils.data import DataLoader as&hellip;
0
2021-11-21T09:14:45.568Z
You could return the tensors or numpy arrays containing the loss values from the train and test functions and plot it in a single plt.plot in the main script.
0
2021-12-03T00:37:36.110Z
https://discuss.pytorch.org/t/how-to-plot-training-and-testing-graphs-for-this-pytorch-model-here/137420/12
It was an issue with DLLs… TouchDesigner has its own DLLs in C:/Program Files/Derivative/TouchDesigner/bin. These DLLs get loaded when TouchDesigner opens. My custom plugin is in Documents/Derivative/Plugins and all of the libtorch DLLs are also there. My thought was that having everything in this&hellip; You could r...
1,387
{'text': ['You could return the tensors or numpy arrays containing the loss values from the train and test functions and plot it in a single plt.plot in the main script.'], 'answer_start': [1387]}
Loss becomes nan after few iterations
# layers self.hidden_layer_1 = torch.nn.Linear(self.input_neurons,self.hidden_neurons_1) self.hidden_layer_2 = torch.nn.Linear(self.hidden_neurons_1,self.hidden_neurons_2) self.output = torch.nn.Linear(self.hidden_neurons_2, self.output_neurons) def forward(self, input): print(input.isnan()&hellip;
0
2021-03-11T16:15:07.616Z
You could try training with smaller learning rates e.g. 1e-3, 1e-4, 1e-5, … (as <a class="mention" href="/u/juanfmontesinos">@JuanFMontesinos</a> had already mentioned)
0
2021-03-15T13:12:07.798Z
https://discuss.pytorch.org/t/loss-becomes-nan-after-few-iterations/114491/14
It was an issue with DLLs… TouchDesigner has its own DLLs in C:/Program Files/Derivative/TouchDesigner/bin. These DLLs get loaded when TouchDesigner opens. My custom plugin is in Documents/Derivative/Plugins and all of the libtorch DLLs are also there. My thought was that having everything in this&hellip; You could r...
468
{'text': ['You could try training with smaller learning rates e.g. 1e-3, 1e-4, 1e-5, … (as <a class="mention" href="/u/juanfmontesinos">@JuanFMontesinos</a> had already mentioned)'], 'answer_start': [468]}
Is it planned to support nn.Embeddings quantization?
First of all, I would like to thank you for the awesome torch.quantization . But at the moment, the quantization of embeddings is not supported, although ususally it’s one of the biggest (in terms of size) parts of the model (in NLP). I tried to use nn.Embeddings as nn.Linear because they have&hellip;
0
2020-07-14T13:19:44.747Z
It is possible to set the qconfig of Embeddings to None if you wish to skip quantizing them. For example class EmbeddingWithLinear(torch.nn.Module): def __init__(self): super().__init__() self.emb = torch.nn.Embedding(num_embeddings=10, embedding_dim=12) &hellip;
3
2021-02-20T22:41:47.438Z
https://discuss.pytorch.org/t/is-it-planned-to-support-nn-embeddings-quantization/89154/15
It is possible to set the qconfig of Embeddings to None if you wish to skip quantizing them. For example class EmbeddingWithLinear(torch.nn.Module): def __init__(self): super().__init__() self.emb = torch.nn.Embedding(num_embeddings=10, embedding_dim=12) &hellip; I write the dimensions in the comments. Given: z =...
1,272
{'text': ['It is possible to set the qconfig of Embeddings to None if you wish to skip quantizing them. For example\n\nclass EmbeddingWithLinear(torch.nn.Module):\n\ndef __init__(self):\n\nsuper().__init__()\n\nself.emb = torch.nn.Embedding(num_embeddings=10, embedding_dim=12)\n\n&hellip;'], 'answer_start': [1272]}
Custom Loss KL-divergence Error
import torch from torch.autograd import Variable from common.constants import Constants import torch.nn.functional as F class Cluster_Assignment_Hardening_Loss(torch.nn.Module): def __init__(self): super(Cluster_Assignment_Hardening_Loss,self).__init__() def forward(self,encode_output, cen&hellip;
0
2018-06-18T01:58:57.363Z
I write the dimensions in the comments. Given: z = torch.randn(7,5) # i, d use torch.stack([list of z_i], 0) if you don&#39;t know how to get this otherwise. mu = torch.randn(6,5) # j, d nu = 1.2 you do # I don&#39;t use norm. Norm is more memory-efficient, but possibly less numerically stable in bac&hellip;
1
2018-06-19T19:02:01.773Z
https://discuss.pytorch.org/t/custom-loss-kl-divergence-error/19850/10
It is possible to set the qconfig of Embeddings to None if you wish to skip quantizing them. For example class EmbeddingWithLinear(torch.nn.Module): def __init__(self): super().__init__() self.emb = torch.nn.Embedding(num_embeddings=10, embedding_dim=12) &hellip; I write the dimensions in the comments. Given: z =...
905
{'text': ['I write the dimensions in the comments. Given:\n\nz = torch.randn(7,5) # i, d use torch.stack([list of z_i], 0) if you don&#39;t know how to get this otherwise.\n\nmu = torch.randn(6,5) # j, d\n\nnu = 1.2\n\nyou do\n\n# I don&#39;t use norm. Norm is more memory-efficient, but possibly less numerically st...
Variable declared in nn.Parameter is not shown in model.parameters output
Hi! I implemented a model where one variable is defined inside the function nn.Parameter() in order to be used during the optimization process. However, when I request the list of variables defined in the model, that variable is not displayed. Here is the class, in this case, the variable I need t&hellip;
1
2019-04-16T01:59:29.492Z
Hi <a class="mention" href="/u/justusschock">@justusschock</a> and <a class="mention" href="/u/ptrblck">@ptrblck</a>: Thanks for your help. I changed the optimizer function from Adam to SGD and the loss function is minimized.
0
2019-04-18T01:42:53.907Z
https://discuss.pytorch.org/t/variable-declared-in-nn-parameter-is-not-shown-in-model-parameters-output/42678/10
It is possible to set the qconfig of Embeddings to None if you wish to skip quantizing them. For example class EmbeddingWithLinear(torch.nn.Module): def __init__(self): super().__init__() self.emb = torch.nn.Embedding(num_embeddings=10, embedding_dim=12) &hellip; I write the dimensions in the comments. Given: z =...
588
{'text': ['Hi <a class="mention" href="/u/justusschock">@justusschock</a> and <a class="mention" href="/u/ptrblck">@ptrblck</a>: Thanks for your help. I changed the optimizer function from Adam to SGD and the loss function is minimized.'], 'answer_start': [588]}
Efficient way of Calculating jacobians
Hello everyone. I would like to take the derivative of the output with respect to the input. People in other pages have suggested this: torch.autograd.grad(output, input, retain_graph=True)[0] However, I think this method is not very efficient: Many of the operations needed to take derivative wrt&hellip;
0
2019-03-18T17:38:59.829Z
Hi, It works as expected: import torch inp = torch.rand(5, 10, requires_grad=True) w1 = torch.rand(10, 1, requires_grad=True) w0 = torch.rand(1, 1, requires_grad=True) out = w0 + inp.mm(w1) out.sum().backward() print(&quot;w1&quot;) print(w1) print(&quot;inp.grad&quot;) print(inp.grad) Keep in mind here tha...
1
2019-03-20T14:49:23.030Z
https://discuss.pytorch.org/t/efficient-way-of-calculating-jacobians/40202/6
Hi, It works as expected: import torch inp = torch.rand(5, 10, requires_grad=True) w1 = torch.rand(10, 1, requires_grad=True) w0 = torch.rand(1, 1, requires_grad=True) out = w0 + inp.mm(w1) out.sum().backward() print(&quot;w1&quot;) print(w1) print(&quot;inp.grad&quot;) print(inp.grad) Keep in mind here tha...
1,626
{'text': ['Hi,\n\nIt works as expected:\n\nimport torch\n\ninp = torch.rand(5, 10, requires_grad=True)\n\nw1 = torch.rand(10, 1, requires_grad=True)\n\nw0 = torch.rand(1, 1, requires_grad=True)\n\nout = w0 + inp.mm(w1)\n\nout.sum().backward()\n\nprint(&quot;w1&quot;)\n\nprint(w1)\n\nprint(&quot;inp.grad&quot;)\n\nprint...
DDP training on RTX 4090 (ADA, cu118)
Hi, DDP training hangs with 100% CPU and no progress when using multiple RTX 4090s. Torch get stuck at File &quot;/usr/local/lib/python3.8/dist-packages/torch/multiprocessing/spawn.py&quot;, line 240, in spawn return start_processes(fn, args, nprocs, join, daemon, start_method=&#39;spawn&#39;) File &quot;/usr/lo&he...
0
2022-12-15T08:48:19.501Z
After further investigation the problem was due to NCCL backend trying to use peer to peer (P2P) transport. Forcing NCCL_P2P_DISABLE=1 fixed the issue :+1:
3
2022-12-18T10:43:12.932Z
https://discuss.pytorch.org/t/ddp-training-on-rtx-4090-ada-cu118/168366/4
Hi, It works as expected: import torch inp = torch.rand(5, 10, requires_grad=True) w1 = torch.rand(10, 1, requires_grad=True) w0 = torch.rand(1, 1, requires_grad=True) out = w0 + inp.mm(w1) out.sum().backward() print(&quot;w1&quot;) print(w1) print(&quot;inp.grad&quot;) print(inp.grad) Keep in mind here tha...
1,144
{'text': ['After further investigation the problem was due to NCCL backend trying to use peer to peer (P2P) transport.\n\nForcing NCCL_P2P_DISABLE=1 fixed the issue :+1:'], 'answer_start': [1144]}
Input format for pretrained torchvision models
Hi, Many torchvision models are also available in a fully trained mode. As it is not obvious, I’d like to know what’s the input format that the models are trained on. I’m assuming it’s color images so 3 channel tensors, but is it RGB or BGR (like in OpenCV \ cv2)? Also what’s the range values? I&hellip;
0
2019-06-23T15:35:18.307Z
From the <a href="https://pytorch.org/docs/stable/torchvision/models.html" rel="nofollow noopener">docs</a>: All pre-trained models expect input images normalized in the same way, i.e. mini-batches of 3-channel RGB images of shape (3 x H x W), where H and W are expected to be at least 224. The images have to be loaded...
1
2019-06-23T15:58:48.125Z
https://discuss.pytorch.org/t/input-format-for-pretrained-torchvision-models/48759/2
Hi, It works as expected: import torch inp = torch.rand(5, 10, requires_grad=True) w1 = torch.rand(10, 1, requires_grad=True) w0 = torch.rand(1, 1, requires_grad=True) out = w0 + inp.mm(w1) out.sum().backward() print(&quot;w1&quot;) print(w1) print(&quot;inp.grad&quot;) print(inp.grad) Keep in mind here tha...
488
{'text': ['From the <a href="https://pytorch.org/docs/stable/torchvision/models.html" rel="nofollow noopener">docs</a>:\n\nAll pre-trained models expect input images normalized in the same way, i.e. mini-batches of 3-channel RGB images of shape (3 x H x W), where H and W are expected to be at least 224. The images have...
Loss doesn't decrease, reuqires_grad = True
trying to do transfer learning and fine-tuning of a few layer of one model to another model with shared architecture. after initializing the new model and loading the shared weights i start training as usual and no training occur. i look at a conv3d layer object and see in it’s attributes (only c&hellip;
0
2021-01-06T10:13:14.971Z
ok! seems like the entire drama was solved by changing the Relu at the end of the network to LeakyRelu. i don’t fully understand what happened, maybe albanD can comment? my intuition is that the entire network is composed of LeakyRelus and norm layers, so it must contain a lot of negative activati&hellip;
0
2021-01-07T11:41:54.736Z
https://discuss.pytorch.org/t/loss-doesnt-decrease-reuqires-grad-true/108071/13
ok! seems like the entire drama was solved by changing the Relu at the end of the network to LeakyRelu. i don’t fully understand what happened, maybe albanD can comment? my intuition is that the entire network is composed of LeakyRelus and norm layers, so it must contain a lot of negative activati&hellip; We currentl...
1,778
{'text': ['ok! seems like the entire drama was solved by changing the Relu at the end of the network to LeakyRelu.\n\ni don’t fully understand what happened, maybe albanD can comment?\n\nmy intuition is that the entire network is composed of LeakyRelus and norm layers, so it must contain a lot of negative activati&hell...
Simple quantized model doesn't export to ONNX
Hello, I’m having problems exporting a very simple quantized model to ONNX. The error message I’m seeing is - AttributeError: &#39;torch.dtype&#39; object has no attribute &#39;detach&#39; The cause of this is that (‘fc1._packed_params.dtype’, torch.qint8) is ends up in the state_dict. I asked on a previous (and&hel...
0
2020-07-21T11:12:10.116Z
We currently don’t support exporting pytorch quantized models to ONNX. We welcome suggestions and contributions for this!
0
2021-04-30T05:45:25.282Z
https://discuss.pytorch.org/t/simple-quantized-model-doesnt-export-to-onnx/90019/10
ok! seems like the entire drama was solved by changing the Relu at the end of the network to LeakyRelu. i don’t fully understand what happened, maybe albanD can comment? my intuition is that the entire network is composed of LeakyRelus and norm layers, so it must contain a lot of negative activati&hellip; We currentl...
1,198
{'text': ['We currently don’t support exporting pytorch quantized models to ONNX. We welcome suggestions and contributions for this!'], 'answer_start': [1198]}
Training faster-rcnn on multiple gpus on single node
I am getting started with torch, and trying to understand the object detection support in it using <a href="https://pytorch.org/tutorials/intermediate/torchvision_tutorial.html" rel="nofollow noopener">https://pytorch.org/tutorials/intermediate/torchvision_tutorial.html</a> I am having trouble paralleilizing the faste...
1
2019-10-04T02:36:03.555Z
My bad. In the target dict, target[“image_id”] needs to be torch.tensor([idx]). I was setting it to torch.tensor(idx).
0
2019-10-05T03:06:56.606Z
https://discuss.pytorch.org/t/training-faster-rcnn-on-multiple-gpus-on-single-node/57433/9
ok! seems like the entire drama was solved by changing the Relu at the end of the network to LeakyRelu. i don’t fully understand what happened, maybe albanD can comment? my intuition is that the entire network is composed of LeakyRelus and norm layers, so it must contain a lot of negative activati&hellip; We currentl...
431
{'text': ['My bad. In the target dict, target[“image_id”] needs to be torch.tensor([idx]). I was setting it to torch.tensor(idx).'], 'answer_start': [431]}