Data Types
123456789101112import tensorflow as tf # Creating a tensor of type `float16` tensor_float = tf.constant([1.2, 2.3, 3.4], dtype=tf.float16) # Creating a tensor of type `int64` tensor_int = tf.constant([1, 2, 3], dtype=tf.int64) # Display tensors print(tensor_float) print('-' * 50) print(tensor_int)
123456789101112import tensorflow as tf # Create a tensor tensor_float = tf.constant([-1.2, 2.3, 3.8]) # Convert our `tensor_float` from `float32` to `int32` tensor_int_converted = tf.cast(tensor_float, dtype=tf.int32) # Display a tensor print(tensor_float) print('-' * 50) print(tensor_int_converted)
Opgave
Swipe to start coding
Løsning
Var alt klart?
Tak for dine kommentarer!
Sektion 1. Kapitel 7
single
Spørg AI
Spørg AI
Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat
Suggested prompts:
Opsummér dette kapitel
Explain code
Explain why doesn't solve task
Awesome!
Completion rate improved to 5.56
Data Types
Stryg for at vise menuen
123456789101112import tensorflow as tf # Creating a tensor of type `float16` tensor_float = tf.constant([1.2, 2.3, 3.4], dtype=tf.float16) # Creating a tensor of type `int64` tensor_int = tf.constant([1, 2, 3], dtype=tf.int64) # Display tensors print(tensor_float) print('-' * 50) print(tensor_int)
123456789101112import tensorflow as tf # Create a tensor tensor_float = tf.constant([-1.2, 2.3, 3.8]) # Convert our `tensor_float` from `float32` to `int32` tensor_int_converted = tf.cast(tensor_float, dtype=tf.int32) # Display a tensor print(tensor_float) print('-' * 50) print(tensor_int_converted)
Opgave
Swipe to start coding
Løsning
Var alt klart?
Tak for dine kommentarer!
Awesome!
Completion rate improved to 5.56Sektion 1. Kapitel 7
single