TensorFlow and Keras Basics
TensorFlow और Keras Basics
What are TensorFlow and Keras Basics?
TensorFlow and Keras Basics means tensorFlow and Keras are used to build, train and evaluate deep learning models.
In real programs, this topic helps in building neural networks. Learn the idea first, then type the program yourself and compare the output.
| Point | Details |
|---|---|
| Course Area | Machine Learning + AI Concepts used for prediction, classification, clustering and AI-based projects. |
| Main Use | building neural networks |
| Example File | tensorflow-keras-basics.py |
| Practice Focus | Run, change values, and explain the output line by line. |
Why should you learn this?
- It is useful for building neural networks.
- It connects with training deep learning models.
- It improves your ability to read, write and debug Python programs.
Important Terms
These terms are used directly in this lesson. Understand them before memorising the code.
| Term | Meaning |
|---|---|
| tensor | tensor is an important term in this topic. |
| Keras | High-level API used to build neural networks easily. |
| Sequential | Sequential is an important term in this topic. |
| Dense layer | Dense layer is an important term in this topic. |
| training | Process where a model learns from data. |
Syntax / Basic Pattern
The simple pattern is: prepare data, apply the concept, then show the result.
import tensorflow as tf
model = tf.keras.Sequential([
tf.keras.layers.Dense(8, activation="relu", input_shape=(2,)),
tf.keras.layers.Dense(1, activation="sigmoid")
])
model.compile(optimizer="adam", loss="binary_crossentropy", metrics=["accuracy"])
model.summary()Complete Example Program
import tensorflow as tf
model = tf.keras.Sequential([
tf.keras.layers.Dense(8, activation="relu", input_shape=(2,)),
tf.keras.layers.Dense(1, activation="sigmoid")
])
model.compile(optimizer="adam", loss="binary_crossentropy", metrics=["accuracy"])
model.summary()Expected Output
Program Explanation
import tensorflow as tfimports ready-made features from a module/library.model = tf.keras.Sequential([stores a value in model.tf.keras.layers.Dense(8, activation="relu", input_shape=(2,)),stores a value in tf.keras.layers.Dense(8, activation.tf.keras.layers.Dense(1, activation="sigmoid")stores a value in tf.keras.layers.Dense(1, activation.])performs the next step of the program logic.model.compile(optimizer="adam", loss="binary_crossentropy", metrics=["accuracy"]stores a value in model.compile(optimizer.model.summary()performs the next step of the program logic.
Where will you use it?
- Building neural networks.
- Training deep learning models.
- Using keras layers.
Common Mistakes
- Training and testing the model on the same data.
- Using an algorithm without understanding the input features.
- Reporting only accuracy without checking actual mistakes and limitations.
Practice Tasks
- Type the program in
tensorflow-keras-basics.pyand run it. - Change input values or sample data and observe the new output.
- Create one example related to building neural networks.
- Write 5 lines explaining the logic in your own words.
Summary
TensorFlow and Keras Basics is not a theory-only topic. You should be able to explain the meaning, write the example, run it successfully, and use it in a small practical program.
TensorFlow और Keras Basics क्या है?
TensorFlow और Keras Basics ka matlab hai: TensorFlow and Keras are used to build, train and evaluate deep learning models. Simple words me, ye topic practical Python programs likhne me direct use hota hai.
Is topic ko sirf definition ke liye nahi, balki building neural networks jaise real examples ke liye practice karein.
यह क्यों सीखना जरूरी है?
- Ye building neural networks me kaam aata hai.
- Ye training deep learning models se bhi connected hai.
- Isse aap code ka output aur errors better samajh paate hain.
Important Terms
| Term | Meaning |
|---|---|
| tensor | tensor is an important term in this topic. |
| Keras | High-level API used to build neural networks easily. |
| Sequential | Sequential is an important term in this topic. |
| Dense layer | Dense layer is an important term in this topic. |
| training | Process where a model learns from data. |
Syntax / Basic Pattern
Basic idea: pehle data तैयार करें, phir Python logic apply करें, aur finally result display करें.
import tensorflow as tf
model = tf.keras.Sequential([
tf.keras.layers.Dense(8, activation="relu", input_shape=(2,)),
tf.keras.layers.Dense(1, activation="sigmoid")
])
model.compile(optimizer="adam", loss="binary_crossentropy", metrics=["accuracy"])
model.summary()Complete Example Program
import tensorflow as tf
model = tf.keras.Sequential([
tf.keras.layers.Dense(8, activation="relu", input_shape=(2,)),
tf.keras.layers.Dense(1, activation="sigmoid")
])
model.compile(optimizer="adam", loss="binary_crossentropy", metrics=["accuracy"])
model.summary()Expected Output
Program Explanation
import tensorflow as tfimports ready-made features from a module/library.model = tf.keras.Sequential([stores a value in model.tf.keras.layers.Dense(8, activation="relu", input_shape=(2,)),stores a value in tf.keras.layers.Dense(8, activation.tf.keras.layers.Dense(1, activation="sigmoid")stores a value in tf.keras.layers.Dense(1, activation.])performs the next step of the program logic.model.compile(optimizer="adam", loss="binary_crossentropy", metrics=["accuracy"]stores a value in model.compile(optimizer.model.summary()performs the next step of the program logic.
Practical Uses
- Building neural networks.
- Training deep learning models.
- Using keras layers.
Common Mistakes
- Training and testing the model on the same data.
- Using an algorithm without understanding the input features.
- Reporting only accuracy without checking actual mistakes and limitations.
Practice Tasks
- Program ko
tensorflow-keras-basics.pyfile me type karke run karein. - Values change karke output compare karein.
- building neural networks par ek छोटा example banayen.
- Logic ko apne words me 5 lines me likhein.
सारांश
TensorFlow and Keras Basics ko tab complete maanenge jab aap iska meaning, example, output aur practical use clearly explain kar saken.