2017-08-14 77 views
1

如何使用TensorFlow進行隨機伽馬校正?如何用張量流進行隨機伽馬校正?

我試圖做到這一點:

a, b = tf.unstack(tf.random_uniform([2], dtype=tf.float32)) 
r = tf.image.adjust_gamma(image, gamma=a, gain=b) 

但我得到這個錯誤的結果:

File "/venv/local/lib/python3.5/site-packages/tensorflow/python/ops/image_ops_impl.py", line 999, in adjust_gamma 
    if gamma < 0: 
File "/venv/local/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 564, in __bool__ 
raise TypeError("Using a `tf.Tensor` as a Python `bool` is not allowed. " 
TypeError: Using a `tf.Tensor` as a Python `bool` is not allowed. Use `if t is not None:` instead of `if t:` to test if a tensor is defined, and use TensorFlow ops such as tf.cond to execute subgraphs conditioned on the value of a tensor. 

回答

0

這裏gammagaintensor,但普通的Python標

gamma = np.random.uniform(low=0, high=3, size=[1,]) 
gain = np.random.uniform(low=0, high=1, size=[1,]) 
r = tf.image.adjust_gamma(image, gamma=gamma[0], gain=gain[0])