akankshakshurai/cuda-error-resolution-analysis huggingface dataset:
Labels names of Pretrained Mask RCNN model

username: Jindong
cooked: <p>Hi, everyone,</p>
<p>I have a question about the name of labels predicted by pretrained mask rcnn in Pytorch,<br>
torchvision.models.detection.maskrcnn_resnet50_fpn</p>
<p>I wonder if there is an official name lists  indicating the name of each label number, like<br>
0 --&gt;BG<br>
1–&gt;person<br>
…</p>
<p>Thanks</p>

username: AKASH_KUMAR
cooked: <p>Check out this link: <a href="https://github.com/matterport/Mask_RCNN/blob/master/samples/demo.ipynb" class="inline-onebox" rel="noopener nofollow ugc">Mask_RCNN/demo.ipynb at master · matterport/Mask_RCNN · GitHub</a></p>
<p>Although the repo is for Keras, I guess it serves your purpose. Class labels remain the same.</p>
How to get partial encoder input gradient?

username: lee_hyungyu
cooked: <p>I want to get the gradients of “mixup_state” which is the input of the “self.encoder”, then those concatenated with “mixup_action” are fed to the “self.discriminator”.<br>
So, I need the gradients of disc → discriminator → encoder → state gradient</p>
<p>But it gives the error “RuntimeError: One of the differentiated Tensors appears to not have been used in the graph. Set allow_unused=True if this is the desired behavior”. But if setting allow_unused=True, the gradient of the “mixup_state” become None.<br>
I think it is because “mixup_action” is not the input of the encoder and when gradients are backpropagated from disciriminator to encoder. How can I get the gradient of “mixup_state”?</p>
<pre><code>mixup_data = torch.cat([self.state_encoder(mixup_state), mixup_action], dim=1)
mixup_state.requires_grad = True
# mixup_action.requires_grad = True # either, mixup_action.detach(), all same error
disc = self.discriminator(mixup_data)
ones = torch.ones(disc.size()).to(disc.device)
grad_state = autograd.grad(
            outputs=disc,
            inputs=mixup_state,
            grad_outputs=ones,
            create_graph=True,
            retain_graph=True,
            only_inputs=True)[0]</code></pre>
Sharing GPU tensors with torch.utils.DataLoader

username: IgnacioPickering
cooked: <p>I want use PyTorch’s dataloader with multiprocessing to return tensors allocated in the GPU. The docs explicitly say this is not recommended and point to the CUDA in multiprocessing documentation:</p>
<p><a href="https://pytorch.org/docs/stable/notes/multiprocessing.html#cuda-in-multiprocessing" class="onebox" target="_blank" rel="noopener nofollow ugc">https://pytorch.org/docs/stable/notes/multiprocessing.html#cuda-in-multiprocessing</a></p>
<p>From the documentation I gather that this should work properly as long as I wrap my training code in <code>if __main__ == '__name__'</code>, use “spawn” as the multiprocessing context, keep persistent_workers = True, and del the tensors after using them on the main training loop, so the workers can release the memory of the copied tensors. Is this correct or are there any other issues I should be aware of regarding this?</p>
I wanna find some torch function ;

username: danchu
cooked: <p>I wanna find some torch function like this:</p>
<p>input : a = [[1,2,3,4], [5,6,7,8]], b = [[0,0,0,0],[0,0,0,0]]<br>
output : c = [[[1,0],[2,0],[3,0],[4,0]],[[5,0],[6,0],[7,0],[8,0]]]</p>
<p>Does this kind of function exist in torch?</p>

username: ptrblck
cooked: <p>Yes, you can use <code>torch.stack</code>:</p>
<pre><code class="lang-python">a = torch.tensor([[1,2,3,4], [5,6,7,8]])
b = torch.tensor([[0,0,0,0],[0,0,0,0]])

c = torch.tensor([[[1,0],[2,0],[3,0],[4,0]],[[5,0],[6,0],[7,0],[8,0]]])
print(c)
&gt; tensor([[[1, 0],
           [2, 0],
           [3, 0],
           [4, 0]],

          [[5, 0],
           [6, 0],
           [7, 0],
           [8, 0]]])

d = torch.stack((a, b), dim=2)
print(d)
&gt; tensor([[[1, 0],
           [2, 0],
           [3, 0],
           [4, 0]],

          [[5, 0],
           [6, 0],
           [7, 0],
           [8, 0]]])
</code></pre>

username: danchu
cooked: <p>oh, that’s exactly what I want.</p>
<p>thanks so much :).</p>
What does register_buffer do?

username: Sanjan_Das
cooked: <p>I’m working through a tutorial on transformers (<a href="https://uvadlc-notebooks.readthedocs.io/en/latest/tutorial_notebooks/tutorial6/Transformers_and_MHAttention.html" class="inline-onebox" rel="noopener nofollow ugc">Tutorial 6: Transformers and Multi-Head Attention — UvA DL Notebooks v1.2 documentation</a>) and I came across this block of code about positional encoding.</p>
<blockquote>
<p>class PositionalEncoding(nn.Module):</p>
<pre><code>def __init__(self, d_model, max_len=5000):
    """
    Inputs
        d_model - Hidden dimensionality of the input.
        max_len - Maximum length of a sequence to expect.
    """
    super().__init__()

    # Create matrix of [SeqLen, HiddenDim] representing the positional encoding for max_len inputs
    pe = torch.zeros(max_len, d_model)
    position = torch.arange(0, max_len, dtype=torch.float).unsqueeze(1)
    div_term = torch.exp(torch.arange(0, d_model, 2).float() * (-math.log(10000.0) / d_model))
    pe[:, 0::2] = torch.sin(position * div_term)
    pe[:, 1::2] = torch.cos(position * div_term)
    pe = pe.unsqueeze(0)

    # register_buffer =&gt; Tensor which is not a parameter, but should be part of the modules state.
    # Used for tensors that need to be on the same device as the module.
    # persistent=False tells PyTorch to not add the buffer to the state dict (e.g. when we save the model)
    self.register_buffer('pe', pe, persistent=False)

def forward(self, x):
    x = x + self.pe[:, :x.size(1)]
    return x
</code></pre>
</blockquote>
<p>I haven’t understood what the <code>register_buffer</code> does, would someone be able to explain it in an easier way? I get that it’s saved alongside model parameters but isn’t included in gradient calculations - so what’s the difference between this and just setting the <code>requires_grad</code> to be <code>False</code>?</p>

username: shaolinkhoa
cooked: <p>I think this <a href="https://discuss.pytorch.org/t/what-is-the-difference-between-register-buffer-and-register-parameter-of-nn-module/32723">answer</a> can help you. Also, another <a href="https://stackoverflow.com/questions/57540745/what-is-the-difference-between-register-parameter-and-register-buffer-in-pytorch" rel="noopener nofollow ugc">one</a></p>
Converting list of tensors to a tesnor module

username: ronnie
cooked: <p>i have tensors of size [336,261] generated in for loop for 10 iterations, i want them to be stored as out=[10,336,261]. what is the possible way to do this?</p>
<p>Right now i am storing it in list but when i have been unable to convert the list in a tensor module. any suggestions or help?</p>

username: a_d
cooked: <p>Hello<br>
you could use <code>torch.stack</code><br>
If <code>tensor_list</code> is the list of the tensors you obtain after the loop then -</p>
<pre><code class="lang-auto">desired_tensor = torch.stack(tensor_list, dim=0)
</code></pre>

username: ronnie
cooked: <p>thank you. it works like charm.</p>
Detectron 2 pred_masks checking to see if a given class has been detected?

username: Mona_Jalal
cooked: <p>How can I check to see if the pred_masks is false for a given COCO class (e.g. bicycle)?</p>
<pre><code class="lang-auto">(Pdb) instances.pred_masks
tensor([[[False, False, False,  ..., False, False, False],
         [False, False, False,  ..., False, False, False],
         [False, False, False,  ..., False, False, False],
         ...,
         [False, False, False,  ..., False, False, False],
         [False, False, False,  ..., False, False, False],
         [False, False, False,  ..., False, False, False]],

        [[False, False, False,  ..., False, False, False],
         [False, False, False,  ..., False, False, False],
         [False, False, False,  ..., False, False, False],
         ...,
         [False, False, False,  ..., False, False, False],
         [False, False, False,  ..., False, False, False],
         [False, False, False,  ..., False, False, False]]], device='cuda:0')
(Pdb) torch.all(instances.pred_masks == False)
tensor(False, device='cuda:0')
</code></pre>
<p>From the above it shows it is True for some classes, right? How can I check if it is true for a class name of my own interest?</p>
<p>I also have this dimension and am not exactly sure what it represents:</p>
<pre><code class="lang-auto">(Pdb) instances.pred_masks.shape
torch.Size([2, 414, 640])
</code></pre>
<p>[ a double-post of <a href="https://github.com/facebookresearch/detectron2/discussions/3036" class="inline-onebox" rel="noopener nofollow ugc">checking the pred_masks against COCO classes of interest · Discussion #3036 · facebookresearch/detectron2 · GitHub</a> ]</p>

username: Mona_Jalal
cooked: <p><code>       if coco_metadata.thing_classes.index(args.class_name) in instances.pred_classes:</code></p>
Implement elementwise "ufunc" in C++/CUDA extension

username: kosiokarchev
cooked: <p>I have a C++ implementation of a “special” function (an elliptic integral) that I can also modify into a cuda kernel if need be. What is the recommended way to code up an extension that applies it elementwise over tensors with automatic broadcasting, type upcasting, and CPU (parallelized) / cuda dispatch like a builtin function?</p>
<p><a href="https://pytorch.org/tutorials/advanced/cpp_extension.html" rel="noopener nofollow ugc">The extension tutorial</a> shows something slightly more complicated (not elementwise) but explicitly cannot handle mixed types or different sizes. And there’s some examples of automatic mixed precision and CPU/cuda dispatch in another tutorial, again assuming equal sizes though. In fact, a <a href="https://discuss.pytorch.org/t/broadcast-c-api/98884">similar question</a> (concerning only broadcast) was asked before but never answered. But this seems to me like a ubiquitous task for builtin functions, so I’m hoping there’s an easy way to do it.</p>

username: ptrblck
cooked: <p>Maybe you could use the <code>TensorIterator</code> as it’s also used in e.g. <a href="https://github.com/pytorch/pytorch/blob/ebd2c0a4ed73033a62b44198f369b7a682150d56/aten/src/ATen/native/UnaryOps.cpp">UnaryOps.cpp</a> and might fit your use case.</p>
Mobile Inference

username: onyx22574
cooked: <p>Hello all,</p>
<p>I’m a newbie to PyTorch and I would like to run inference on a mobile device (ARM-based). I have my PyTorch model that needs to run outside my development environment where the model prediction will be executed.<br>
Is there a PyTorch interpreter for embedded devices or what is workflow when the model needs to be run on embedded devices? How should I proceed to execute the PyTorch models on memory and computational constraint devices?</p>
<p>Thank you.</p>
Transferring pruning hooks

username: Dan_Blanaru
cooked: <p>Hello!<br>
I am currently having diffiiculties with implementing the lottery ticket hypothesis.<br>
I got a trained and pruned model, and i am trying to transfer the weight masks from the trained network to the untrained one.<br>
I have tried this but it has no effect:</p>
<pre><code class="lang-auto">def transfer_hooks(trained_model,fresh):
    fresh.conv1.register_forward_pre_hook(trained_model.conv1._forward_pre_hooks)
</code></pre>
<p>Also, deepcopy seems to be broken when copying pruned layers, throwing</p>
<pre><code class="lang-auto">RuntimeError: Only Tensors created explicitly by the user (graph leaves) support the deepcopy protocol at the moment
</code></pre>
<p>I have also tried with</p>
<pre><code class="lang-auto">copymodel.load_state_dict(torch.load(model_path))
</code></pre>
<p>but it only works if i apply pruning once on the copymodel before loading, else it throws:</p>
<pre><code class="lang-auto">RuntimeError: Error(s) in loading state_dict for network:
	Missing key(s) in state_dict: "conv1.weight", "conv2.weight", "fc1.weight", "fc2.weight". 
	Unexpected key(s) in state_dict: "conv1.weight_orig", "conv1.weight_mask", "conv2.weight_orig", "conv2.weight_mask", "fc1.weight_orig", "fc1.weight_mask", "fc2.weight_orig", "fc2.weight_mask". 

</code></pre>
<p>is there a more elegant solution out there, that doesnt require to apply a pruning step on the network beforehand and simply allows me to transfer the “pruning” component?</p>

username: Michela
cooked: <p>You pruned model is in a pruned reparametrization state, where pruned weights have been replaced as such: <code>weight</code> --&gt; <code>weight_orig</code>, <code>weight_mask</code>.<br>
Now, if you try to load those into an unpruned model via a state_dict, it will of course fail, because that reparametrization doesn’t exist in your unpruned model, and the keys in the state_dicts don’t match.</p>
<p>Instructions on how to solve this are provided in these answers: <a href="https://discuss.pytorch.org/t/proper-way-to-load-a-pruned-network/77694/3" class="inline-onebox">Proper way to load a pruned network</a></p>
<p>Let me know if you have any further questions.</p>

username: hgarud
cooked: <p>Hey <a class="mention" href="/u/dan_blanaru">@Dan_Blanaru</a> , any luck with transferring the forward pre hook from checkpoint to a newly instantiated model? If I understand correctly, PyTorch hooks are applied to the model instance and not to the parameters. So unless one saves the model instance along with the state_dict, the hooks are lost?</p>
C++ Pytorch API runs very slow on Windows

username: michellemarionette
cooked: <p>I have been using the C++ frontend API for a few days now but noticed a very drastic slow down in inference timings between Linux and Windows. On Windows a simple forward pass through my model can take many seconds in debug mode and up to a second in release mode. On my Ubuntu system timing isn’t even an issue I took into consideration because it only takes a few milliseconds for the forward pass to complete. Is this something common? Are there any obvious reasons which cause this sort of behavior? I am using the same exact code on both the Linux and Windows build and it was taken from this page: <a href="https://pytorch.org/cppdocs/installing.html" class="inline-onebox" rel="noopener nofollow ugc">Installing C++ Distributions of PyTorch — PyTorch master documentation</a></p>
What is __pycache__ folder?

username: krishna511
cooked: <p>I am sorry to ask this, may be not related to forum, but what is this cashe folder? and for what its  used<br>
?</p>

username: ptrmcl
cooked: <p>I think you may find <a href="https://stackoverflow.com/questions/16869024/what-is-pycache" rel="noopener nofollow ugc">this post</a> helpful.</p>
AttributeError: '_IncompatibleKeys' object has no attribute 'eval' CNN

username: Samiur_Rahman
cooked: <p>Hi, after the last epoch, i have an array of local model weights, which i use to load them onto an empty model to test it later on.</p>
<pre><code class="lang-auto">global_model = CNNMnist(args=args)
local_model1 = CNNMnist(args=args)
.........
#training
local_weights, local_losses = [], []
local_model = LocalUpdate(args=args, dataset=train_dataset,
                                      idxs=user_groups[idx], logger=logger)
            w, loss = local_model.update_weights(
                model=copy.deepcopy(global_model), global_round=epoch)
            local_weights.append(copy.deepcopy(w))

            local_losses.append(copy.deepcopy(loss))
# update global weights
        global_weights = average_weights(local_weights)
 # update global weights
        global_model.load_state_dict(global_weights)
</code></pre>
<p>The following line is where i start tinkering:</p>
<pre><code class="lang-auto">local_model1 = local_model1.load_state_dict(local_weights[0])
</code></pre>
<p>then i send the model to a function to get the metrics:<br>
<code>test_acc, test_loss, precision, recall, f1, confusion = sam_eval(args,local_model1,test_dataset)</code><br>
the error is thrown right towards the beginning of the function:</p>
<pre><code class="lang-auto">def sam_eval(args, model, test_dataset):
    device = 'cuda' if args.gpu else 'cpu'
    criterion = nn.NLLLoss().to(device)
    model.eval() #this is the line throwing the error
    loss, total, correct = 0.0, 0.0, 0.0
    ..........

</code></pre>
<p>p.s. when i do the same thing with <code>global_model</code>, it works just fine. And i also tried adding <code>local_model.to(device)</code> line to my code.<br>
Any help would be really appreciated.</p>

username: eqy
cooked: <p>I don’t think <code>load_state_dict</code> returns a reference to the model so you likely want to just change<br>
<code>local_model1 = local_model1.load_state_dict(local_weights[0])</code> to <code>local_model1.load_state_dict(local_weights[0])</code>.</p>

username: Samiur_Rahman
cooked: <p>thank you so much. this worked.<br>
p.s. the code does not work if i don’t do:</p>
<pre><code class="lang-auto">local_model1.to(device)
</code></pre>
What is tensor.init()

username: Shawn_Zhuang
cooked: <p>Hi,<br>
I saw this in code:<br>
<code>coors = coors.int()</code><br>
and coors is a tensor, whose shape is [1515,4].</p>
<p>I have googled the init function but found nothing.</p>
<p>Anybody know this function?</p>

username: ptrblck
cooked: <p>Based on your code snippet it seems you are looking for the <code>int()</code> operator, not <code>init()</code>.<br>
If that’s the case: the <code>int()</code> operation will return a tensor transformed to the <code>int32</code> data type:</p>
<pre><code class="lang-python">x = torch.randn(10) * 10
print(x)
&gt; tensor([  2.9199, -13.7902,  -0.3769, -11.2643,  -2.8111,  -0.7583,  -2.9747,
         12.1106,  -2.1383,   6.7038])

y = x.int()
print(y)
&gt; tensor([  2, -13,   0, -11,  -2,   0,  -2,  12,  -2,   6], dtype=torch.int32)
</code></pre>

username: Shawn_Zhuang
cooked: <p>OMG! I mistook it as init! So stupid <img src="https://discuss.pytorch.org/images/emoji/apple/hot_face.png?v=9" title=":hot_face:" class="emoji" alt=":hot_face:"></p>
Using Batch Sampler in a multi-gpu scenario

username: roman-vygon
cooked: <p>Hello, I have a piece of code that uses a torch.utils.data.DataLoader with a custom BatchSampler to sample batches with the same amount of objects in each class.</p><aside class="onebox githubblob">
  <header class="source">
      <a href="https://github.com/roman-vygon/triplet_loss_kws/blob/master/layers/datalayer.py" target="_blank" rel="noopener nofollow ugc">github.com</a>
  </header>
  <article class="onebox-body">
    <h4><a href="https://github.com/roman-vygon/triplet_loss_kws/blob/master/layers/datalayer.py" target="_blank" rel="noopener nofollow ugc">roman-vygon/triplet_loss_kws/blob/master/layers/datalayer.py</a></h4>
<pre><code class="lang-py">from functools import partial
from typing import Any, Dict, List, Optional, Union

import numpy as np
import torch
from nemo import logging
from nemo.backends.pytorch import DataLayerNM
from nemo.collections.asr.parts.dataset import AudioLabelDataset, seq_collate_fn
from nemo.collections.asr.parts.features import WaveformFeaturizer
from nemo.collections.asr.parts.perturb import AudioAugmentor
from nemo.collections.asr.parts.perturb import perturbation_types
from nemo.core.neural_types import *
from torch.utils.data.sampler import BatchSampler


class BalancedBatchSampler(BatchSampler):
    """
    BatchSampler - from a MNIST-like dataset, samples n_classes and within these classes samples n_samples.
    Returns batches of size n_classes * n_samples
    """
</code></pre>

  This file has been truncated. <a href="https://github.com/roman-vygon/triplet_loss_kws/blob/master/layers/datalayer.py" target="_blank" rel="noopener nofollow ugc">show original</a>

  </article>
  <div class="onebox-metadata">
    
    
  </div>
  <div style="clear: both"></div>
</aside>
<p>
I’m trying to use it in a multi-gpu scenario with NeMo framework. By default when in multi-gpu mode it should be something like this:</p>
<pre><code class="lang-auto">if self._placement == DeviceType.AllGpu:
    sampler = torch.utils.data.distributed.DistributedSampler(self._dataset)

self._dataloader = torch.utils.data.DataLoader(
            dataset=self._dataset,            
            sampler=sampler,
            num_workers=num_workers,
        )
</code></pre>
<p>I’ve found some tricks to implement a custom distributed sampler, but none of them work for custom distributed batch sampler. What can I do?</p>

username: wayi
cooked: <p><a class="mention" href="/u/vitalyfedyunin">@VitalyFedyunin</a> for data loader questions</p>
Relative error loss functions and defining your own loss functions

username: hankdikeman
cooked: <p>Currently, I am pursuing a regression problem where I am attempting to estimate the time derivative of chemical species undergoing reaction and I am having a issue with the scales of my output. Since this is a detonation reaction, my outputs can range from essentially 0 for most cases to very large for others (during a detonation).</p>
<p>I think I am having problems with MSE as the loss function for this problem, since what I am really after is a low <em>percentage</em> error on each derivative estimation. If the output is meant to be 0.01 and the network predicts 10, I would like to punish this much more heavily than if the output is meant to be 1000 and the network predicts 1010. As of right now, I suspect that these large derivatives are dominating due to large contributions to loss.</p>
<p>Is there a loss function that implements a relative error loss based on training data? If I am correct in thinking that there is not, what is the recommended way to define a custom loss function?</p>

username: ariG23498
cooked: <p>I am not sure about the loss that would be good for your case but if you want a custom loss formulation here is a great thread <a href="https://discuss.pytorch.org/t/custom-loss-functions/29387/2" class="inline-onebox">Custom loss functions - #2 by ptrblck</a></p>
Using ConcatDataset slows down training by 10

username: yonatansc97
cooked: <p>Hi everyone,</p>
<p>I’m using a custom Dataset, which loads data from a single h5. This runs fast and works well with num_workers=6.</p>
<p>However, I have 20 files I would like to load from, so I created 20 datasets and tried to use the mentioned dataset by creating a torch.utils.data.dataset.ConcatDataset.</p>
<p>Surprisingly, this runs extremely slow. As it turns out, 87% of the time is spent waiting.<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/a/c/ac9c1251221237cbdd581a574c17ab3c6e94272e.png" data-download-href="https://discuss.pytorch.org/uploads/default/ac9c1251221237cbdd581a574c17ab3c6e94272e" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/a/c/ac9c1251221237cbdd581a574c17ab3c6e94272e_2_690x97.png" alt="image" data-base62-sha1="oCYvpE7Wzun3BziBCOgE8jtQwZo" width="690" height="97" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/a/c/ac9c1251221237cbdd581a574c17ab3c6e94272e_2_690x97.png, https://discuss.pytorch.org/uploads/default/optimized/3X/a/c/ac9c1251221237cbdd581a574c17ab3c6e94272e_2_1035x145.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/a/c/ac9c1251221237cbdd581a574c17ab3c6e94272e.png 2x" data-dominant-color="424547"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">1127×159 21.3 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>Things I thought and tried:</p>
<ul>
<li>After looking this up, I saw a suggestion to use <code>pin_memory=False</code>. This did not help to speed up anything. The suggestion is found here: <a href="https://discuss.pytorch.org/t/dataloader-method-acquire-of-thread-lock-objects/52943/2" class="inline-onebox">DataLoader: method 'acquire' of '_thread.lock' objects - #2 by bask0</a></li>
<li>I can’t use the torch.utils.data.dataset.ChainDataset, since my dataset is not iterable.</li>
<li>Looking for a solution, I came across the DistributedSampler. I thought this would maybe enable different workers to work with different subsets of the data, obviating the need to access the same object (a guess of mine). Looking this up, I saw only mentions of multi-nodes/multi-gpus training, which I’m not searching for.<br>
<a href="https://pytorch.org/docs/stable/data.html#torch.utils.data.distributed.DistributedSampler" class="inline-onebox" rel="noopener nofollow ugc">torch.utils.data — PyTorch 2.1 documentation</a></li>
</ul>
<p>Does anyone know how to approach this?<br>
Thanks in advance!</p>

username: neeraj_wagh
cooked: <p>+1. Same issue here. Training performance varies for each batch, some batches are loaded very quickly, some take an unacceptable amount of time.</p>
<p>Have 3000 .npy files with multiple samples in each. Unable to find a scalable solution for building a map-style dataset when samples are distributed across multiple files on disk.</p>
Expected 4 dimensional weight, expected 3

username: sanyam.ss99
cooked: <pre><code class="lang-auto">import math
from copy import copy
from pathlib import Path

import numpy as np
import pandas as pd
import requests
import torch
import torch.nn as nn
from PIL import Image
from torch.cuda import amp


def autopad(k, p=None):  # kernel, padding
    # Pad to 'same'
    if p is None:
        p = k // 2 if isinstance(k, int) else [x // 2 for x in k]  # auto-pad
    return p


class Conv(nn.Module):
    # Standard convolution
    def __init__(self, c1, c2, k=1, s=1, p=None, g=1, act=True):  # ch_in, ch_out, kernel, stride, padding, groups
        super(Conv, self).__init__()
        self.conv = nn.Conv2d(c1, c2, k, s, autopad(k, p), groups=g, bias=False)
        self.bn = nn.BatchNorm2d(c2)
        self.act = nn.SiLU() if act is True else (act if isinstance(act, nn.Module) else nn.Identity())

    def forward(self, x):
        print("Conv forward")
        return self.act(self.bn(self.conv(x)))

    def fuseforward(self, x):
        return self.act(self.conv(x))

class Focus(nn.Module):
    # Focus wh information into c-space
    def __init__(self, c1, c2, k=1, s=1, p=None, g=1, act=True):  # ch_in, ch_out, kernel, stride, padding, groups
        super(Focus, self).__init__()
        self.conv = Conv(c1 * 4, c2, k, s, p, g, act)
        # self.contract = Contract(gain=2)

    def forward(self, x):  # x(b,c,w,h) -&gt; y(b,4c,w/2,h/2)
        return self.conv(torch.cat([x[..., ::2, ::2], x[..., 1::2, ::2], x[..., ::2, 1::2], x[..., 1::2, 1::2]], 1))
        # return self.conv(self.contract(x))


x = torch.ones(3,416,416)
print("input dimension : ",x.shape)
print(x[..., ::2, ::2].shape)
print(x[..., 1::2, ::2].shape)
print(x[..., ::2, 1::2].shape)
print(x[..., 1::2, 1::2].shape)
x = torch.cat([x[..., ::2, ::2], x[..., 1::2, ::2], x[..., ::2, 1::2], x[..., 1::2, 1::2]])
print(x.shape)
focuslayer = Focus(3,6)
x = focuslayer.conv(x)
print(x.shape)
</code></pre>
<p>error message :</p>
<pre><code class="lang-auto">Expected 4-dimensional input for 4-dimensional weight [6, 12, 1, 1], but got 3-dimensional input of size [12, 208, 208] instead
</code></pre>
<p>Can anyone please help me debug this ? I am a beginner trying to understand how layers work.</p>

username: eqy
cooked: <p>Usually conv layers expect a 4 dimensional input where the first dimension is the batch dimension. If you are trying to pass a single image or example can you try something like <code>x.unsqueeze(0)</code> to add a batch dimension?</p>

username: sanyam.ss99
cooked: <p>Thank you so much sir.</p>
NameError: name 'torch' is not defined

username: brenth
cooked: <p>Hi all, I’m able to import torch but am getting an error about torch not being defined (NameError: name ‘torch’ is not defined) for the following statement:</p>
<p>device = torch.device(‘cuda’) if torch.cuda.is_available() else torch.device(‘cpu’)</p>
<p>Background: do not have cuda, just using cpu. python version: 3.7.6,  pytorch ver: 1.5.1, using conda. Any insights would be greatly appreciated, thanks</p>

username: ptrblck
cooked: <p>Could you post the exact stack trace and error message, please?</p>

username: alpha_omega_alpha
cooked: <p>Sometimes when I encounter this, restarting the Python kernel and re-importing torch does the trick.</p>

username: Pedro_Yuri_Marquez_S
cooked: <p>you can use the option execution enviroment → change type of execution enviroment  → aceleration by hardaware : none</p>
How Flashlight release will affect PyTorch development?

username: lithuak
cooked: <p>How Flashlight <a href="https://ai.facebook.com/blog/flashlight-fast-and-flexible-machine-learning-in-c-plus-plus/" rel="noopener nofollow ugc">release</a> is gonna affect PyTorch development?</p>
<p>What are the plans?</p>

username: smth
cooked: <p>it wont affect pytorch development at all</p>
Init Weights with Gaussian Kernels

username: magnus_w
cooked: <p>hey,<br>
is there a quick way to fill filters with Gauss filters + noise. i am familiar with …</p>
<pre><code>def weights_init(m):
    if isinstance(m, nn.Conv2d):
        m.weight.data.normal_(0, 0.02)
        m.bias.data.normal_(0, 0.001)
</code></pre>
<p>However I don’t know how to init s.t. we have gaussian filters.</p>

username: smth
cooked: <p>Generate your filter with <a href="https://docs.scipy.org/doc/scipy-0.16.1/reference/generated/scipy.ndimage.filters.gaussian_filter.html">https://docs.scipy.org/doc/scipy-0.16.1/reference/generated/scipy.ndimage.filters.gaussian_filter.html</a></p>
<p>copy over into <code>m.weight.data</code><br>
<code>m.weight.data</code> is of shape: <code>nOutputChannels x nInputChannels x kernelHeight x kernelWidth</code>, so you have to generate <code>nOutputChannels * nInputChannels</code>, then make a numpy array of the same shape as <code>m.weight.data</code> and then copy:</p>
<pre><code class="lang-auto">generated_filters = ... # some scipy / numpy logic
m.weight.data.copy_(torch.from_numpy(generated_filters))
</code></pre>

username: mathematics
cooked: <p>I solved it as above answer as</p>
<pre><code class="lang-auto">        generated_filters = gaussian_filter(m.weight.data, sigma=0.5)
        m.weight.data.copy_(torch.from_numpy(generated_filters))
</code></pre>
<p>Thank you.</p>

username: DanielM
cooked: <p>Gaussian is another word for normal distribution, so you can just use:</p>
<pre><code class="lang-auto">torch.nn.init.normal_(m.weight, 0, 0.5)
</code></pre>
<p>Assuming you want a standard deviation (or sigma) of 0.5 and a mean of 0.<br>
Also see: <a href="https://pytorch.org/docs/stable/nn.init.html#torch.nn.init.normal_" class="inline-onebox" rel="noopener nofollow ugc">torch.nn.init — PyTorch 1.8.1 documentation</a></p>
Homoscedastic uncertainty loss implementation

username: nivesh_gadipudi
cooked: <p>I am trying to implement the Homoscedastic uncertainty loss from <a href="https://arxiv.org/abs/1704.00390" rel="noopener nofollow ugc">Geometric Loss Functions for Camera Pose Regression with Deep Learning</a>.</p>
<pre><code class="lang-auto">class HomoLoss(nn.Module):
	def __init__(self):
		super(HomoLoss, self).__init__()
		self.sx = nn.Parameter(torch.tensor(0.0))
		self.sq = nn.Parameter(torch.tensor(-3.5))
		self.criterion = nn.MSELoss(reduction = 'mean')
	def forward(self, out, gt):
		rot_loss = self.criterion(out[:, 3:], gt[:, 3:])
		trans_loss = self.criterion(out[:, :3], gt[:, :3])
		loss = self.learned_loss(trans_loss, rot_loss)
		#print("SX: {} and SQ: {} values are".format(self.sx, self.sq))
		return loss

	def learned_loss(self, trans_loss, rot_loss):
		return (-1*self.sx).exp()*trans_loss + self.sx + (-1*self.sq).exp()*rot_loss + self.sq
</code></pre>
<p>is this the correct way to implement and my loss is always in negative, is it behaving as properly?</p>
<p>Any leads would be appreciated !!!</p>

username: nivesh_gadipudi
cooked: <p><a class="mention" href="/u/alband">@albanD</a> can you help me out with this. When i start training with values sx, sq = 0.0, -3.0 as suggested by the author my loss is diverging to negative.</p>
<pre><code class="lang-auto">epoch1-------[02:56&lt;00:00,  3.62it/s, average_loss=-18.351]
epoch2-------[02:54&lt;00:00,  3.66it/s, average_loss=-22.009]
epoch3-------[02:54&lt;00:00, 4.55it/s, average_loss=-23.185]

</code></pre>
<p>Is it how it is supposed to work?</p>

username: albanD
cooked: <p>Hi,</p>
<p>I am not familiar with this loss function I’m afraid. Is there any reason why you can’t use the builtin one: <a href="https://pytorch.org/docs/master/generated/torch.nn.GaussianNLLLoss.html?highlight=homoscedastic" class="inline-onebox">GaussianNLLLoss — PyTorch master documentation</a> ?</p>

username: nivesh_gadipudi
cooked: <p>Thanks <a class="mention" href="/u/alband">@albanD</a>. I am totally unaware of this pytorch loss. It is similar to what i am trying to implement. It is natural for this loss to converge in negatives?</p>

username: albanD
cooked: <p>I am not a specialist into what it is doing but it seems to be doing homoscedastic assumption as well. So I though it might be related.</p>
Replace some values of output distribution in a differentiable way

username: Dongwon_Ryu
cooked: <p>Hi all.</p>
<p>Is there any way that you can replace some values of output from a network in a differentiable way?</p>
<p>For example,</p>
<pre><code class="lang-auto">idx = [[1, 2], [0, 1]]
idx = torch.tensor(idx)
prob = [[0.4, 0.6], [0.55, 0.45]]
prob = torch.tensor(prob)
# dist = f.forward(input)
dist = [[2, 7, 2, 4.5], [8, 0.2, 2, 4.5]]
dist = torch.tensor(dist)

print('=== dist before')
print(dist)
print(F.softmax(dist, dim=-1), '\n')

for i in range(dist.size(0)):
    dist[i, idx[i]] = prob[i] * dist[i, idx[i]].sum()

print('=== dist after')
print(dist)
print(F.softmax(dist, dim=-1))
</code></pre>
<p>The output is,</p>
<pre><code class="lang-auto">=== dist before
tensor([[2.0000, 7.0000, 2.0000, 4.5000],
        [8.0000, 0.2000, 2.0000, 4.5000]])
tensor([[6.1502e-03, 9.1277e-01, 6.1502e-03, 7.4925e-02],
        [9.6797e-01, 3.9661e-04, 2.3994e-03, 2.9230e-02]]) 

=== dist after
tensor([[2.0000, 3.6000, 5.4000, 4.5000],
        [4.5100, 3.6900, 2.0000, 4.5000]])
tensor([[0.0208, 0.1030, 0.6230, 0.2533],
        [0.3981, 0.1753, 0.0324, 0.3942]])
</code></pre>
<p>As you see, I am basically changing <code>[1, 2]</code> index in <code>[2, 7, 2, 4.5]</code> following by <code>[0.4, 0.6]</code> ratio. So, calculation would be, <code>0.4 * (7 + 2) = 3.6</code> and <code>0.6 * (7 + 2) = 5.4</code>. If I do this, the <code>grad_fn</code> changes from <code>AddmmBackward</code> to <code>CopySlices</code>. Does this mean that it is out of computation graph? If so, how do I handle this problem?</p>

username: JuanFMontesinos
cooked: <p>I mean, you can do that. What you should think about is if those gradients make sense and so. Think that when you replace the values, gradients will flow through those tensors.</p>
Custom kernel Conv2D

username: crist77
cooked: <p>Hi! Can I have a kernel for a conv2d with some parameters trainable and some parameters not trainable?</p>
<p>Let s say if I have 1 kernel with dim 9x9 , can I have the firs 4x9 params trainable and the last 5x9 params not trainable?</p>

username: ptrblck
cooked: <p>Yes, you could create a custom <code>nn.Parameter</code> for the trainable part and use <code>torch.cat</code> or <code>torch.stack</code> to create the <code>weight</code> tensor for the convolution. Once this is done, you could use the functional API via <code>F.conv2d(input, weight, ...)</code> to apply the convolution.<br>
You could use a custom <code>nn.Module</code> for these operations, if it would fit your use case.</p>
Cannot freeze model - requires grad is always true

username: szymonindy
cooked: <p>I have tried to freeze part of my model but it does not work. Gradient computation is still enabled for each layer. Is that some sort of bug or am I doing something wrong? <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=9" title=":slight_smile:" class="emoji" alt=":slight_smile:"></p>
<p><code>model = models.resnet18(pretrained=True)</code></p>
<pre><code class="lang-auto"># To freeze the residual layers
for param in model.parameters():
    param.require_grad = False
for param in model.fc.parameters():
    param.require_grad = True
</code></pre>
<pre><code class="lang-auto"># Replace last layer        
num_features = model.fc.in_features
model.fc = nn.Linear(num_features, 2)
model.fc = nn.Dropout(0.5)
</code></pre>
<pre><code class="lang-auto"># Find total parameters and trainable parameters
total_params = sum(p.numel() for p in model.parameters())
print(f'{total_params:,} total parameters.')
total_trainable_params = sum(
    p.numel() for p in model.parameters() if p.requires_grad)
print(f'{total_trainable_params:,} training parameters.')

21,284,672 total parameters.
21,284,672 training parameters.
</code></pre>
<pre><code class="lang-auto"></code></pre>

username: pascal_notsawo
cooked: <p>The line <code>model.fc = nn.Dropout(0.5)</code> seems to make no sense, since it completely changes <code>model.fc</code> from a linear layer with trainable parameters to a layer without trainable parameters (<code>nn.Dropout</code>)</p>
<p>Declare it as another layer:</p>
<pre><code class="lang-auto">model.fc = nn.Linear(num_features, 2)
model.dropout = nn.Dropout(0.5)
</code></pre>
<p>Or combine the two like this.</p>
<pre><code class="lang-auto">model.fc = nn.Sequential(
				nn.Linear(num_features, 2),
				nn.Dropout(0.5)
			)  
</code></pre>
<p>And let me know if it has changed.</p>

username: ptrblck
cooked: <p>You are creating a new <code>.require_grad</code> attribute for each parameter, while you most likely want to set the <code>.requires_grad</code> attribute to <code>False</code> for the parameters (note the missing s).</p>
Data loader for two datasets (same number and same resolution of images)

username: adam_kossemtini
cooked: <p>Hello,<br>
i have a single model (Net) that contains two separate ResNet (cnn) models.<br>
i want to pass two datasets(same number and same resolution of input images) into the same model using one dataloader.<br>
can you help me?</p>

username: JamesTrick
cooked: <p>From your <a href="https://discuss.pytorch.org/t/dataloader-for-two-concatenated-models/120988/4">other post</a> - does <a href="https://discuss.pytorch.org/t/train-simultaneously-on-two-datasets/649">this thread</a> help you? The idea would be to:</p>
<ul>
<li>Create two data sets</li>
<li>Create a final data set that joins the two datasets</li>
<li>Create a dataloader for the final concatenated datasets to pass into your model.</li>
</ul>

username: nivesh_gadipudi
cooked: <p>We need more information to come to a solution. However, it is possible to return different images with labels in the same dataloader.</p>
<pre><code class="lang-auto">class SampleDataloader(Dataset):
	def __init__(self, required_arguments...):
    #Modify as per your use
    self.length_samples = #length of samples
    def __len__(self):
         return self.length_samples
    def __getitem__(self, index):
        # returns a single sample at a time
         return image1, image2, label1, label2

</code></pre>
<p>As i’ve mentioned if you are looking for more accurate code, try to mention what you are trying to do.</p>
Nan gradient despite masking

username: randbit
cooked: <p>How can I compute this function in a way that handles gradients correctly?</p>
<pre><code class="lang-auto">def f(x):
    return torch.where(x &gt; 0, x, x / (1 - x))
</code></pre>
<p><a href="https://github.com/pytorch/pytorch/issues/15506" rel="noopener nofollow ugc">This issue</a> causes an incorrect <code>nan</code> gradient at <code>x == 1</code>:</p>
<pre><code class="lang-auto">x = torch.tensor(1., requires_grad=True)
y = f(x)
print(y)
y.backward()
print(x.grad)
</code></pre>
<p>I tried using <a href="https://pytorch.org/docs/stable/tensors.html#torch.Tensor.masked_scatter" rel="noopener nofollow ugc"><code>masked_scatter</code></a> but it also doesn’t work:</p>
<pre><code class="lang-auto">def f(x):
    return x.masked_scatter(x &lt; 0, x / (1 - x))
</code></pre>

username: notprime
cooked: <p>If your problem is related to the presence of NaNs, I think you could:</p>
<ol>
<li>use an <code>if statement</code> to avoid <code>x == 1</code>, you could set a smaller value for <code>x</code>, for instance <code>x = 0.98</code>;</li>
<li>before returning the value, you could check the presence of NaNs: you could create a variable <code>function = torch.where(x &gt; 0, x, x / (1 - x))</code>, then use <code>torch.nan_to_num(function, nan = value)</code>.</li>
</ol>
<p>I don’t know if this solutions are the best, but I guess they’re worth trying.<br>
Let me know if you’re able to solve the problem <img src="https://discuss.pytorch.org/images/emoji/apple/smiley.png?v=9" title=":smiley:" class="emoji" alt=":smiley:"></p>

username: Clifford451
cooked: <p>Solution is to use <code>Masking()</code> layers available in keras with <code>mask_value=0</code> . This is because when using empty vectors they are calculated into the loss, by using <code>Masking()</code> , as outlined by keras the padding vectors are skipped and not included<a href="https://www.facetimeapp.ltd/" rel="noopener nofollow ugc">.</a></p>
shape '[-1, 2, 4, 28]' is invalid for input of size 768

username: Qu_nh_Anh
cooked: <p>I’m trying to train IAM Dataset on TPSSpatialTransformerNetwork but finally I got an error: shape ‘[-1, 2, 4, 28]’ is invalid for input of size 768</p>
<p>Each image in the dataset has the size of (32,128). I can not figure out the shape it got in the error step. And here is the code:</p>
<pre><code class="lang-auto">class TPS_SpatialTransformerNetwork(nn.Module):
    def __init__(self):
        super(TPS_SpatialTransformerNetwork, self).__init__()
        self.conv1 = nn.Conv2d(1, 79, kernel_size=5)
        self.conv2 = nn.Conv2d(79, 256, kernel_size=5)
        self.conv2_drop = nn.Dropout2d()
        self.fc1 = nn.Linear(256, 512)
        self.fc2 = nn.Linear(512, 79)

        # Spatial transformer localization-network
        self.localization = nn.Sequential(
            nn.Conv2d(1, 8, kernel_size=7),
            nn.MaxPool2d(2, stride=2),
            nn.ReLU(True),
            nn.Conv2d(8, 79, kernel_size=5),
            nn.MaxPool2d(2, stride=2),
            nn.ReLU(True)
        )

        # Regressor for the 3 * 2 affine matrix
        self.fc_loc = nn.Sequential(
            nn.Linear(79 * 4 * 28, 32),
            nn.ReLU(True),
            nn.Linear(32, 3 * 2)
        )

        # Initialize the weights/bias with identity transformation
        self.fc_loc[2].weight.data.zero_()
        self.fc_loc[2].bias.data.copy_(torch.tensor([1, 0, 0, 0, 1, 0], dtype=torch.float))

    # Spatial transformer network forward function
    def stn(self, x):
        xs = self.localization(x)
        xs = xs.view(-1, 79 * 4 * 28)
        theta = self.fc_loc(xs)
        theta = theta.view(-1, 2, 4,28)


        grid = F.affine_grid(theta, x.size())
        x = F.grid_sample(x, grid)

        return x

    def forward(self, x):
        # transform the input
        x = self.stn(x)

        # Perform the usual forward pass
        x = F.relu(F.max_pool2d(self.conv1(x), 2))
        x = F.relu(F.max_pool2d(self.conv2_drop(self.conv2(x)), 2))
        x = x.view(-1, 320)
        x = F.relu(self.fc1(x))
        x = F.dropout(x, training=self.training)
        x = self.fc2(x)
        return F.log_softmax(x, dim=1)

4 frames
/content/drive/My Drive/OCR/transformation.py in stn(self, x)
     41         xs = xs.view(-1, 79 * 4 * 28)
     42         theta = self.fc_loc(xs)
---&gt; 43         theta = theta.view(-1, 2, 4,28)
     44 
     45 

RuntimeError: shape '[-1, 2, 4, 28]' is invalid for input of size 768
</code></pre>
Need help importing videos into PyTorch

username: Hummus
cooked: <p>I have trained a Faster RCNN model for detecting fish underwater. I am currently using a random selection of frames from a 1hr video and training in batches. I have a few questions that might help improve the accuracy of the model:</p>
<ol>
<li>Should I be training on a 1hr video without shuffling the data? What’s the best way to go about this?</li>
<li>Is there a way to inform the training of previous frames, so the model has some understanding of how fish move from frame to frame? This would help track fish between predicted frames, and reduce the number of false positives (eg. rocks, seaweed, misc. objects).</li>
<li>Should I be considering alternatives to Faster RCNN to achieve better results? (eg. Mask RCNN, Instance segmentation, YOLO/DeepSort)</li>
</ol>
<p>Cheers!</p>
How to split a tensor by segments

username: ikkem
cooked: <p>Hello,</p>
<p>I have an output tensor for which the shape is (3,5,100). So, for my case 16 is the batch size, 64 is the number of steps, and 100 is the features for each step.<br>
Moreover,  I have the following information:<br>
[[1,0,0,1,0] , [1,1,0,1,1], [1,0,0,0,1]]</p>
<p>So, [1,0,0,1,0] means that for the 1st tensor in my batch I want to split that tensor from index 0 to index 2 and from index 3 to index 5 (the end of the sequence).</p>
<p>[1,1,0,1,1] means that for the 2nd tensor in my batch I want to split that tensor from index 0 to index 0 and from index 1 to index 2 and from index 3 to index 3 and from index 4 to index 4.</p>
<p>So, in this batch, I will result with some segments of tensors that I will apply the mean on.</p>
<p>What’s the most efficient way to do it?</p>
Torch.nn.functional.interpolate memory issue

username: raceee
cooked: <p>I am trying to down sample a <code>.mp4</code> file for a vision project.</p>
<pre><code class="lang-auto">t = torchvision.io.read_video(r"path.mp4")
video_tensor= t[0]   # video_tensor.shape  ---&gt; [853, 1080, 1920, 3]
video_tensor= video_tensor.permute(0,3,1,2)
video_tensor= torch.reshape(video_tensor, (video_tensor.shape[0], video_tensor.shape[1], -1))
video_tensor= torch.nn.functional.interpolate(video_tensor.float(), scale_factor=0.3)
</code></pre>
<p>I get this error:</p>
<p><code>RuntimeError: [enforce fail at ..\c10\core\CPUAllocator.cpp:72] data. DefaultCPUAllocator: not enough memory: you tried to allocate 22071398400 bytes. Buy new RAM!</code></p>
<p>Is this a viable way to try to downscale video, or are there other functions I should be using?</p>
<p>Cheers!</p>
The code that was working previously, gets stuck at loading the checkpoint file that is cached on system

username: Mona_Jalal
cooked: <p>Do you know how I could fix this issue? This was working correctly but now it gets stuck at loading the model from cache apparently</p>
<pre><code class="lang-auto">(phosa) [jalal@goku phosa]$ python demo.py --filename input/other/bike.jpg --class_name bicycle

2021-05-11 01:33:26,300 INFO     Calling with args: Namespace(class_name='bicycle', filename='input/other/bike.jpg', lw_collision=None, lw_depth=None, lw_inter=None, lw_inter_part=None, lw_scale=None, lw_scale_person=None, lw_sil=None, mesh_index=0, output_dir='output')
2021-05-11 01:33:29,857 INFO     Loading checkpoint from detectron2://PointRend/InstanceSegmentation/pointrend_rcnn_R_50_FPN_3x_coco/164955410/model_final_3c3198.pkl
2021-05-11 01:33:29,864 INFO     URL https://dl.fbaipublicfiles.com/detectron2/PointRend/InstanceSegmentation/pointrend_rcnn_R_50_FPN_3x_coco/164955410/model_final_3c3198.pkl cached in /home/grad3/jalal/.torch/fvcore_cache/detectron2/PointRend/InstanceSegmentation/pointrend_rcnn_R_50_FPN_3x_coco/164955410/model_final_3c3198.pkl

</code></pre>
<p>a double-post of <a href="https://github.com/facebookresearch/phosa/issues/37" class="inline-onebox" rel="noopener nofollow ugc">running the demo code gets stuck at loading the checkpoint for model_final_3c3198.pkl · Issue #37 · facebookresearch/phosa · GitHub</a></p>

username: ptrblck
cooked: <p>Assuming you are trying to load a pretrained checkpoint, which can be downloaded again, try to move or delete the cached file and see, if a newly downloaded file would work.</p>

username: Mona_Jalal
cooked: <p>Thanks a lot, definitely a great idea. do you know sometimes the cached model breaks even if untouched (for 1-2 weeks)?</p>

username: Mona_Jalal
cooked: <p>hmm it was very weird. I reboot the machine and then I ran it again and it worked.</p>