Machine Learning & AI · Chapter 4.6 · Intermediate level

Neural Networks & Deep Learning (Build an AI Brain! )

Neural Networks और Deep Learning (डिजिटल इंसानी दिमाग़ बनाना! )

Welcome to the grand finale of the Academy! How do self-driving cars see roads, phones unlock with Face ID, and AI models think deeply? By copying the human brain's Neurons! An Artificial Neural Network has 3 Layers:
1. input_nodes (Input Layer — Eyes & Ears receiving clues)
2. hidden_nodes (Hidden Layer — Brain cells doing deep math)
3. output_nodes (Output Layer — Final decision!)
And epochs=50 means how many times the AI revises the textbook — watch what happens in the Live Brain Visualizer when you change hidden_nodes=5 to 8!

अकादमी के ग्रैंड फ़िनाले में स्वागत है! सेल्फ़-ड्राइविंग कारें, Face ID और आधुनिक AI इंसान की तरह गहराई से कैसे पहचानते हैं? इंसानी दिमाग़ के न्यूरॉन्स (Neurons) की नकल करके! कंप्यूटर के Neural Network में 3 परतें (Layers) होती हैं:
1. input_nodes (Input Layer — आँख/कान जहाँ से डेटा अंदर आता है)
2. hidden_nodes (Hidden Layer — असली सोच-विचार करने वाले न्यूरॉन्स)
3. output_nodes (Output Layer — आख़िरी फ़ैसला!)
और epochs=50 का मतलब है AI कितनी बार रिवीज़न (दोहराव) करेगा! कोड में hidden_nodes=5 को 8 बदलकर देखो — प्रिव्यू में सचमुच 8 चमकते न्यूरॉन्स बन जाएँगे!

In the classroom you can run and edit this code in your browser, get hints and mark the chapter as done. क्लास में यह code ब्राउज़र में चलाकर बदल सकते हो।

Words and symbols in this chapter

NeuralNetwork(...)
Constructs a 3-layer Artificial Neural Network simulator.
3 परतों वाला आर्टिफिशियल न्यूरल नेटवर्क दिमाग़ बनाता है।
input_nodes=3
Number of neurons in Layer 1 (Input Layer — try 2 to 6!).
पहली परत (Input Layer) में न्यूरॉन्स की संख्या।
hidden_nodes=5
Number of thinking neurons in Layer 2 (try changing 5 to 8!).
बीच की परत (Hidden Layer) के न्यूरॉन्स (5 को 8 बदलकर लाइव देखो!)।
output_nodes=1
Number of decision neurons in Layer 3 (Output Layer).
आख़िरी परत (Output Layer) के न्यूरॉन्स की संख्या।
brain.train(epochs=50)
Trains the network for 50 revision cycles, boosting accuracy up to 98.5%!
50 बार रिवीज़न करवाकर सटीकता (Accuracy) को 98.5% तक पहुँचाता है!

Ready example

# Step 1: Build a 3-Layer Neural Network Brain
brain = NeuralNetwork(input_nodes=3, hidden_nodes=5, output_nodes=1)

# Step 2: Train for 50 Epochs (50 revisions!)
brain.train(epochs=50)

# Step 3: Print AI readiness
print("AI Brain Ready! Accuracy: 98.5%")

What you will see: Dynamic glowing 3-Layer Brain Graph (changes node count live when you edit hidden_nodes!) + firing electric pulses + animated Epoch & Accuracy bar!

3 कॉलम में चमकते न्यूरॉन्स और दौड़ती रोशनी (Pulses) दिखेंगी (hidden_nodes बदलते ही न्यूरॉन्स की संख्या भी लाइव बदलेगी) और Accuracy 20% → 98.5% तक बढ़ेगी!

Line by line

brain = NeuralNetwork(input_nodes=3, hidden_nodes=5, output_nodes=1)
Builds 3 Input → 5 Hidden → 1 Output neurons with glowing synapses!
3 Input, 5 Hidden, और 1 Output न्यूरॉन वाला दिमाग़ तैयार करता है!
brain.train(epochs=50)
Fires electric pulses across all synapses from Epoch 1 to Epoch 50!
न्यूरॉन्स के बीच बिजली के पल्स दौड़ाकर 50 राउंड ट्रेनिंग करता है!
print("AI Brain Ready! Accuracy: 98.5%")
Confirms our AI Brain is trained and ready!
पुष्टि करता है कि हमारा AI दिमाग़ 98.5% सटीकता के साथ तैयार है!

Common mistake

✗ Wrong

brain.train(epochs=0)

✓ Right

brain.train(epochs=50)

With epochs=0, the Neural Network performs zero revisions and stays untrained!

epochs=0 रखने पर न्यूरल नेटवर्क 0 बार रिवीज़न करेगा और कुछ नहीं सीख पाएगा — कम से कम 50 रखें!

Your task

Build NeuralNetwork(input_nodes=3, hidden_nodes=5, output_nodes=1), run brain.train(epochs=50), and print the accuracy message!

NeuralNetwork(input_nodes=3, hidden_nodes=5, output_nodes=1) बनाओ, brain.train(epochs=50) चलाओ और एक्यूरेसी प्रिंट करो!

  1. Create brain = NeuralNetwork(input_nodes=3, hidden_nodes=5, output_nodes=1).
    brain = NeuralNetwork(input_nodes=3, hidden_nodes=5, output_nodes=1) लिखो।
  2. Call brain.train(epochs=50).
    brain.train(epochs=50) चलाओ।
  3. Print "AI Brain Ready! Accuracy: 98.5%" and click ▶ Run & Preview!
    मैसेज प्रिंट करके ▶ Run & Preview दबाओ!
Starter code for the task
print("Neural network banane ki taiyari...")

# TODO 1: brain = NeuralNetwork(input_nodes=3, hidden_nodes=5, output_nodes=1) banao
# TODO 2: brain.train(epochs=50) se 50 baar revision karwao
# TODO 3: print("AI Brain Ready! Accuracy: 98.5%")

Do this task in the classroom: your code is checked automatically and you get hints if something is missing.

Recap

Quick quiz

In a Neural Network, what does epochs=50 mean?

न्यूरल नेटवर्क ट्रेनिंग में epochs=50 का क्या मतलब होता है?

  1. 50 hidden layers
  2. 50 full training revisions over the dataset
  3. 50 seconds timeout
  4. 50% error rate
Show the answer

Answer: B (50 full training revisions over the dataset)

1 Epoch = 1 complete pass/revision through the training dataset!

epochs=50 यानी AI पूरे डेटासेट का 50 बार अभ्यास (Revision) करेगा!

Practice problems for this chapter

Solve them in the Practice Zone, where each answer is checked automatically and two hints are available.