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

Hi,
I have got this error

Traceback (most recent call last):
File “train.py”, line 15, in
model = CreateModel(opt)
File “model/model_Loader.py”, line 15, in CreateModel
model.init_weights()
File “model/DRGAN.py”, line 204, in init_weights
self.G.apply(weights_init_normal)
File “/home/pirl/anaconda3/envs/dr-gan-torch1-2/lib/python3.6/site-packages/torch/nn/modules/module.py”, line 293, in apply
module.apply(fn)
File “/home/pirl/anaconda3/envs/dr-gan-torch1-2/lib/python3.6/site-packages/torch/nn/modules/module.py”, line 293, in apply
module.apply(fn)
File “/home/pirl/anaconda3/envs/dr-gan-torch1-2/lib/python3.6/site-packages/torch/nn/modules/module.py”, line 293, in apply
module.apply(fn)
[Previous line repeated 2 more times]
File “/home/pirl/anaconda3/envs/dr-gan-torch1-2/lib/python3.6/site-packages/torch/nn/modules/module.py”, line 294, in apply
fn(self)
File “model/Component.py”, line 49, in weights_init_normal
init.uniform_(m.weight.data, 1.0, 0.02)
File “/home/pirl/anaconda3/envs/dr-gan-torch1-2/lib/python3.6/site-packages/torch/nn/init.py”, line 88, in uniform_
return no_grad_uniform(tensor, a, b)
File “/home/pirl/anaconda3/envs/dr-gan-torch1-2/lib/python3.6/site-packages/torch/nn/init.py”, line 14, in no_grad_uniform
return tensor.uniform_(a, b)
RuntimeError: Expected a_in <= b_in to be true, but got false. (Could this error message be improved? If so, please report an enhancement request to PyTorch.)

File “train.py”, line 15, in is

model = CreateModel(opt)

File “model/model_Loader.py”, line 15, in CreateModel is

model.init_weights()

File “model/DRGAN.py”, line 204, in init_weights is

203 def init_weights(self):
204 self.G.apply(weights_init_normal)
205 self.D.apply(weights_init_normal)

I got this pytorch code from


and try to run it.

According to github-site, the required pytorch version is 0.2, however my torch version is 1.2, the latest version.
I want to run in the current version without changing the version.

Any help will be greatly appreciated!!!

I’m having trouble understanding the logic in the original code. In both version 0.2 and 1.2 of PyTorch, calling .uniform_(a, b) on a tensor requires a <= b, as the error states, and the call uses a = 1.0 and b = 0.02.

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 here for the torchvision provided ResNet model.

1 Like

Sorry for late comment :frowning:
Thx for your advice, I finally solve the problem.

I change the value of a & b like

init.uniform_(m.weight.data, 1.0, 0.02)
to
init.uniform_(m.weight.data, 0.02, 1.0)

After that, I install the torchvision using in different way

conda install torchvision -c pytorch
instead of
pip install torchvision

and I work :slight_smile:
I really appreciate your help!!!

2 Likes