akankshakshurai/cuda-error-resolution-analysis huggingface dataset:
What does work torch.cat(dim=2)?

wonchulSon: <p>Somewhere, I saw the <code>torch.cat((tensors),dim=2)</code> works.<br>
So I tried under code but it doesn’t working.</p>
<pre><code class="lang-auto">a = torch.randn(2,5)
b = torch.randn(3,5)

torch.cat((a,b),dim=2)
</code></pre>
<pre><code class="lang-auto">RuntimeError: Dimension out of range (expected to be in range of [-2, 1], but got 2)
</code></pre>
<p>What does meaning of <code>dim=2</code>?</p>

imaluengo: <p>It is going to try to concatenate across dimension 2 – but dimension numbers, as tensor indexes  start at <code>0</code> in PyTorch. Thus <code>dim=2</code> refers to the 3rd dimension, and your tensors are only 2-dimensional.</p>
Multi branching model depend on input data

AhmdNassar: <p>HI,<br>
I’m trying to implement imitation end-to-end self driving car model.</p>
<p><img src="https://discuss.pytorch.org/uploads/default/original/2X/5/5f1a3d0179a9a602254b40a2c88c8d94c08d46ea.png" alt="model-arch" data-base62-sha1="dzjzEiprGuv6Sx9CwZVPsmlpqKm" width="521" height="327"></p>
<p>as shown in image depend on command input I should pick a branch</p>
<p>That what I did…</p>
<p>in init</p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/2X/4/41a0ae87ef4ca05acfd6b094cd80c1b3cbc1059a.png" data-download-href="https://discuss.pytorch.org/uploads/default/41a0ae87ef4ca05acfd6b094cd80c1b3cbc1059a" title="build"><img src="https://discuss.pytorch.org/uploads/default/original/2X/4/41a0ae87ef4ca05acfd6b094cd80c1b3cbc1059a.png" alt="build" data-base62-sha1="9mzigH8HWTJ0Au5hD5yDnmile1I" width="690" height="363" data-dominant-color="2D3744"><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">build</span><span class="informations">935×493 11.2 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>and in feedforward</p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/2X/3/324188b5d71bf1558319053d71edbfba7bda4204.png" data-download-href="https://discuss.pytorch.org/uploads/default/324188b5d71bf1558319053d71edbfba7bda4204" title="feed"><img src="https://discuss.pytorch.org/uploads/default/original/2X/3/324188b5d71bf1558319053d71edbfba7bda4204.png" alt="feed" data-base62-sha1="7aAhku612p70T9aID4FA5j1UDhq" width="539" height="500" data-dominant-color="313B49"><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">feed</span><span class="informations">591×548 13.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>I don’t know if this is messy or not…</p>
<p>but when i tried to feed data to the model i get error said</p>
<p><img src="https://discuss.pytorch.org/uploads/default/original/2X/5/5f65cbe637c136d94237ec74143674ab869f988b.png" alt="error" data-base62-sha1="dBVsnctM49lqew1IwBcDgZQqkRl" width="520" height="157"></p>
<p>I don’t know how to do that… so how can I implement this branching part !</p>
<p>Thanks in advance</p>
Understanding tying of weights (CNN autoencoder)

vdw: <p>I have an CNN-based autoencoder setup that looks like this (showing only the Conv/ConvTranspose layers; 1d layers since I work with text):</p>
<pre><code>Encoder(
  (conv_layers): ModuleList(
     (0): Conv1d(300, 300, kernel_size=(5,), stride=(2,))
     (1): Conv1d(300, 600, kernel_size=(5,), stride=(2,))
     (2): Conv1d(600, 500, kernel_size=(10,), stride=(2,))
  )
  ...
)
Decoder(
  (deconv_layers): ModuleList(
    (0): ConvTranspose1d(500, 600, kernel_size=(10,), stride=(2,))
    (1): ConvTranspose1d(600, 300, kernel_size=(5,), stride=(2,))
    (2): ConvTranspose1d(300, 300, kernel_size=(5,), stride=(2,))
  )
)
</code></pre>
<p>This works already quite fine. Now I read about tying the weights of the respective Conv/ConvTranspose layers. To this end, I’ve added to following to the decoder:</p>
<pre><code>deconv_layers[0].weight = conv_layers[2].weight
deconv_layers[1].weight = conv_layers[1].weight
deconv_layers[2].weight = conv_layers[0].weight
</code></pre>
<p>Which seems to work – that is, it trains alright and the respective weight matrices are always identical. I check during training using, e.g.:</p>
<pre><code>torch.all(torch.eq(encoder.conv_layers[0].weight, decoder.deconv_layers[2]))
</code></pre>
<p>which is always 1 (True). However, I wonder if this is the best or even the right way to do:</p>
<ul>
<li>My current solution does not reduce the number of parameters. I assume that to correct way would be to define the 3 weight matrices first and given them to the encoder and decoder. I just don’t know how this would look like in proper code so that backprop works correctly.</li>
<li>Even if I don’t reduce the number of parameters, is my approach at least in principle correct. Technically, the encoder and decoder updates the <code>conv_layers</code> and <code>deconv_layers</code> independently. But given that the respective weights are identical, I guess this so no problem.</li>
</ul>
System reboot when increase batchsize

fft: <p>I tried to implement SSD by using pytorch code from <a href="https://github.com/amdegroot/ssd.pytorch" rel="nofollow noopener">https://github.com/amdegroot/ssd.pytorch</a>, strange things happened. When I set batch_size=1/2/4, cpu utilization is nearly 99%.(GPUs are used normally)When batch_size increased to 8 or more ,system crashed and reboot automatically. So I only can train it by using 4 batch_size , but finally I got lower mAP of 72.74 (compared with 77.43 from author), I think batch_size influence much but I cannot increase it because of the problem.</p>
<p>So I am really confused why it uses too much CPU in a GPU-used situation? How can I solve it.<br>
When I train other pytorch net , this weird thing doesn’t happened(about 1% utilization CPU used)<br>
Hardware:8x1080Ti, 56 cores ,ubuntu 16.04.</p>

ptrblck: <p>Could the increased batch size also increase the power usage of your GPUs which might crash (a too weak or faulty) PSU?<br>
Could you create a dummy model using all GPUs at high utilizations?<br>
Did you notice something else, e.g. your memory filling up etc.?</p>

fft: <p>Today I found When I set num_workers=2(not 4 in default),batch_size can be set larger than 4 and system won’t reboot automatically. But CPU utilization is still very high.</p>
<p>I think the problem is from dataloader in pytorch 0.4.0,how can I solve it?</p>

ptrblck: <p>Why do you think it’s a problem of the <code>DataLoader</code> in PyTorch <code>0.4.0</code>?<br>
Id your code running fine in newer versions?</p>
Autograd backward with a matrix

wentao: <p>Hi,</p>
<p>I’m new in pyorch and I have a little question.<br>
we use pytorch for backpropagation, we usually do: loss.backward(). And loss is a scalar. But what if my loss is not a scalar? Now I have a 54*3840 matrix, and I want use like Jacob matrix backpropagation. Do you know how can do it?</p>
Why use torch dataset?

Thomas_Johnson: <p>I understand that data.Dataset can be useful if we need to prepare our data (e.g., load it from disk, or do data augmentation). Is there any benefit to using Dataset if all of our data is already in memory and we are not doing augmentation?</p>

Tony-Y: <p>We can use <a href="https://pytorch.org/docs/stable/data.html#torch.utils.data.TensorDataset" rel="nofollow noopener">TensorDataset</a> for on-memory data that some tensors store. That dataset is fed to <a href="https://pytorch.org/docs/stable/data.html#torch.utils.data.DataLoader" rel="nofollow noopener">DataLoader</a>, which produces shuffled batches.</p>

Thomas_Johnson: <p>So it’s just so I don’t have to do my own shuffling?</p>

Tony-Y: <p>Your own shuffling is not banned in pytorch.</p>

justusschock: <p>Essentially it is, that you don’t have to bother yourself with shuffling, efficient batching (for various types of inputs) and pinning memory.</p>
<p>as <a class="mention" href="/u/tony-y">@Tony-Y</a> stated, you can always introduce your own methods, but you don’t have to.</p>
Which trick is used to numerically stabilize sleu?

Binbose: <p>I tried to implement my own version of selu like this:</p>
<pre><code class="lang-auto">class MySelu(nn.Module):

    def __init__(self):
        super(MySelu, self).__init__()

    def forward(self, x):
        term1 = torch.clamp(x, min=0)
        term2 = torch.clamp(1.6732632423543772848170429916717 * (torch.exp(x) -1), max=0)
        return 1.0507009873554804934193349852946 * ( term1 + term2)
</code></pre>
<p>It turns out though, that I run quickly in nan in the backward pass when using this module. Using autograd anomaly detection I found out, that his is due to the exp(x) producing nan in the backward pass. When I look at the c implementation of selu in pytorch <a href="https://github.com/pytorch/pytorch/blob/3796cbaf7ab4c4c30cb99191d55a8b9c50b398dc/caffe2/operators/selu_op.cu" rel="nofollow noopener">https://github.com/pytorch/pytorch/blob/3796cbaf7ab4c4c30cb99191d55a8b9c50b398dc/caffe2/operators/selu_op.cu</a> it says “// Reuse Y[i] to avoid computing exp(X[i])”. What do they mean? Which trick do they use to stabilize the computation?</p>
How can I print the shape of a tensor inside the forward function?

wasiahmad: <p>I have an attention decoder whose forward function is as follows.</p>
<pre><code>def forward(self, input, hidden, encoder_outputs):
    embedded = self.embedding(input).view(1, 1, -1)
    embedded = self.drop(embedded)
    attn_weights = F.softmax(self.attn(torch.cat((embedded[0], hidden[0]), 1)))
</code></pre>
<p>How can I print the shape of <code>embedded</code> tensor inside the forward function? I checked, simple print() statement doesn’t work.</p>
<p>Any suggestion?</p>

jekbradbury: <p>A print statement (<code>print(embedded.size())</code>) should work. What do you mean when you say it doesn’t work (nothing happens?)</p>

Nabarun_Goswami: <p>You can do <code>print(embedded.size())</code>. Works for me even in the <code>forward</code> function.</p>

Mithun_Paul: <p>The .size() solution didn’t work for me when I had created an embedding using nn.Embedding.  However, just printing the embeddings does show me size at the end of it:<br>
<code>print(embedded).</code><br>
Hope this helps someone</p>

kingxueyuf: <aside class="quote no-group" data-username="jekbradbury" data-post="2" data-topic="1143">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/jekbradbury/48/14_2.png" class="avatar"> jekbradbury:</div>
<blockquote>
<p>embedded.size()</p>
</blockquote>
</aside>
<p>does this return a tuple?<br>
I saw it is torch.Size([19, 25, 2100])</p>

jekbradbury: <p><code>torch.Size</code> is essentially a tuple, and can do the same things</p>

eduamf: <p>Use print(embedded) to see the shape, or embedded.eval()</p>
<p>If you want to see the content, embedded.weight will show you the tensor and if it requires grad.</p>
How can I expand tensor size?

Nick_Kim: <p>i have<br>
<code>input = torch.randn(48, 64, 8, 28, 28)</code><br>
and i want to resize it to (48,128,8,28,50) with zeros at once</p>
<p>I know this is not working but just for example,<br>
<code>t = torch.cat([input, torch.zeros(48,64,8,28,22)],dim=(1,4))</code></p>

Tony-Y: <pre><code class="lang-auto">import torch
input = torch.randn(48, 64, 8, 28, 28)
t = input.new_zeros(48,128,8,28,50)
t[:,:64,:,:,:28] = input
</code></pre>
Downsample module

JinyangGuo: <p>Hi there,</p>
<p>I am new to pytorch. Is there a layer to remove some spatial points in the feature map.<br>
For example, suppose we have a 64x224x224 feature map, which is the output of the intermediate layer of model. We also have a 224x224 spatial mask containing 0 or 1. We want to choose 112x112 points in the feature map by this mask. How can we choose the spatial location and output a feature map of 64x112x112? Is there a module to do that?</p>
Autograd output

cc22b9b790d907eb71bc: <p>Hi.</p>
<p>I’m trying to compute the gradient using Autograd.grad function.</p>
<p>I set a and b as follows.</p>
<blockquote>
<p>a = Variable(torch.FloatTensor([2]), requires_grad=True)<br>
b = a * torch.FloatTensor([3,4])</p>
</blockquote>
<p>and calculated the gradient by</p>
<blockquote>
<p>torch.autograd.grad(b, a, create_graph=True, grad_outputs=torch.ones_like(b))[0]</p>
</blockquote>
<p>It gives the result tensor([7]).</p>
<p>But as you can see in the equation, the derivative of b w.r.t a should be torch.tensor([3,4]).<br>
Why this grad function automatically sum up the results?<br>
And How can I get the gradient result as vector [3,4]??</p>
RNN loss second-order derivative

xiaofan: <p>I’m trying to take a second-order derivative of the RNN loss function, but I got an error “trying to differentiate twice a function that was markedwith <span class="mention">@once_differentiable</span>”. Does this mean the current pytorch implementation does not support 2nd order derivative?</p>

smth: <p>it doesn’t support 2nd order derivative for RNNs yet.</p>

ivallesp: <p>Wow! I have just experienced this limitation. I am implementing an WGAN with an LSTM in the generator and an LSTM in the discriminator and when I calculate the gradients I get</p>
<blockquote>
<p>RuntimeError: CudnnRNNLegacyBackward is not differentiable twice</p>
</blockquote>
<p>Is there any workaround? When do you think it is going to be implemented? <img src="https://discuss.pytorch.org/images/emoji/apple/smiley.png?v=12" title=":smiley:" class="emoji" alt=":smiley:" loading="lazy" width="20" height="20"></p>
<p>Thanks a lot</p>

tom: <p>You could use <a href="http://lernapparat.de/more-improved-wgan/#slogan" rel="nofollow noopener">SLOGAN</a>. The gradient penalty won’t be the hardest bit.</p>
<p>Best regards</p>
<p>Thomas</p>

ivallesp: <p>Wow! I didn’t know it! It is really good; impressive work. I have just adapted the SLOGAN loss to my net (for language generation) and now I can train it with 2 RNNs. It seems to be stabilizing, though it gets into a hard mode collapse. Lets wait a bit still… <img src="//discuss.pytorch.org/images/emoji/apple/smiley.png?v=5" title=":smiley:" class="emoji" alt=":smiley:"> Thanks!!!</p>

tanyaisanumber: <p>Any updates on the issue?<br>
because I am running into same problem <code>RuntimeError: CudnnRNNLegacyBackward is not differentiable twice</code></p>

tom: <p>As far as I know, this is still the same. You might have better luck using LSTMCell and friends.</p>
<p>Best regards</p>
<p>Thomas</p>

Sachin_Kumar: <p>Has there been any update on this? I am facing the same problem.</p>
Problem importing CyclicLR

boris: <p>For some reason I can’t import CyclicLR. For example, “from torch.optim.lr_scheduler import CyclicLR” should work but it doesn’t. I have the latest version of PyTorch (version 1.1.0).  Don’t know what the issue is. Help would be appreciated.</p>

ptrblck: <p>What kind of error message do you get?<br>
I tried it in the latest stable version and it is working on my machine.</p>

boris: <p>I get AttributeError: module ‘torch.optim’ has no attribute ‘CyclicLR’.</p>
<p>It’s as if it doesn’t exist. Everything else works fine except this. For example, nn.MultiheadedAttention, which is also part of the new release, works no problem. All the other new additions I’ve tested so far also work. CyclicLR seems to be the only issue that I’ve encountered. Very weird.</p>

ptrblck: <p>Did you forget to use “lr_scheduler” in your import?</p>
<pre><code class="lang-python">from torch.optim.lr_scheduler import CyclicLR
</code></pre>
<p>At least, the error message points to <code>torch.optim</code> instead of <code>torch.optim.lr_scheduler</code>.</p>

boris: <p>That’s exactly what I used, still not importing though. I even checked the installed torch package in torch/optim/lr_scheduler.py – CyclicLR is there so it should work. I wonder if anyone else is having this issue.</p>

ptrblck: <p>Could you print the PyTorch version using</p>
<pre><code class="lang-python">print(torch.__version__)
</code></pre>

boris: <p>Version 1.1.0, which is the latest.</p>

ptrblck: <p>I just installed this version and it’s working:</p>
<pre><code class="lang-python">&gt;&gt;&gt; import torch
&gt;&gt;&gt; torch.__version__
'1.1.0'
&gt;&gt;&gt; from torch.optim.lr_scheduler import CyclicLR
&gt;&gt;&gt; CyclicLR
&lt;class 'torch.optim.lr_scheduler.CyclicLR'&gt;
</code></pre>
<p>That’s really weird, but could you post some more information, e.g. which OS are you using?</p>

boris: <p>It’s a MacOS X 10.14.4. I reinstalled torch and even restarted and updated my machine. Still, the problem persists. Could be a problem specific to Macs.</p>

boris: <p>Updated my PyCharm editor and it fixed the problem. Don’t know what exactly the issue was but I’m glad it’s working now. Thank you for all the help.</p>

ptrblck: <p>Good to hear it’s working, but could you explain what went wrong?<br>
Is the PyCharm editor used to install packages?</p>

boris: <p>Yes, I do use it to install packages. So that could have been the issue. I didn’t update it in 6 months so I’m not surprised I started seeing problems. Whatever the bug was, it seems to be fixed.</p>
How to create a CNN layer with varying dilation filers?

MuserHao: <p>I want to create a CNN layer with filters of varying dilations.<br>
For example, in a conv2d layer there are filters with size 5<em>5 and also dilated filters with 3</em>3 with dilation=1?<br>
Or if I just concatenate the output feature maps from two conv2d layers, the gradient backprop will just be fine?</p>
<p>Thank you for any clarification.</p>

JuanFMontesinos: <p>Dilation is related to filter kernel, thus, you cannot set dilations-per-filter. However, you can concatenate and it will backprop properly</p>

MuserHao: <p>Thanks a lot! Appreciated!</p>
Equivalent of register forward hook for parameters?

whoab: <p>I have some custom parameters that I want to log the outputs for. How do I setup the forward hook akin to module.register_forward_hook?</p>

ptrblck: <p>If you are dealing with modules, you could use <a href="https://discuss.pytorch.org/t/how-can-l-load-my-best-model-as-a-feature-extractor-evaluator/17254/6?u=ptrblck">this code example</a>.<br>
I’m not sure what you mean by “custom parameters”, as parameters won’t have an output without any operation.</p>

whoab: <p><a class="mention" href="/u/ptrblck">@ptrblck</a> I mean, I have a parameter within a module and I want to see it’s forward activation separately from the module’s forward hook.</p>

ptrblck: <p>Could you wrap the operation involving this parameter in a custom module and register the forward hook?</p>
<p>I assume you are performing some operation using this parameter in your <code>forward</code> method.<br>
If so, you could also return/store the output of this operation.</p>
A possible bug in torch.nn.functional.conv1d/2d

liangbright: <p>Pytorch 1.1.0, windows</p>
<pre><code class="lang-python">import torch
import torch.nn as nn
import torch.nn.functional as nnF
x=torch.rand((16, 3, 28, 28))
a=nn.Conv2d(3,10,10,padding_mode='zeros')
y=nnF.conv2d(x, a.weight, padding_mode='zeros')
</code></pre>
<p>TypeError: conv2d() got an unexpected keyword argument ‘padding_mode’</p>

Tony-Y: <aside class="onebox githubblob">
  <header class="source">
      <a href="https://github.com/pytorch/pytorch/blob/142c973f4179e768164cd578951489e89021b29c/torch/nn/modules/conv.py#L330-L338" target="_blank" rel="nofollow noopener">github.com</a>
  </header>
  <article class="onebox-body">
    <h4><a href="https://github.com/pytorch/pytorch/blob/142c973f4179e768164cd578951489e89021b29c/torch/nn/modules/conv.py#L330-L338" target="_blank" rel="nofollow noopener">pytorch/pytorch/blob/142c973f4179e768164cd578951489e89021b29c/torch/nn/modules/conv.py#L330-L338</a></h4>
<pre class="onebox"><code class="lang-py"><ol class="start lines" start="330" style="counter-reset: li-counter 329 ;">
<li>def forward(self, input):</li>
<li>    if self.padding_mode == 'circular':</li>
<li>        expanded_padding = ((self.padding[1] + 1) // 2, self.padding[1] // 2,</li>
<li>                            (self.padding[0] + 1) // 2, self.padding[0] // 2)</li>
<li>        return F.conv2d(F.pad(input, expanded_padding, mode='circular'),</li>
<li>                        self.weight, self.bias, self.stride,</li>
<li>                        _pair(0), self.dilation, self.groups)</li>
<li>    return F.conv2d(input, self.weight, self.bias, self.stride,</li>
<li>                    self.padding, self.dilation, self.groups)</li>
</ol></code></pre>


  </article>
  <div class="onebox-metadata">
    
    
  </div>
  <div style="clear: both"></div>
</aside>

<p><code>F.conv2d</code> does not have the optional argument <code>padding_mode</code>.</p>
<p><a href="https://pytorch.org/docs/stable/nn.html#torch.nn.functional.conv2d" class="onebox" target="_blank" rel="nofollow noopener">https://pytorch.org/docs/stable/nn.html#torch.nn.functional.conv2d</a></p>
<p>This document for <code>F.conv2d</code> is wrong.</p>

ptrblck: <p>It looks like the circular padding is indeed applied before calling the functional conv API.<br>
Could you open an issue so that the docs can be fixed?</p>
Buck build for libtorch

yngtodd: <p>I have built <code>libtorch</code> from source using the <code>build_libtorch.py</code> found <a href="https://github.com/pytorch/pytorch/blob/master/tools/build_libtorch.py" rel="nofollow noopener">here.</a></p>
<p>I would like use torch in some C++ libraries and have been considering building them with the Buck build system. Would the developers advise against this? Buck seems appealing, but I wonder if I am barking up the wrong tree.</p>

Michael_Suo: <p>We use Buck internally within Facebook to build PyTorch, but not all the build rules are open-sourced. <code>build_variables.py</code> contains a sanitized subset of them that could be a good starting point.</p>

yngtodd: <p>Oh man, thank you. I didn’t take notice of <code>build_variables.py</code>. That looks great.</p>

jacob_1: <p>I’m also trying to build libtorch from source with a build system similar to buck (bazel). I just checked build_libtorch.py and build_variables.py, but still feel lost about how these scripts work. i can see there are a few custom rules in build_variables.py, but why these rules can be used directly in a bazel scripts?</p>
<p>also wondering if you can share your progress on this. Any sharing and suggestion would be really appreciated! Thanks!</p>

jacob_1: <p>can buck use build rules from bazel directly? i see “load(”<span class="mention">@bazel_skylib</span>//lib:new_sets.bzl", “sets”)" in tools/build_variables.py, which makes me a little bit confused.</p>

Michael_Suo: <p>You shouldn’t try to use <code>build_variables.py</code> directly; it’s intended to be used within Facebook’s internal environment. It can be a starting point for you to create your own Bazel rules, however.</p>

jacob_1: <p>Thanks for your answer.</p>
<p>Yeah, i can see there are some customized rules in build_variables.py, which are required if i want to use it, but i’m still wondering how is this scripts used by the internal environment. Since this is still a python script, how could the syntax like <code>load("@bazel_skylib//lib:new_sets.bzl", "sets")</code> work?</p>
Why there is no "min" property in torch.iinfo

liyugong: <p>There is iinfo.min in numpy. I’m wondering why iinfo.min is missing in pytorch. Is there a alternative to obtain it? Thanks!</p>

ezyang: <p>This would make a fine feature request. Post it to the issue tracker?</p>

liyugong: <p>The new version of PyTorch implemented it:<br>
<a href="https://pytorch.org/docs/stable/type_info.html?highlight=iinfo" class="onebox" target="_blank" rel="nofollow noopener">https://pytorch.org/docs/stable/type_info.html?highlight=iinfo</a></p>
Update tensor values based on the arange of each row from another tensor

Mei: <p>Given a 1D pytorch tensor, I want to update specific elements as following:</p>
<pre><code class="lang-auto">import torch 
x = torch.zeros(10) 
idx = torch.LongTensor([[0,1], [3,5], [6,8]]) 
for i in range(idx.shape[0]): 
    x[torch.arange(idx[i][0], idx[i][1])] = 1 
</code></pre>
<p>Expected output:</p>
<pre><code class="lang-auto">tensor([1., 0., 0., 1., 1., 0., 1., 1., 0, 0]
</code></pre>
<p>How can I vectorize this using pytorch? Many thanks in advance.</p>
How to make the newly added Tensorboard in PyTorch 1.1 update with new data when it is opened inside a docker container?

yxchng: <p>How to make the newly added Tensorboard in PyTorch 1.1 update with new data when it is opened inside a docker container?</p>
<p>Currently, it does not update even if I press the refresh button on the top right corner. The only way to see the updated log is to restart the tensorboard instance. How to make it update without restarting the instance?</p>
<p>There is no problem if it is not run inside docker.</p>

yxchng: <p>It seems like tensorflow is required in order for it to work in docker. I am not sure why. Anyone happens to know?</p>
Convert pandas df to 4 dimensions tensor

nolwen_brosson: <p>Hello,</p>
<p>I have a panda dataframe with several columns, and I would like to convert it in a tensor of 4 dimensions.</p>
<p>One of the pandas column is dates, and I want it to be one of the dimensions for example.</p>
<p>Sample of my data:</p>
<pre><code class="lang-auto">date        view  node   neigbor  link_value|

|20161104||   286|  1 10753|   1|
|20161104|   293|  1  10753|   1|
|20161104||  701|  1 . 10753|   1|
|20161104|| . 122|  1  10753|   1|
|20161105|| . 286|  1   10753|   1|
|20161105|| . 293|  1 10753|   1|
|20161105||  701|  1  10753|   1|
|20161105|| . 122|  1  10753|   1|
</code></pre>
<p>I would like the date and the view as dimensions, and then have a matrix with node as row, neighbor as column, and link weights as values in the matrix.</p>
<p>Thank you so much !!!</p>
How to include Atrous Spatial Pyramid Pooling to a Neural Net

Tsakunelson: <p>Hi All,<br>
Can someone explain or provide resources on how to incorporate Atrous Spatial Pyramid Pooling (ASPP) to a NeuralNet Model in Pytorch? My model is a modified version of the InceptionV3 model, and I would like to add an ASPP layer in there. Feedback much appreciated.</p>
How to keep the correspondence between 2 dataset when using shuffle in dataloader?

Shinered_Qiu: <p>Hello, I am using two datasets to train my model. Because the correspondence between the two datasets(same length), so when I use dataloader shuffle,  always need to keep the batches of two dataset s having same index.   Can you give me some ideas? <div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/2X/7/7f85a7a6095b7bda40e758ff30520790d578889c.png" data-download-href="https://discuss.pytorch.org/uploads/default/7f85a7a6095b7bda40e758ff30520790d578889c" title="1556697725(1)"><img src="https://discuss.pytorch.org/uploads/default/original/2X/7/7f85a7a6095b7bda40e758ff30520790d578889c.png" alt="1556697725(1)" data-base62-sha1="ic6Zz5VgSlJXZnYWHiptPznAQ2w" width="690" height="248" data-dominant-color="B9C6DB"><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">1556697725(1)</span><span class="informations">803×289 3.78 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>

Tony-Y: <p>You can create a custom dataset composed of two datasets.</p>
<p>First read the following tutorial if you don’t know.<br>
<a href="https://pytorch.org/tutorials/beginner/data_loading_tutorial.html#data-loading-and-processing-tutorial" class="onebox" target="_blank" rel="nofollow noopener">https://pytorch.org/tutorials/beginner/data_loading_tutorial.html#data-loading-and-processing-tutorial</a></p>
<p>For example:</p>
<pre><code class="lang-auto">class CustomDataset(Dataset):
    def __init__(self, dataset1, dataset2):
        self.dataset1 = dataset1
        self.dataset2 = dataset2

    def __len__(self):
        return len(self.dataset1)

    def __getitem__(self, idx):
        sample = {'data1': self.dataset1[idx], 'data2': self.dataset2[idx]}
        return sample
</code></pre>

Shinered_Qiu: <p>Thankyou so much. I will try it!</p>