בינה מאלכותית RB14-01 : קורס תרגול רשתוות נירונים

בינה מאלכותית : קורס תרגול רשתוות נירונים – למתחלים

 

ANN SINGLE INPUT SINGLE OUT PUT

pip install tensorflow  או pip install tensorflow!

  1. Imports TensorFlow and NumPy libraries.

  2. Creates a simple dataset where y = 2 * x.

  3. Builds a neural network with:

    • 1 input layer

    • 3 hidden layers (ReLU activation)

    • 1 linear output layer for regression

  4. Compiles the model using Adam optimizer and mean squared error loss.

  5. Trains the model for 200 epochs with batch size = 2.

  6. Predicts outputs for test inputs [6], [7], [8].

  7. Prints predictions for each test input.

Let me know if you want this written as comments directly inside the code.

 

 

 

 

 

מה ניתן לעשות בשביל  בשביל לשפר את הדיוק  ?

הרבה מאוד דברים וניראה במספר שלבים

  1. הוספת עוד נתונים למשל במקום 5 להוסיף 25
  2. יותר epocs
  3. learning_rate=0.001 למשל  להגדיל את הקצב או להקטין  למשל learning_rate=0.01

 

1.נוסיף נתונים  :

2.נשנה את קצב הלימוד :

 

נשמה לערך לימוד מהיר יותר קצב  לימוד מהיר  יותר

הרץ את התוכנה והראה ערכים

 

 

 


 

לומד או זוכר   ? 

(האם הבינה מלאכותית – המודל זוכרת או לומדת ) ?

 

Overfitting זה כשהמודל  זוכר  אבל  לא  לומד

דוגמה פשוטה:

אם סטודנט  שינן בעל־פה את התשובות למבחן אבל לא הבין את החומר,
אז אם ישנו טיפה את הניסוח של השאלה — הוא ייפול.
זה בדיוק מה שקורה למודל ב־Overfitting

 

Model is memorizing, not learning” means:

The model is learning to copy exact patterns from the training data instead of learning general rules that work on new data.

 

Model is memorizing, not learning” means:

The model is learning to copy exact patterns from the training data instead of learning general rules that work on new data.


🔄 Example:

You train a model on:

plaintext
X = [1, 2, 3]
y = [2, 4, 6]

If the model memorizes:

  • It will do well on [1,2,3]

  • But fail on [4] →5 AND NOT 8 –  unpredictable output

If the model learns:

  • It understands the pattern: y = 2 * x

  • So it works well on both training and new inputs like [4, 5, 6]  and predict the  val output while leaning ...close to 8 ,10 ,12  ....that show that the model is leering  and the A.I  found  the rule 


 How to detect memorizing (overfitting)?

  • Training loss is low

  • Validation loss is high or increasing

  • This means the model is "cheating" on the test by memorizing answers.


Want me to show a code example where this happens?

val does not affect training directly in a standard ANN.


✅ What actually happens:

  • Training data (X_train, y_train) is used to update the weights during each epoch.

  • Validation data (X_val, y_val) is used only to evaluate model performance after each epoch.

  • The model does not learn from validation — it's just a checkpoint to monitor overfitting or generalization.

מה ההבדל בין שינון לבין למידה אמיתית?

📌 שינון (memorizing):

המודל "זוכר בעל־פה" את הנתונים שעליהם התאמן, מבלי להבין את הדפוס הכללי לא מוצא קשר א חוקיות .

📌 למידה (learning):

המודל מבין את הקשר בין הקלט לפלט, ולכן מצליח גם על דוגמאות חדשות

כתיבת תגובה