Your First TensorFlow Code
Creating and Using Tensors
Basic TensorFlow objects
TensorFlow lets you create constant values and variables. A constant does not change, while a variable can be updated during training. You can add, multiply, and reshape tensors just like mathematical objects.
Example workflow
You might create a tensor with values like , apply an operation such as addition, and inspect the result. This is the foundation for everything from data processing to model training.
First TensorFlow practice
-
1
Import TensorFlow as
tf. -
2
Create a tensor or constant.
-
3
Apply a simple math operation.
-
4
Print the result and inspect its shape.
Mental Model
Think of TensorFlow as a tool for doing math on structured data, not just for training deep learning models.
What is the difference between a constant and a variable?
Variables are used when values need to be learned or changed.
Correct answer: A variable can be updated, a constant usually does not change
What is one reason to inspect tensor shape?
Shape mismatches are a common beginner error.
Correct answer: To make sure the data has the structure the model expects.
What kind of work can TensorFlow perform on tensors?
TensorFlow is built for numeric computation on tensors.
Correct answer: Math operations such as addition and multiplication