Recall & Review
beginner
What is type casting in TensorFlow?
Type casting in TensorFlow means changing the data type of a tensor from one type to another, like from float32 to int32.
Click to reveal answer
beginner
Why do we need type casting in machine learning models?
We need type casting to make sure data matches the expected type for operations or models, which helps avoid errors and improves performance.
Click to reveal answer
beginner
How do you cast a tensor to a different type in TensorFlow?
Use the function tf.cast(tensor, dtype) where 'tensor' is your data and 'dtype' is the new data type you want.
Click to reveal answer
intermediate
What happens if you cast a float tensor to an integer tensor in TensorFlow?
The decimal part is dropped (not rounded), so 3.7 becomes 3 when cast to an integer type.
Click to reveal answer
beginner
Which TensorFlow data types are commonly used for type casting?
Common types include tf.float32, tf.float64, tf.int32, tf.int64, and tf.bool.
Click to reveal answer
Which TensorFlow function is used to change a tensor's data type?
✗ Incorrect
tf.cast is the correct function to convert a tensor to a different data type.
What happens when you cast a float tensor with value 4.9 to int32 in TensorFlow?
✗ Incorrect
Casting to int32 drops the decimal part, so 4.9 becomes 4.
Which data type is NOT a valid TensorFlow dtype for casting?
✗ Incorrect
tf.string is not supported by tf.cast for numeric conversions.
Why is type casting important before feeding data into a TensorFlow model?
✗ Incorrect
Models expect inputs of certain types; casting ensures data matches those types.
What is the result of casting a boolean tensor [True, False] to int32 in TensorFlow?
✗ Incorrect
Casting booleans to int32 converts True to 1 and False to 0.
Explain how and why you would use type casting in TensorFlow when preparing data for a model.
Think about data types and model requirements.
You got /4 concepts.
Describe what happens internally when casting a float tensor to an integer tensor in TensorFlow.
Focus on how numbers change during casting.
You got /4 concepts.