Reputation: 2643
I am using Tensorflow and I want to apply the condition below to my tensor
:
if(value > 0):
value = log(value)
else:
value = -log(-value)
Currently, I am doing the following.
minone = tf.constant(-1, dtype=tf.float32)
condition = tf.less(X, minone)
idx = tf.where(condition)
portion = tf.gather_nd(X, idx)
log = -tf.log(-portion)
X = tf.scatter_nd_update(X, idx, log)
However, this only works when X
is of type tf.Variable
and not of a normal Tensor
type.
How would I achieve a working condition for a variable of Tensor
type?
Upvotes: 0
Views: 373