I have to convert tensorflow scalars into 1-dimensional tensors with 1 element. I wonder what is the best way to do this?
You can use tf.reshape
For example:
import tensorflow as tf
x = tf.constant(2)
x_1d = tf.reshape(x, [1])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.