Fitted Q-Learning और Deep Q-Learning क्या हैं? | Fitted Q and Deep Q-Learning in Hindi


Fitted Q-Learning और Deep Q-Learning क्या हैं? | Fitted Q and Deep Q-Learning in Hindi

Reinforcement Learning (RL) में, **Fitted Q-Learning** और **Deep Q-Learning (DQN)** दो महत्वपूर्ण एल्गोरिदम हैं, जो Q-Learning को अधिक शक्तिशाली और प्रभावी बनाते हैं।

  • Fitted Q-Learning: Supervised Learning Techniques का उपयोग करके Q-Function को Approximated करता है।
  • Deep Q-Learning (DQN): Q-Function को Deep Neural Networks की मदद से सीखता है।

1. Fitted Q-Learning क्या है?

Fitted Q-Learning एक **Batch Reinforcement Learning** Technique है, जिसमें Traditional Q-Learning को Supervised Learning Algorithms के साथ जोड़ा जाता है। यह **Overfitting को कम करता है** और बेहतर Generalization प्रदान करता है।

Fitted Q-Learning का मुख्य उद्देश्य:

  • Q-Function को किसी भी Approximation Model के साथ Fit करना।
  • Sample-Efficient Learning प्रदान करना।
  • Continuous और High-Dimensional State Spaces में Q-Learning को अधिक प्रभावी बनाना।

Fitted Q-Learning Algorithm:

  1. Experience Data (s, a, r, s′) को Collect करें।
  2. Q-Function को एक Function Approximator (Decision Tree, Neural Network, आदि) के साथ Fit करें।
  3. Bellman Equation का उपयोग करके Target Q-Values को अपडेट करें:

Q(s, a) = R(s, a) + γ maxa′ Q(s′, a′)

Fitted Q-Learning को Python में Implement करें

import numpy as np
from sklearn.ensemble import ExtraTreesRegressor

# Environment Parameters
n_states = 10
n_actions = 2
gamma = 0.9

# Initialize Model
q_function = ExtraTreesRegressor(n_estimators=50)
X_train, y_train = [], []

# Sample Data (State, Action, Reward, Next State)
data = [(0, 1, 10, 1), (1, 0, 5, 2), (2, 1, -1, 3)]

# Q-Function Approximation
for (s, a, r, s_next) in data:
    target_q = r + gamma * np.max(q_function.predict([[s_next, a]]))
    X_train.append([s, a])
    y_train.append(target_q)

q_function.fit(X_train, y_train)
print("Trained Q-Function:", q_function.predict([[0, 1]]))

Fitted Q-Learning का उपयोग

  • Robotics
  • Autonomous Vehicles
  • Game AI
  • Healthcare Decision-Making
---

2. Deep Q-Learning (DQN) क्या है?

Deep Q-Network (DQN) Reinforcement Learning में एक महत्वपूर्ण Algorithm है, जो **Neural Networks का उपयोग करके Q-Function** को Approximate करता है। यह High-Dimensional State Spaces में Q-Learning को अधिक शक्तिशाली बनाता है।

Deep Q-Learning के मुख्य घटक:

  • **Experience Replay:** Training Stability बढ़ाने के लिए Past Experiences को Store करना।
  • **Target Network:** Q-Value Estimation को स्थिर करने के लिए एक Fixed Target Network का उपयोग।
  • **Deep Neural Network:** Q-Function को Approximate करने के लिए Multi-Layer Perceptron का उपयोग।

Deep Q-Learning Algorithm:

  1. Environment से Experiences (s, a, r, s′) Collect करें।
  2. Experience Replay Buffer में Save करें।
  3. Mini-Batch Gradient Descent से Q-Network को Update करें।
  4. Bellman Equation का उपयोग करके Target Q-Values अपडेट करें:

Q(s, a) = R(s, a) + γ maxa′ Q(s′, a′)

Deep Q-Learning को Python में Implement करें

import tensorflow as tf
import numpy as np
import gym

# OpenAI Gym Environment लोड करें
env = gym.make("CartPole-v1")
state_size = env.observation_space.shape[0]
action_size = env.action_space.n

# DQN Model
model = tf.keras.models.Sequential([
    tf.keras.layers.Dense(24, activation="relu", input_shape=(state_size,)),
    tf.keras.layers.Dense(24, activation="relu"),
    tf.keras.layers.Dense(action_size, activation="linear")
])

optimizer = tf.keras.optimizers.Adam(lr=0.01)
loss_fn = tf.keras.losses.MeanSquaredError()

# Q-Update Function
def train_dqn(states, actions, rewards, next_states, done):
    target_q_values = rewards + 0.9 * np.max(model.predict(next_states), axis=1) * (1 - done)
    with tf.GradientTape() as tape:
        predicted_q_values = model(states)
        action_q_values = tf.reduce_sum(predicted_q_values * actions, axis=1)
        loss = loss_fn(target_q_values, action_q_values)
    
    grads = tape.gradient(loss, model.trainable_variables)
    optimizer.apply_gradients(zip(grads, model.trainable_variables))

# Training Loop
for episode in range(1000):
    state = env.reset()
    done = False
    while not done:
        state = np.reshape(state, [1, state_size])
        action_prob = model.predict(state)
        action = np.argmax(action_prob)
        
        next_state, reward, done, _ = env.step(action)
        train_dqn(state, action, reward, next_state, done)
        state = next_state

Deep Q-Learning का उपयोग

  • Autonomous Driving
  • Atari Games
  • Robotics
  • Finance
---

3. Fitted Q-Learning बनाम Deep Q-Learning

Feature Fitted Q-Learning Deep Q-Learning
मुख्य उद्देश्य Function Approximation के साथ Q-Function सीखना Neural Networks के साथ Q-Function सीखना
Learning Type Batch-Based Learning Online Learning
Function Approximator Decision Trees, Random Forests Deep Neural Networks
मुख्य उपयोग Offline RL, Healthcare AI Atari Games, Robotics
---

4. निष्कर्ष

Fitted Q-Learning Reinforcement Learning में Traditional Q-Learning को अधिक स्थिर और प्रभावी बनाता है, जबकि Deep Q-Learning Neural Networks का उपयोग करके Large State Spaces में अधिक बेहतर Decision-Making करता है।

दोनों Techniques AI, Robotics, और Autonomous Systems में उपयोग की जाती हैं और Reinforcement Learning को अधिक शक्तिशाली बनाती हैं।

Related Post

Comments

Comments