y_d = tf.matmul(activation_d, W_out_d) + b_out_d
Now if we want to apply sigmoid function to the first three columns of y_d while taking absolute value of the fourth column, what should we do?
Since 'Tensor' object does not support item assignment, we need to use tf.slice to slice the tensor first so that we can manipulate each slice separately and use tf.concat to join them back together.
The code for the above purpose is as follows:
y_d1=tf.slice(y_d, [0,0],[-1,3]) #-1 tells TensorFlow all the rows are needed; 3 is the column number (size).
y_d1=tf.nn.sigmoid(y_d1)
y_d2=tf.slice(y_d, [0,3],[-1,1])
y_d2=tf.abs(y_d2)
y_d=tf.concat([y_d1, y_d2], 1)
tf.slice:
https://www.tensorflow.org/api_docs/python/tf/slice
tf.concat:
https://www.tensorflow.org/api_docs/python/tf/concat