# Demo entry 6718255

**task1**

Submitted by **anonymous**
on Mar 03, 2018 at 06:55

Language: Python 3. Code size: 577 Bytes.

#use numpy to build a numpy array which include from 1 to 60 x_init = np.arange(1,61,1) #use np.reshape() to make the 1D array become 4x3x5 3D numpy array x = np.array(x_init).reshape(4,3,5) #covert the numpy array to tensor by using tf.convert_to_tensor() tensor_x = tf.convert_to_tensor(x,preferred_dtype=tf.float32) #use tf.reshape() to reshape Previous tensor to 10x6 tensor X = tf.reshape(tensor_x, ([10,6])) #define sess to run sess = tf.InteractiveSession() #print out the result(there are two ways to print out x print(sess.run(X)) print(X.eval())

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.