Create tensor of a sequence with a defined shape using TensorFlow
Create a tensor Y of shape (2,3) having a sequence of numbers 12,15,18,...., 150
I tried using the below code
tf.constant(np.arange(12,153,3),dtype=tf.dtypes.float32,shape=[2,3])
I got an error saying the tensor with 47 elements cannot be converted into 6 elements.
I added the following third dimension in shape and it worked.
tf.constant(np.arange(12,153,3),dtype=tf.dtypes.float32,shape=[8,2,3])
How to proceed as the given question wants the sequence tensor to be in shape [2,3]?
Please help.
Topic tensorflow machine-learning
Category Data Science