WangJY06 / RDGAN

ICME 2019 paper "RDGAN: Retinex Decomposition based Adversarial Learning for Low-Light Enhancement"
31 stars 10 forks source link

TypeError: Expected float for argument 'alpha' not <tf.Tensor 'retinex/l1/cv1/pr/constraining_alpha_var_in_0_1:0' shape=(32,) dtype=float32>. #1

Open RichealYoung opened 5 years ago

RichealYoung commented 5 years ago

I ran the test.py and encountered the following error Error

WARNING:tensorflow:From /data/lld/RDGAN/model.py:150: max_pooling2d (from tensorflow.python.layers.pooling) is deprecated and will be removed in a future version.
Instructions for updating:
Use keras.layers.max_pooling2d instead.
WARNING:tensorflow:From /home/lld/.conda/envs/enh/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py:263: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.
Instructions for updating:
Colocations handled automatically by placer.
Traceback (most recent call last):
  File "/data/lld/RDGAN/test.py", line 76, in <module>
    main()
  File "/data/lld/RDGAN/test.py", line 24, in main
    img_i, img_r = rdnet(img_v, img, hei, wid)
  File "/data/lld/RDGAN/model.py", line 46, in rdnet
    n11 = conv_k3(n, 32, name='l1/cv1')
  File "/data/lld/RDGAN/model.py", line 108, in conv_k3
    n = PReluLayer(n, a_init=a_init, name=name+'/pr')
  File "/home/lld/.conda/envs/enh/lib/python3.6/site-packages/tensorlayer/decorators/deprecated_alias.py", line 24, in wrapper
    return f(*args, **kwargs)
  File "/home/lld/.conda/envs/enh/lib/python3.6/site-packages/tensorlayer/layers/activation.py", line 74, in __init__
    'name': "PReLU_activation"
  File "/home/lld/.conda/envs/enh/lib/python3.6/site-packages/tensorlayer/decorators/method_decorator.py", line 16, in func_wrapper
    return func(*args, **kwargs)
  File "/home/lld/.conda/envs/enh/lib/python3.6/site-packages/tensorlayer/layers/core.py", line 329, in _apply_activation
    return self.act(logits, **kwargs) if self.act is not None else logits
  File "/home/lld/.conda/envs/enh/lib/python3.6/site-packages/tensorflow/python/ops/nn_ops.py", line 2086, in leaky_relu
    return gen_nn_ops.leaky_relu(features, alpha=alpha, name=name)
  File "/home/lld/.conda/envs/enh/lib/python3.6/site-packages/tensorflow/python/ops/gen_nn_ops.py", line 4908, in leaky_relu
    alpha = _execute.make_float(alpha, "alpha")
  File "/home/lld/.conda/envs/enh/lib/python3.6/site-packages/tensorflow/python/eager/execute.py", line 96, in make_float
    (arg_name, repr(v)))
TypeError: Expected float for argument 'alpha' not <tf.Tensor 'retinex/l1/cv1/pr/constraining_alpha_var_in_0_1:0' shape=(32,) dtype=float32>.

python 3.6 tensorflow-gpu 1.13.1 tensorlayer 1.10.1

WangJY06 commented 5 years ago

Thanks for opening the first issue on our work! The parameter 'alpha' in PReluLayer should be a trainable tensor instead of float type,and the testing codes work well on our PC with tensorflow-gpu 1.10.0 and tensorlayer 1.11.1 Agree with @smarteric that the error is caused by the mismatching version of tensorlayer.

smarteric commented 4 years ago

If you use tensorflow-gpu>=1.13 and tensorlayer 1.11.1, it will encounter this problem. Due to the mismatching version of tensorlayer. The easiest way to solve it is to write a PReluLayer function by yourself. Or just revise the activation.py in tensorlayer under your env. Using self.outputs = tf.maximum(alpha_var_constrained * self.inputs, self.inputs) instead of tf.nn.leaky_relu. Hope it helps