LECTURE 07 | المحاضرة 07

Deep Learning

التعلم العميق
Deep Neural Networks, ReLU, CNN, RNN, and Power-System Applications
الشبكات العصبية العميقة وReLU وCNN وRNN وتطبيقاتها في نظم الطاقة

🎯 Learning Objectives

  • Understand what makes a neural network “deep”.
  • Distinguish shallow and deep neural networks.
  • Understand why deep networks can learn hierarchical features.
  • Explain the ReLU activation function.
  • Understand the vanishing-gradient problem.
  • Understand the basic ideas of CNNs and RNNs.
  • Identify important Deep Learning applications in power systems.

🎯 أهداف التعلم

  • فهم المقصود بالشبكة العصبية العميقة.
  • التمييز بين الشبكات الضحلة والعميقة.
  • فهم كيف تتعلم الشبكات العميقة ميزات هرمية.
  • فهم دالة التنشيط ReLU.
  • فهم مشكلة تلاشي التدرج.
  • فهم الفكرة الأساسية لـ CNN وRNN.
  • التعرف على أهم تطبيقات التعلم العميق في نظم الطاقة الكهربائية.

1. What is Deep Learning?

Deep Learning is a branch of Machine Learning based mainly on neural networks containing multiple hidden layers.

Deep Learning = Neural Networks with many layers capable of learning increasingly abstract representations.

1. ما هو التعلم العميق؟

التعلم العميق هو فرع من التعلم الآلي يعتمد بصورة أساسية على الشبكات العصبية متعددة الطبقات المخفية.

كلما ازدادت الطبقات، أصبح بإمكان الشبكة تعلم تمثيلات أكثر تعقيدًا وتجريدًا.

2. Shallow vs Deep Neural Networks

Shallow Neural Network

Usually one hidden layer or only a few layers.

Deep Neural Network

Multiple hidden layers arranged hierarchically.

2. الشبكات الضحلة مقابل الشبكات العميقة

الشبكة الضحلة

تحتوي عادةً على طبقة مخفية واحدة أو عدد قليل من الطبقات.

الشبكة العميقة

تحتوي على عدة طبقات مخفية مرتبة بصورة هرمية.

3. Why Can Deep Networks Learn More?

Each layer transforms the representation produced by the previous layer.

Raw Input
Simple Features
Combined Features
High-Level Representation
Prediction
Depth allows the network to build complex features from simpler ones.

3. لماذا تستطيع الشبكات العميقة تعلم علاقات أكثر تعقيدًا؟

تقوم كل طبقة بتحويل التمثيل القادم من الطبقة السابقة إلى تمثيل جديد.

تبني الطبقات المتقدمة ميزات معقدة انطلاقًا من ميزات أبسط.

4. Mathematical Form of a Deep Network

For layer l:

z⁽ˡ⁾ = W⁽ˡ⁾ a⁽ˡ⁻¹⁾ + b⁽ˡ⁾
a⁽ˡ⁾ = φ(z⁽ˡ⁾)

where:

  • W⁽ˡ⁾ = weight matrix of layer l
  • b⁽ˡ⁾ = bias vector
  • a⁽ˡ⁻¹⁾ = input from previous layer
  • φ = activation function

4. الصيغة الرياضية للشبكة العميقة

في كل طبقة l نحسب أولًا:

z⁽ˡ⁾ = W⁽ˡ⁾ a⁽ˡ⁻¹⁾ + b⁽ˡ⁾

ثم:

a⁽ˡ⁾ = φ(z⁽ˡ⁾)

أي أن كل طبقة تستقبل خرج الطبقة السابقة وتطبّق عليه تحويلًا خطيًا ثم دالة تنشيط.

5. Visual Structure of a Deep Network

x₁ x₂ h₁ h₂ h₃ h₄ h₅ h₆ h₇ y

The essential difference is not the symbol used, but the number of sequential nonlinear transformations.

5. البنية البصرية للشبكة العميقة

الفرق الأساسي هو وجود عدة تحويلات غير خطية متتابعة بين المدخلات والخرج.

6. The ReLU Activation Function

ReLU(z) = max(0,z)

Therefore:

ReLU(z) = 0, z<0
z, z≥0

Its derivative is:

ReLU'(z) = 0, z<0
1, z>0

6. دالة التنشيط ReLU

ReLU(z) = max(0,z)

أي أن القيم السالبة تتحول إلى صفر، بينما تمر القيم الموجبة كما هي.

بساطة مشتقة ReLU تساعد على تدريب الشبكات العميقة بكفاءة أكبر.

7. Why Not Use Sigmoid Everywhere?

Sigmoid is useful, but in deep networks its derivative can become very small.

σ'(z)=σ(z)[1-σ(z)]

Since:

0 < σ'(z) ≤ 0.25

multiplying many such derivatives during backpropagation can make the gradient extremely small.

7. لماذا لا نستخدم Sigmoid في جميع الطبقات العميقة؟

مشتقة Sigmoid صغيرة نسبيًا، ومع تكرار الضرب عبر طبقات كثيرة قد يصبح التدرج صغيرًا جدًا.

0 < σ'(z) ≤ 0.25

8. Vanishing Gradient

During backpropagation, gradients are multiplied across layers.

∂E/∂w₁ = ∂E/∂aᴸ × ∂aᴸ/∂aᴸ⁻¹ × ... × ∂a²/∂a¹ × ∂a¹/∂w₁

If many factors are smaller than 1, the final gradient may approach zero.

Vanishing gradient means early layers learn extremely slowly.

8. مشكلة تلاشي التدرج

أثناء الانتشار الخلفي يتم ضرب العديد من المشتقات عبر الطبقات.

إذا كانت معظم هذه القيم أصغر من الواحد، فقد يصبح التدرج في الطبقات الأولى قريبًا جدًا من الصفر.

النتيجة: تتعلم الطبقات الأولى ببطء شديد.

9. Why ReLU Helps

For positive inputs:

ReLU'(z)=1

so the gradient can pass through the layer without being repeatedly multiplied by a small number such as 0.1 or 0.2.

9. كيف تساعد ReLU؟

عندما يكون الدخل موجبًا تكون المشتقة مساوية للواحد:

ReLU'(z)=1

وهذا يساعد على انتقال التدرج عبر الشبكة بصورة أفضل.

10. Deep Learning Training Cycle

Mini-Batch Data
Forward Pass
Loss
Backpropagation
Optimizer
Updated Weights

10. دورة تدريب التعلم العميق

دفعة بيانات ← انتشار أمامي ← حساب الخطأ ← انتشار خلفي ← خوارزمية تحسين ← تحديث الأوزان

11. What is a Mini-Batch?

Instead of using the whole dataset at every update, Deep Learning usually processes a small subset called a mini-batch.

Batch Size = Number of samples used in one gradient update

11. ما المقصود بـ Mini-Batch؟

بدل استخدام كامل بيانات التدريب في كل تحديث، يتم استخدام مجموعة صغيرة من العينات في كل خطوة.

12. Epoch

One epoch means that the complete training dataset has been processed once.

1 Epoch = One full pass through the training dataset

12. ما هو Epoch؟

يعني Epoch واحد أن جميع عينات بيانات التدريب قد مرت عبر الشبكة مرة واحدة.

13. Convolutional Neural Networks — CNN

CNNs are designed to detect local patterns using filters or kernels.

y(i) = Σₖ w(k)x(i-k)

This operation is a simplified discrete convolution.

The same filter is reused at different positions, reducing the number of independent parameters.

13. الشبكات العصبية الالتفافية CNN

تستخدم CNN مرشحات صغيرة لاكتشاف الأنماط المحلية داخل البيانات.

y(i) = Σₖ w(k)x(i-k)

يتم استخدام المرشح نفسه في مواقع مختلفة، وهذا يقلل عدد المعاملات.

14. CNN for Power-System Signals

CNNs are not limited to images. A one-dimensional CNN can process electrical time-series signals.

Voltage / Current Signal
Convolution Filters
Feature Maps
Classifier
Example: detect fault signatures directly from voltage or current waveforms.

14. استخدام CNN مع إشارات نظم الطاقة

يمكن استخدام CNN أحادية البعد لمعالجة إشارات الجهد أو التيار الزمنية.

مثال: اكتشاف بصمة العطل مباشرة من شكل موجة الجهد أو التيار.

15. Recurrent Neural Networks — RNN

RNNs are designed for sequential data where past information matters.

hₜ = φ(Wₓxₜ + Wₕhₜ₋₁ + b)

The hidden state hₜ depends on both the current input and the previous hidden state.

15. الشبكات العصبية المتكررة RNN

تستخدم RNN للبيانات المتسلسلة زمنيًا، حيث تكون المعلومات السابقة مهمة.

hₜ = φ(Wₓxₜ + Wₕhₜ₋₁ + b)

أي أن الحالة الحالية تعتمد على الدخل الحالي والحالة السابقة.

16. Why RNNs are Useful for Energy Forecasting

Electrical load and renewable generation are time-dependent.

Load(t+1) = f(Load(t), Load(t-1), Temperature(t), ...)
RNN-type models are attractive because they explicitly represent temporal dependence.

16. لماذا تعد RNN مناسبة للتنبؤ بالطاقة؟

الحمل الكهربائي وتوليد الطاقة المتجددة يعتمدان على القيم السابقة زمنيًا.

Load(t+1) = f(Load(t), Load(t-1), Temperature(t), ...)

17. LSTM — Basic Idea

Long Short-Term Memory networks are a special form of recurrent network designed to retain useful information over longer time intervals.

LSTM uses gates to control what information should be remembered, forgotten, or passed forward.

17. الفكرة الأساسية لـ LSTM

LSTM هي بنية متقدمة من الشبكات المتكررة تساعد على الاحتفاظ بالمعلومات المهمة عبر فترات زمنية أطول.

تستخدم بوابات لتحديد ما يجب تذكره وما يجب نسيانه وما يجب تمريره.

18. Deep Learning vs Classical Machine Learning

Aspect Classical ML Deep Learning
Feature Engineering Often manual Often learned automatically
Data Requirement Moderate Often large
Model Complexity Lower Higher
Interpretability Often easier Often more difficult
Computation Lower Higher

18. التعلم العميق مقابل التعلم الآلي التقليدي

يحتاج التعلم العميق عادةً إلى بيانات وقدرة حسابية أكبر، لكنه يستطيع تعلم الميزات تلقائيًا وبناء تمثيلات معقدة.

19. Power-System Application: Load Forecasting

A deep network may receive:

x = [Historical Load, Temperature, Time, Day Type, Weather]

and predict:

y = Future Load

19. تطبيق في نظم الطاقة: التنبؤ بالحمل

يمكن للشبكة العميقة استخدام الحمل التاريخي والطقس والوقت ونوع اليوم للتنبؤ بالحمل المستقبلي.

20. Renewable-Energy Forecasting

PV Forecasting

Solar irradiance, temperature, cloud information, and historical PV power.

Wind Forecasting

Wind speed, wind direction, weather data, and historical turbine output.

20. التنبؤ بالطاقة المتجددة

يمكن استخدام التعلم العميق للتنبؤ بالطاقة الشمسية وطاقة الرياح اعتمادًا على البيانات الجوية والتاريخية.

21. Fault Detection and Classification

Deep networks can learn characteristic fault patterns from measurements.

Voltage / Current Data
Deep Model
Fault Type

21. اكتشاف الأعطال وتصنيفها

تستطيع الشبكات العميقة تعلم أنماط الأعطال من بيانات الجهد والتيار ثم تحديد نوع العطل.

22. Condition Monitoring

Deep Learning can analyze large streams of sensor data for equipment such as transformers, generators, and converters.

Goal: detect abnormal behavior before complete failure occurs.

22. مراقبة الحالة

يمكن تحليل بيانات الحساسات للمحولات والمولدات والمحولات الإلكترونية لاكتشاف السلوك غير الطبيعي مبكرًا.

23. Challenges of Deep Learning

  • Large data requirements.
  • High computational cost.
  • Difficult model interpretation.
  • Risk of overfitting.
  • Data quality and distribution shifts.
  • Cybersecurity and safety considerations.

23. تحديات التعلم العميق

  • الحاجة إلى كميات كبيرة من البيانات.
  • ارتفاع الكلفة الحسابية.
  • صعوبة تفسير بعض النماذج.
  • احتمال فرط المطابقة.
  • تأثر الأداء بجودة البيانات وتغير توزيعها.
  • ضرورة مراعاة الأمن السيبراني والسلامة.

24. MATLAB / Deep Learning Concept

At a conceptual level, a deep network still repeats the same basic layer operation:

z = W*a + b
a = activation(z)

The key difference is that this operation is repeated through many layers.

24. الفكرة البرمجية في MATLAB

ما زالت الشبكة العميقة تعتمد على العملية الأساسية نفسها:

z = W*a + b
a = activation(z)

لكن هذه العملية تتكرر عبر عدد أكبر من الطبقات.

25. Summary

  • Deep Learning uses neural networks with multiple hidden layers.
  • Each layer learns a new representation of the data.
  • ReLU is widely used in deep networks.
  • Vanishing gradients can make early layers learn slowly.
  • CNNs are useful for local patterns and waveform analysis.
  • RNNs and LSTMs are useful for sequential and time-series data.
  • Power-system applications include forecasting, fault diagnosis, and condition monitoring.

25. الخلاصة

  • يعتمد التعلم العميق على شبكات عصبية متعددة الطبقات.
  • تتعلم كل طبقة تمثيلًا جديدًا للبيانات.
  • تستخدم ReLU بكثرة في الشبكات العميقة.
  • يمكن أن تسبب مشكلة تلاشي التدرج بطئًا في تعلم الطبقات الأولى.
  • تعد CNN مناسبة لاكتشاف الأنماط المحلية وتحليل الإشارات.
  • تعد RNN وLSTM مناسبة للبيانات المتسلسلة زمنيًا.
  • تشمل التطبيقات التنبؤ وتشخيص الأعطال ومراقبة الحالة.

📝 Review Questions

  1. What makes a neural network deep?
  2. Why can deep networks learn hierarchical features?
  3. Write the mathematical equation of one deep-network layer.
  4. What is the ReLU activation function?
  5. Why can Sigmoid cause vanishing gradients?
  6. What is the main idea of CNN?
  7. What is the main idea of RNN?
  8. Why are RNN/LSTM models useful for load forecasting?
  9. Give three Deep Learning applications in power systems.

📝 أسئلة المراجعة

  1. متى نطلق على الشبكة العصبية اسم شبكة عميقة؟
  2. لماذا تستطيع الشبكات العميقة تعلم ميزات هرمية؟
  3. اكتب المعادلة الرياضية لطبقة واحدة في شبكة عميقة.
  4. ما هي دالة ReLU؟
  5. لماذا قد تؤدي Sigmoid إلى تلاشي التدرج؟
  6. ما الفكرة الأساسية لـ CNN؟
  7. ما الفكرة الأساسية لـ RNN؟
  8. لماذا تعد RNN وLSTM مناسبة للتنبؤ بالحمل؟
  9. اذكر ثلاثة تطبيقات للتعلم العميق في نظم الطاقة الكهربائية.