January 2018
Intermediate to advanced
474 pages
10h 23m
English
We can create tensors from Python objects such as lists and NumPy arrays, using the tf.convert_to_tensor() operation with the following signature:
tf.convert_to_tensor( value, dtype=None, name=None, preferred_dtype=None )
Let's create some tensors and print them for practice:
tf_t=tf.convert_to_tensor(5.0,dtype=tf.float64)print('tf_t : ',tf_t)print('run(tf_t) : ',tfs.run(tf_t))
The output is as follows:
tf_t : Tensor("Const_1:0", shape=(), dtype=float64)run(tf_t) : 5.0
a1dim = np.array([1,2,3,4,5.99])print("a1dim Shape : ",a1dim.shape)tf_t=tf.convert_to_tensor(a1dim,dtype=tf.float64)print('tf_t : ',tf_t)print('tf_t[0] : ',tf_t[0])print('tf_t[0] ...Read now
Unlock full access