Artificial Neural Networks
العصبونات ودوال التنشيط ودالة الخطأ والتدرجات والانتشار الخلفي
🎯 Learning Objectives
- Understand the mathematical model of an artificial neuron.
- Explain weights, bias, weighted sum, and activation functions.
- Understand the Sigmoid activation function.
- Derive the derivative of the Sigmoid function.
- Understand forward propagation.
- Define and interpret a loss function.
- Understand gradient descent.
- Use the chain rule to derive backpropagation equations.
- Apply neural networks to power-system problems.
🎯 أهداف التعلم
- فهم النموذج الرياضي للعصبون الاصطناعي.
- فهم الأوزان والانزياح والمجموع الموزون ودوال التنشيط.
- فهم دالة Sigmoid.
- اشتقاق مشتق دالة Sigmoid خطوة بخطوة.
- فهم الانتشار الأمامي.
- تعريف دالة الخطأ وفهم معناها.
- فهم خوارزمية الانحدار المتدرج.
- استخدام قاعدة السلسلة لاشتقاق معادلات الانتشار الخلفي.
- تطبيق الشبكات العصبية على مسائل نظم الطاقة الكهربائية.
1. From Biological Neuron to Artificial Neuron
Artificial neural networks are inspired by the idea of biological neurons: receive signals, combine them, and generate an output.
1. من العصبون الحيوي إلى العصبون الاصطناعي
تستلهم الشبكات العصبية الاصطناعية فكرتها بصورة مبسطة من العصبونات الحيوية: استقبال إشارات، دمجها، ثم إنتاج خرج.
2. Mathematical Model of a Neuron
Suppose the neuron receives n inputs:
Each input has a corresponding weight:
The neuron first calculates the weighted sum:
or more compactly:
The output is:
2. النموذج الرياضي للعصبون
لنفترض أن العصبون يستقبل n من المدخلات:
ولكل مدخل وزن:
يقوم العصبون أولًا بحساب المجموع الموزون:
ثم يتم تمرير z عبر دالة التنشيط:
3. Why Do We Need Weights?
The weights determine how strongly each input influences the output.
If:
then input x₁ has a stronger influence than x₂.
3. لماذا نحتاج إلى الأوزان؟
تحدد الأوزان مقدار تأثير كل مدخل على خرج العصبون.
فإذا كان:
فإن تأثير x₁ على الخرج أكبر من تأثير x₂.
4. What Does the Bias Do?
The bias shifts the activation function and allows the neuron to produce useful outputs even when all inputs are zero.
4. ما وظيفة الانزياح Bias؟
يسمح الانزياح بتحريك استجابة العصبون ويساعده على إعطاء خرج مناسب حتى عندما تكون بعض المدخلات مساوية للصفر.
5. Structure of a Simple Neural Network
This is a 2–2–1 neural network:
5. بنية شبكة عصبية بسيطة
يوضح الشكل شبكة عصبية من النوع:
أي مدخلان، عصبونان في الطبقة المخفية، وخرج واحد.
6. Activation Functions
Without an activation function, a neural network would behave mainly like a linear mathematical model.
6. دوال التنشيط
تسمح دوال التنشيط للشبكة بتمثيل علاقات غير خطية ومعقدة.
من أشهرها Sigmoid وTanh وReLU.
7. The Sigmoid Function
The output always lies between 0 and 1:
This is useful when the output can be interpreted as a probability or normalized response.
7. دالة Sigmoid
تكون قيمة الخرج دائمًا بين الصفر والواحد:
8. Derivative of the Sigmoid Function
Start with:
Differentiate using the chain rule:
Therefore:
Now note:
and:
Multiplying both expressions:
Hence:
8. اشتقاق دالة Sigmoid
نبدأ من:
باستخدام قاعدة السلسلة نحصل على:
وبإعادة ترتيبها باستخدام قيمة σ نفسها:
9. Forward Propagation
Forward propagation means calculating the network output from the input toward the output layer.
Hidden neuron 1
Hidden neuron 2
Output neuron
9. الانتشار الأمامي
يعني الانتشار الأمامي حساب خرج الشبكة بدءًا من المدخلات، مرورًا بالطبقات المخفية، وصولًا إلى الخرج النهائي.
10. Loss Function
The network prediction y must be compared with the desired target t.
A simple squared-error loss is:
The factor 1/2 is used because it simplifies the derivative.
10. دالة الخطأ
نقارن خرج الشبكة y مع القيمة المطلوبة t.
نستخدم العامل 1/2 لأنه يجعل الاشتقاق أبسط.
11. Derivative of the Loss
Start from:
Differentiate with respect to y:
11. مشتقة دالة الخطأ
نبدأ من:
وبالاشتقاق بالنسبة إلى y:
هذه القيمة تخبرنا باتجاه الخطأ.
12. Why Do We Need Backpropagation?
We know the final error, but we need to know:
Backpropagation answers this question using derivatives and the chain rule.
12. لماذا نحتاج إلى الانتشار الخلفي؟
نعرف الخطأ النهائي، لكننا نحتاج إلى معرفة مقدار مساهمة كل وزن في هذا الخطأ.
13. The Chain Rule
If:
then:
13. قاعدة السلسلة
إذا كان الوزن w يؤثر على z، وz تؤثر على y، وy تؤثر على الخطأ E، فإن تأثير w على E يحسب بضرب المشتقات الجزئية على طول المسار.
14. Output-Layer Error Signal
For the output neuron:
We already know:
and:
Therefore:
dO = (y - t) * y * (1 - y)
14. إشارة الخطأ في طبقة الخرج
لدينا:
وباستخدام قاعدة السلسلة:
ولهذا تظهر في كود MATLAB العلاقة:
15. Gradient of an Output Weight
For weight v₁:
Therefore:
Thus:
Similarly:
and for the bias:
15. تدرج وزن في طبقة الخرج
لأن:
فإن:
وبالتالي:
16. Hidden-Layer Error Signal
Hidden neuron h₁ influences the output through weight v₁.
Using the chain rule:
Similarly:
16. إشارة الخطأ في الطبقة المخفية
يصل تأثير الخطأ من طبقة الخرج إلى الطبقة المخفية عبر الأوزان.
17. Gradient of Input-to-Hidden Weights
If:
then:
Therefore:
and:
17. تدرجات الأوزان بين الدخل والطبقة المخفية
لأن:
فإن:
18. Gradient Descent
After calculating the gradients, we update every parameter:
where η is the learning rate.
18. الانحدار المتدرج
بعد حساب المشتقات نقوم بتحديث الأوزان:
حيث η هو معدل التعلم.
19. Complete Training Cycle
19. دورة التدريب الكاملة
20. Numerical Example
Assume:
Then:
Sigmoid output:
Suppose the target is:
Loss:
20. مثال عددي
إذا كان:
فإن:
وإذا كانت القيمة المطلوبة t=1 فإن الخطأ:
21. MATLAB Connection
Forward propagation:
Output-layer error:
Output-weight gradients:
Hidden-layer error:
Weight gradient:
21. الربط مع MATLAB
الآن يمكن فهم كل سطر في كود الانتشار الخلفي بصورة رياضية.
22. Power-System Application: Load Forecasting
A neural network can receive several power-system variables:
and predict:
22. تطبيق في نظم الطاقة: التنبؤ بالحمل
يمكن للشبكة العصبية استقبال معلومات مثل درجة الحرارة والوقت والحمل السابق ونوع اليوم.
ثم تقوم بإنتاج تنبؤ للحمل الكهربائي المستقبلي.
23. Other Power-System Applications
Predict photovoltaic power generation.
Predict wind-power generation.
Identify and classify network faults.
Estimate voltage states using measurements.
Estimate SOC or predict optimal operation.
Detect abnormal conditions from large datasets.
23. تطبيقات أخرى في نظم الطاقة
- التنبؤ بالطاقة الشمسية.
- التنبؤ بطاقة الرياح.
- تصنيف الأعطال.
- تقدير الجهد والحالة التشغيلية.
- إدارة أنظمة تخزين الطاقة.
- مراقبة الشبكات الذكية.
24. Summary
- A neuron calculates a weighted sum and applies an activation function.
- The fundamental neuron equation is z = Σwᵢxᵢ + b.
- Sigmoid maps values into the interval (0,1).
- Its derivative is σ'(z)=σ(z)[1-σ(z)].
- Forward propagation calculates network predictions.
- The loss function measures prediction error.
- Backpropagation calculates gradients using the chain rule.
- Gradient descent updates the weights to reduce error.
- Neural networks have many applications in modern power systems.
24. الخلاصة
- يحسب العصبون مجموعًا موزونًا ثم يطبق دالة تنشيط.
- المعادلة الأساسية للعصبون هي z = Σwᵢxᵢ + b.
- تحول Sigmoid القيم إلى المجال بين الصفر والواحد.
- مشتقتها هي σ'(z)=σ(z)[1-σ(z)].
- يحسب الانتشار الأمامي خرج الشبكة.
- تقيس دالة الخطأ الفرق بين التنبؤ والقيمة المطلوبة.
- يحسب الانتشار الخلفي التدرجات باستخدام قاعدة السلسلة.
- يحدث الانحدار المتدرج الأوزان لتقليل الخطأ.
- للشبكات العصبية تطبيقات واسعة في نظم الطاقة الكهربائية.
📝 Review Questions
- What is the mathematical equation of an artificial neuron?
- What is the role of weights?
- What is the role of the bias?
- Why are activation functions required?
- Derive the derivative of the Sigmoid function.
- What is forward propagation?
- Why do we need a loss function?
- Explain the chain rule in backpropagation.
- Derive dO = (y-t)y(1-y).
- Why do we subtract the gradient during training?
- Name four neural-network applications in electrical power systems.
📝 أسئلة المراجعة
- ما المعادلة الرياضية للعصبون الاصطناعي؟
- ما وظيفة الأوزان؟
- ما وظيفة الانزياح؟
- لماذا نحتاج إلى دوال التنشيط؟
- اشتق مشتقة دالة Sigmoid.
- ما المقصود بالانتشار الأمامي؟
- لماذا نحتاج إلى دالة خطأ؟
- اشرح قاعدة السلسلة في الانتشار الخلفي.
- اشتق العلاقة dO = (y-t)y(1-y).
- لماذا نطرح التدرج أثناء التدريب؟
- اذكر أربعة تطبيقات للشبكات العصبية في نظم الطاقة الكهربائية.