<h1 dir="auto">code</h1>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="a = autograd.Variable(torch.ones(1000))
b = autograd.Variable(torch.ones(1000))
print(a.data.eq(b.data).sum()) # 1000
print(a.eq(b).sum().data[0]) # 232"><pre class="notranslate"><span class="pl-s1">a</span> <span class="pl-c1">=</span> <span class="pl-s1">autograd</span>.<span class="pl-v">Variable</span>(<span class="pl-s1">torch</span>.<span class="pl-en">ones</span>(<span class="pl-c1">1000</span>))
<span class="pl-s1">b</span> <span class="pl-c1">=</span> <span class="pl-s1">autograd</span>.<span class="pl-v">Variable</span>(<span class="pl-s1">torch</span>.<span class="pl-en">ones</span>(<span class="pl-c1">1000</span>))
<span class="pl-en">print</span>(<span class="pl-s1">a</span>.<span class="pl-s1">data</span>.<span class="pl-en">eq</span>(<span class="pl-s1">b</span>.<span class="pl-s1">data</span>).<span class="pl-en">sum</span>()) <span class="pl-c"># 1000</span>
<span class="pl-en">print</span>(<span class="pl-s1">a</span>.<span class="pl-en">eq</span>(<span class="pl-s1">b</span>).<span class="pl-en">sum</span>().<span class="pl-s1">data</span>[<span class="pl-c1">0</span>]) <span class="pl-c"># 232</span></pre></div>
<h1 dir="auto">environment</h1>
<ul dir="auto">
<li>ubuntu 16.04</li>
<li>python3</li>
<li>pytorch 0.2.0_4</li>
</ul>
<p dir="auto">When summing a <code class="notranslate">ByteTensor</code> wrapped in a <code class="notranslate">Variable</code> the answer is incorrect. The answer can be very off in some cases. See the below gist for reproducing.</p>
<p dir="auto"><a href="https://gist.github.com/awni/675bedbda43e7aa3ad06dfd7f5ce7205">https://gist.github.com/awni/675bedbda43e7aa3ad06dfd7f5ce7205</a></p>