2017-08-14 12 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]) 
関連する問題