Vectors

The Norm function is used to get the size of the vector; the norm of a vector x measures the distance from the origin to the point x. It is also known as the norm, where p=2 is known as the Euclidean norm.

The following example shows you how to calculate the norm of a given vector:

import tensorflow as tfvector = tf.constant([[4,5,6]], dtype=tf.float32)eucNorm = tf.norm(vector, ord="euclidean")with tf.Session() as sess:print(sess.run(eucNorm))

The output of the listing is 8.77496.

Get Neural Network Programming with TensorFlow now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.