Expected a_in <= b_in to be true, but got false

20am847: <p>Hi,<br>
I have got this error</p>
<blockquote>
<p>Traceback (most recent call last):<br>
File “train.py”, line 15, in <br>
model = CreateModel(opt)<br>
File “model/model_Loader.py”, line 15, in CreateModel<br>
model.init_weights()<br>
File “model/DRGAN.py”, line 204, in init_weights<br>
self.G.apply(weights_init_normal)<br>
File “/home/pirl/anaconda3/envs/dr-gan-torch1-2/lib/python3.6/site-packages/torch/nn/modules/module.py”, line 293, in apply<br>
module.apply(fn)<br>
File “/home/pirl/anaconda3/envs/dr-gan-torch1-2/lib/python3.6/site-packages/torch/nn/modules/module.py”, line 293, in apply<br>
module.apply(fn)<br>
File “/home/pirl/anaconda3/envs/dr-gan-torch1-2/lib/python3.6/site-packages/torch/nn/modules/module.py”, line 293, in apply<br>
module.apply(fn)<br>
[Previous line repeated 2 more times]<br>
File “/home/pirl/anaconda3/envs/dr-gan-torch1-2/lib/python3.6/site-packages/torch/nn/modules/module.py”, line 294, in apply<br>
fn(self)<br>
File “model/Component.py”, line 49, in weights_init_normal<br>
init.uniform_(m.weight.data, 1.0, 0.02)<br>
File “/home/pirl/anaconda3/envs/dr-gan-torch1-2/lib/python3.6/site-packages/torch/nn/init.py”, line 88, in uniform_<br>
return <em>no_grad_uniform</em>(tensor, a, b)<br>
File “/home/pirl/anaconda3/envs/dr-gan-torch1-2/lib/python3.6/site-packages/torch/nn/init.py”, line 14, in <em>no_grad_uniform</em><br>
return tensor.uniform_(a, b)<br>
RuntimeError: Expected a_in &lt;= b_in to be true, but got false.  (Could this error message be improved?  If so, please report an enhancement request to PyTorch.)</p>
</blockquote>
<p>File “train.py”, line 15, in  is</p>
<blockquote>
<p>model = CreateModel(opt)</p>
</blockquote>
<p>File “model/model_Loader.py”, line 15, in CreateModel is</p>
<blockquote>
<p>model.init_weights()</p>
</blockquote>
<p>File “model/DRGAN.py”, line 204, in init_weights is</p>
<blockquote>
<p>203    def init_weights(self):<br>
204        self.G.apply(weights_init_normal)<br>
205        self.D.apply(weights_init_normal)</p>
</blockquote>
<p>I got this pytorch code from</p><aside class="onebox allowlistedgeneric" data-onebox-src="https://github.com/zhangjunh/DR-GAN-by-pytorch">
  <header class="source">
      <img src="https://github.githubassets.com/favicons/favicon.svg" class="site-icon" width="32" height="32">

      <a href="https://github.com/zhangjunh/DR-GAN-by-pytorch" target="_blank" rel="noopener nofollow ugc">GitHub</a>
  </header>

  <article class="onebox-body">
    <div class="aspect-image" style="--aspect-ratio:690/344;"><img src="https://opengraph.githubassets.com/414ffef5be8544adee6501713ca1700c9a31ee8af066282f4d5bb8fdbf6273f8/zhangjunh/DR-GAN-by-pytorch" class="thumbnail" width="690" height="345"></div>

<h3><a href="https://github.com/zhangjunh/DR-GAN-by-pytorch" target="_blank" rel="noopener nofollow ugc">GitHub - zhangjunh/DR-GAN-by-pytorch: An implement of Disentangled...</a></h3>

  <p>An implement of Disentangled Representation Learning GAN for Pose-Invariant Face Recognition - GitHub - zhangjunh/DR-GAN-by-pytorch: An implement of Disentangled Representation Learning GAN for Pos...</p>


  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>
<p>
and try to run it.</p>
<p>According to github-site, the required pytorch version is 0.2, however my torch version is 1.2, the latest version.<br>
I want to run in the current version without changing the version.</p>
<p>Any help will be greatly appreciated!!!</p>

alex.veuthey: <p>I’m having trouble understanding the logic in the original code. In both version <a href="https://pytorch.org/docs/0.2.0/tensors.html#torch.Tensor.uniform_" rel="nofollow noopener">0.2</a> and <a href="https://pytorch.org/docs/stable/tensors.html#torch.Tensor.uniform_" rel="nofollow noopener">1.2</a> of PyTorch, calling <code>.uniform_(a, b)</code> on a tensor requires <code>a &lt;= b</code>, as the error states, and the call uses <code>a = 1.0</code> and <code>b = 0.02</code>.</p>
<p>This might be a mistake in the original code, but I’m not familiar with GAN initialization standards / approaches for batch norm layers. Have a look <a href="https://discuss.pytorch.org/t/initialization-and-batch-normalization/30655/2">here</a> for the torchvision provided ResNet model.</p>

20am847: <p>Sorry for late comment <img src="https://discuss.pytorch.org/images/emoji/apple/frowning.png?v=12" title=":frowning:" class="emoji" alt=":frowning:" loading="lazy" width="20" height="20"><br>
Thx for your advice, I finally solve the problem.</p>
<p>I change the value of a &amp; b like</p>
<blockquote>
<p>init.uniform_(m.weight.data, 1.0, 0.02)<br>
to<br>
init.uniform_(m.weight.data, 0.02, 1.0)</p>
</blockquote>
<p>After that, I install the torchvision using in different way</p>
<blockquote>
<p>conda install torchvision -c pytorch<br>
instead of<br>
pip install torchvision</p>
</blockquote>
<p>and I work <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=12" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"><br>
I really appreciate your help!!!</p>