Complete the code to convert a TensorFlow tensor to a NumPy array.
import tensorflow as tf tensor = tf.constant([1, 2, 3]) array = tensor.[1]()
Use the numpy() method to convert a TensorFlow tensor to a NumPy array.
Complete the code to create a TensorFlow tensor from a NumPy array.
import tensorflow as tf import numpy as np np_array = np.array([4, 5, 6]) tensor = tf.[1](np_array)
The tf.convert_to_tensor() function converts a NumPy array to a TensorFlow tensor.
Fix the error in the code to correctly convert a TensorFlow tensor to a NumPy array.
import tensorflow as tf tensor = tf.constant([7, 8, 9]) array = tensor.[1]
The numpy() method must be called with parentheses to convert the tensor to a NumPy array.
Fill both blanks to create a TensorFlow tensor from a NumPy array and then convert it back to a NumPy array.
import tensorflow as tf import numpy as np np_array = np.array([10, 11, 12]) tensor = tf.[1](np_array) back_to_np = tensor.[2]()
Use tf.convert_to_tensor() to create a tensor from a NumPy array, then numpy() to convert it back.
Fill all three blanks to create a NumPy array, convert it to a TensorFlow tensor, and then get its shape.
import tensorflow as tf import numpy as np np_array = np.array([[1], [2], [3]]) tensor = tf.convert_to_tensor(np_array) shape = tensor.shape
The NumPy array is created with elements 1, 2, and 3, then converted to a tensor. The shape will be (3,).