TensorFlow Explained in Hindi: Neural Networks, Loss Functions & More in Hindi
TensorFlow ?????? ??????????????????????????? ?????? ?????????-??????????????? Python ??????????????????????????? ??????, ?????? Artificial Intelligence (AI) ?????? Machine Learning (ML) ????????? ????????? ????????????????????? ?????????????????? ?????? ??????????????? ?????? ??????????????? ???????????? ?????? ????????? ?????????????????? ????????? ?????? ??????????????? ?????? ???????????? ?????????
Google ?????????????????? ??????????????? ?????? ?????? ?????? ??????????????????????????? ?????????????????? ???????????????????????????, ??????????????? ????????????????????????, ?????? ??????????????????????????????????????? ??????????????? ?????????????????? ???????????? ??????, ?????? ????????? ????????????????????? ????????????????????????????????? ?????? ????????? ?????????????????? ???????????? ?????? ??????????????? ?????????, ?????? ?????????????????????????????? ?????? ??????????????? ?????? ?????????????????????????????? ????????????????????????????????? ?????? ??????????????? ??????????????????????????? ??????????????????, ???????????? ???????????????, ?????????????????? ???????????????????????????, ???????????? ????????????????????????, ?????? ????????? ???????????????????????????
?????? ??????????????? ?????? ???????????????????????? ???????????????????????? ?????? ?????????????????????????????? ????????????????????? ?????? ?????????????????????????????? ?????? ?????????????????? ????????????????????????????????? ?????????????????? ??????, ?????? AI/ML ????????? ????????? ????????????????????? ?????? ???????????? ???????????? ????????????
?????? ?????? ??????????????????????????? ?????? ????????? ????????????????????????????????????, AI/ML ????????? ???????????? ???????????? ?????????, ?????? ?????????????????????????????? ??????????????? ?????? ????????? ????????? ?????????????????????
?????????????????????????????? ???????????? ??????? ??? What is TensorFlow in Hindi?
?????????????????????????????? ?????? ?????????-??????????????? ??????????????????????????? ??????, ???????????? Google ?????? 2015 ????????? ?????????????????? ???????????? ????????? ???????????? ????????? "Tensor" (???????????????) ?????? ????????? ??????, ?????? ????????? ????????????????????? ????????? ???????????? ?????? ?????????????????????????????? ???????????? ?????? ??????????????? ??????????????? ????????? ?????????????????????????????? ????????? ????????????????????? ?????????????????? ???????????? ?????????????????? ???????????????????????????, CNNs (Convolutional Neural Networks), ?????? RNNs (Recurrent Neural Networks) ?????? ??????????????? ?????? ??????????????? ???????????? ?????? ????????? ????????????????????? ???????????? ????????? ????????? ?????? NumPy, Pandas, ?????? Matplotlib ?????? ????????? ??????????????? ?????? ??????????????????????????? ???????????? ?????????
TensorFlow ?????? ?????????????????? ??????????????????:
-
Tensor Operations: ???????????????-??????????????????????????? ???????????? (???????????????) ?????? ???????????? ????????????????????????????????????
-
Neural Networks: ????????? ????????????????????? ?????????????????? ?????? ??????????????? ?????? ??????????????? ?????? ??????????????? ???????????????
-
Optimization: ??????????????????????????? ?????????????????? ?????? ???????????? ??????????????????????????????????????????
-
Scalability: CPU, GPU, ?????? TPU ?????????????????? ?????? ????????? ???????????? ??????????????????????????? ?????? ????????? ???????????? ?????? ?????????????????????
AI/ML ????????? ???????????? ?????????: ?????????????????????????????? ?????? ??????????????? ???????????? ????????????????????????????????????, ?????????????????? ???????????????????????? ?????????????????????????????? (NLP), ?????? ???????????? ?????????????????? ?????????????????????????????? ???????????? ????????? ????????????????????? ????????????????????? ????????? ???????????? ?????????
?????????????????????????????? ??????????????? ??? TensorFlow Setup in Hindi
?????????????????????????????? ?????? ????????? AI/ML ????????? ????????? ????????????????????? ???????????? ???????????? ?????? ????????? ???????????? ???????????? ????????? ????????????????????? ???????????? ?????????????????? ?????????
1. ?????????????????????????????? ?????????????????????????????? ???
TensorFlow
Installation
-
Command: ????????????????????? ?????? ??????????????? ??????????????????????????? ????????? ?????????????????????????????? ??????????????? ?????? ????????????:
pip install tensorflow
-
Verification: Python ????????? ?????????????????????????????? ????????????????????? ???????????? ????????? ????????????:
import tensorflow as tf
print("TensorFlow Version:", tf.__version__)
Output:
TensorFlow Version: 2.15.0
2. ????????????????????????????????? ??????????????? ??? Environment Setup
-
Jupyter Notebook: ?????????????????????????????? ?????? ????????? ???????????? ???????????????????????? ?????? ?????????????????????????????????????????? ?????? ????????? ??????????????????
-
Anaconda: TensorFlow ?????? ????????? ?????? ????????????????????? ???????????? ????????? ???????????? ?????????
-
VS Code: ?????????????????????????????? ????????? ??????????????? ?????? ??????????????? ???????????? ?????? ????????? ????????????????????????
AI/ML ????????? ????????????: ?????????????????????????????? ?????? ??????????????? ?????????????????? ??????????????????????????? ?????? ????????????????????? ????????????, ??????????????? ????????????, ?????? ????????????????????? ???????????? ????????? ???????????? ?????????
?????????????????????????????? ?????? ??????????????? ????????????????????????????????? ??? Basic Concepts of TensorFlow
1. ??????????????? ??? Tensors
??????????????? TensorFlow ?????? ??????????????? ???????????? ??????????????????????????? ??????, ?????? ???????????????-??????????????????????????? arrays ?????? ????????? ????????? ???????????? ????????? ?????? ??????????????????, ??????????????????, ?????? ??????????????????????????? ?????? ???????????? ?????????
Code Example: ??????????????? ??????????????????
import tensorflow as tf
# Scalar Tensor
scalar = tf.constant(5)
print("Scalar Tensor:", scalar)
# 2D Tensor (Matrix)
matrix = tf.constant([[1, 2], [3, 4]])
print("Matrix Tensor:\n", matrix)
Output:
Scalar Tensor: tf.Tensor(5, shape=(), dtype=int32)
Matrix Tensor:
tf.Tensor(
[[1 2]
[3 4]], shape=(2, 2), dtype=int32)
AI/ML ????????? ????????????: ??????????????? ?????? ??????????????? ???????????? (???????????? ???????????? ????????????????????????, ???????????? ????????????????????????) ?????? ???????????? ?????????????????????????????? (???????????? ???????????????) ?????? ??????????????? ???????????? ?????? ????????? ???????????? ?????????
2. ?????????????????? ??????????????????????????? ??? Neural Networks
TensorFlow ?????????????????? ??????????????????????????? ?????? ??????????????? ?????? ????????? Keras API ?????????????????? ???????????? ??????, ?????? ?????????-???????????? ?????? ???????????????-???????????????????????? ?????????
Code Example: ?????????????????? ?????????????????? ????????????????????? ??????????????????
import tensorflow as tf
from tensorflow.keras import layers, models
# Neural Network Model
model = models.Sequential([
layers.Dense(10, activation='relu', input_shape=(2,)),
layers.Dense(1, activation='sigmoid')
])
# Model Summary
model.summary()
??????????????????:
Model: "sequential"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
dense (Dense) (None, 10) 30
dense_1 (Dense) (None, 1) 11
=================================================================
Total params: 41
Trainable params: 41
Non-trainable params: 0
_________________________________________________________________
AI/ML ????????? ????????????: ?????????????????? ??????????????????????????? ?????? ??????????????? ???????????? ????????????????????????????????????, NLP, ?????? ??????????????????????????? ???????????????????????? ????????? ???????????? ?????????
3. ???????????? ???????????????????????? ??? Model Training
?????????????????????????????? ????????? ???????????? ?????? ???????????? ?????? ??????????????? ???????????? ?????? ????????? ????????? ???????????????????????? ?????? ??????????????????????????????????????? ?????? ??????????????? ???????????? ?????????
Code Example: ?????????????????? ????????????????????? ?????? ??????????????? ???????????????
import tensorflow as tf
from tensorflow.keras import layers, models
import numpy as np
# Data
X = np.array([[0, 0], [0, 1], [1, 0], [1, 1]])
y = np.array([0, 1, 1, 0])
# Model
model = models.Sequential([
layers.Dense(4, activation='relu', input_shape=(2,)),
layers.Dense(1, activation='sigmoid')
])
# Model Compile.
model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy'])
# Tanning
model.fit(X, y, epochs=10, verbose=0)
print("Model Trained Successfully!")
Output:
Model Trained Successfully!
AI/ML ????????? ????????????: ???????????? ???????????????????????? ?????? ??????????????? ????????? ????????????????????? ?????????????????? ?????? ???????????? ?????? ?????????????????????????????? ???????????? ?????? ????????? ???????????? ?????????
4. ????????? ???????????????????????? ??? Loss Functions
????????? ???????????????????????? ???????????? ?????? ?????????????????????????????? ?????? ??????????????? ?????????, ???????????? MSE (????????????????????????) ?????? ???????????????-???????????????????????? (????????????????????????????????????)???
Code Example: ????????? ?????????????????? ?????? ??????????????????
import tensorflow as tf
import numpy as np
# Data
y_true = np.array([1, 0, 1, 0])
y_pred = np.array([0.9, 0.1, 0.8, 0.2])
# Cross-Entropy Loss.
loss = tf.keras.losses.binary_crossentropy(y_true, y_pred)
print("Binary Crossentropy Loss:", loss.numpy())
Output:
Binary Crossentropy Loss: 0.164252033486018
AI/ML ????????? ????????????: ????????? ???????????????????????? ?????? ??????????????? ???????????? ?????? ?????????????????????????????? ???????????? ?????? ?????????????????????????????? ?????? ??????????????? ?????? ????????? ???????????? ?????????
AI ?????? ML ????????? ?????????????????????????????? ?????? ??????????????? ??? Advantages of TensorFlow in AI & ML in Hindi
-
Scalability: ???????????? ??????????????????????????? ?????? GPU/TPU ?????????????????? ?????? ????????? ????????? ???????????? ?????????
-
User-friendly: Keras API ?????? ????????? ????????? ????????????????????? ?????? ???????????? ??????????????? ?????????
-
Versatility: ????????????, ?????????????????????, ?????? ???????????? ?????????????????? ???????????? ?????? ????????? ????????????????????????
-
Community Support: X, GitHub, ?????? Stack Overflow ?????? ????????? ???????????? ??????????????????????????????
AI ?????? ML ????????? ?????????????????????????????? ?????? ???????????? ????????? ??? Use Cases of TensorFlow in AI & ML in Hindi
-
Image Classification:??CNNs ?????? ????????? ???????????? ??????????????????????????????
-
NLP: ????????????????????? ???????????????????????????????????? ?????? ??????????????????????????? ???????????????????????????
-
Time Series: RNNs ?????? ????????? ????????????????????????????????????
-
Automation: ??????????????????????????? ????????? ?????????????????? ?????? ????????????????????? ???????????????
Mini Project Idea:???????? ?????????????????? ?????????????????? ????????????????????? ??????????????? ?????? XOR ???????????????????????? ?????? ??????????????? ????????????
# Mini Project: XOR problem
import tensorflow as tf
from tensorflow.keras import layers, models
import numpy as np
# Data
X = np.array([[0, 0], [0, 1], [1, 0], [1, 1]])
y = np.array([0, 1, 1, 0])
# Model
model = models.Sequential([
layers.Dense(4, activation='relu', input_shape=(2,)),
layers.Dense(1, activation='sigmoid')
])
# Compile and Training
model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy'])
model.fit(X, y, epochs=100, verbose=0)
# Prediction
predictions = model.predict(X)
print("Predictions:", predictions.round())
Output:
Predictions: [[0.]
[1.]
[1.]
[0.]]
?????????????????????????????? ????????? ??????????????? ????????????????????????????????? ??? Best Practices in TensorFlow in Hindi
-
Data Preprocessing:?????????????? ?????? ?????????????????????????????? ?????? ??????????????? ???????????????
-
Model Design: ???????????? ?????????????????? ?????? ???????????? ???????????? ?????? ????????????-???????????? ?????????????????????????????????????????? ?????????????????????
-
Documentation: ????????? ????????? ????????????????????? ?????? ??????????????????????????????????????? ??????????????? ?????????????????????
-
Practice: Kaggle ?????? ?????????????????????????????? ?????? ????????? ????????? ????????????????????? ????????????????????????????????? ???????????????
???????????????????????? - Conclusion
TensorFlow ?????? ??????????????????????????? ??????????????????????????? ?????? ?????? AI ?????? ML ????????? ????????? ????????????????????? ?????????????????? ?????? ??????????????? ?????? ??????????????? ???????????? ?????? ???????????? ??????????????? ????????? ?????? ??????????????? ????????? ???????????? TensorFlow ?????? ??????????????? ????????????????????????????????? ???????????? ???????????????, ?????????????????? ???????????????????????????, ???????????? ????????????????????????, ?????? ????????? ???????????????????????? ?????? ??????????????? ??????????????????????????? ????????????, ????????? ?????? AI/ML ????????? ???????????? ???????????? ????????? ?????? ?????? ????????? ???????????????
???????????? ????????????????????? ????????? ?????? PyTorch, Advanced Deep Learning, ?????? ???????????? AI/ML ??????????????? ?????? ??????????????? ??????????????????????????? ??????????????????, ?????? ?????????????????????????????? ????????????????????????????????? ?????? ??????????????????????????? ??????????????????????????? ???????????? ???????????? ?????? ???????????? AI/ML ????????????????????????????????? ????????? TensorFlow ?????? ??????????????? ????????????!
Read More:
- PyTorch ???????????? ??????? AI ?????? ML ????????? ???????????? ???????????????
- Scikit-learn ?????? ????????? ML ??????????????????
- Matplotlib Explained in Hindi: AI ?????? ML ?????? ????????? Visualizations ???????????? ???????????????
- Pandas ???????????? ??????? AI ?????? Machine Learning Beginners ?????? ????????? Easy Guide