diff --git a/.gitignore b/.gitignore
index 75cddcbd3f621bd0a2ed9589a446c2085cdd5d2e..aedc08cb4d975643576fe2f448d72055e4e2e6be 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,5 @@
+
+# _data_
 /data
 
 # Environments
@@ -6,3 +8,7 @@
 env/
 venv/
 ENV/
+
+# _pycache_
+
+/__pycache__
\ No newline at end of file
diff --git a/README.md b/README.md
index 25d1a7c89b62650f3bd5a67906e90e3144568c00..40355ae20dd8dec8bee78bc30951a0d9f6217207 100644
--- a/README.md
+++ b/README.md
@@ -1,92 +1,108 @@
 # Image classification
 
+### Résumé du Code de Manipulation des Données CIFAR-10
 
+Le code est dédié à la manipulation des données du jeu de données CIFAR-10, effectuant des opérations de lecture, de séparation des ensembles de données, et de chargement.
 
-## Getting started
+#### Composants principaux :
+1. **`unpickle(file)` :** Cette fonction lit un fichier binaire au format CIFAR-10 et le charge dans un dictionnaire via la bibliothèque `pickle`.
 
-To make it easy for you to get started with GitLab, here's a list of recommended next steps.
+2. **`read_cifar_batch(file)` :** Charge un batch spécifique de données CIFAR-10 en extrayant les données et les étiquettes du fichier.
 
-Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
+3. **`read_cifar(path)` :** Lecture de l'ensemble des données CIFAR-10. Cette fonction parcourt tous les batchs disponibles et concatène les données et les étiquettes en un seul jeu de données et d'étiquettes.
 
-## Add your files
+4. **`split_dataset(data, labels, split)` :** Divise l'ensemble de données et les étiquettes en ensembles de données d'entraînement et de test. Les données sont divisées en pourcentage spécifié avec un mélange aléatoire.
 
-- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
-- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
+#### Fonctionnalités :
+- Lecture des fichiers CIFAR-10 depuis le disque.
+- Organisation des données lues en ensembles d'entraînement et de test, tout en conservant la correspondance entre données et étiquettes.
+- Fonctionnalité de division des données en un ensemble d'entraînement et un ensemble de test selon un pourcentage spécifié.
 
-```
-cd existing_repo
-git remote add origin https://gitlab.ec-lyon.fr/tchellal/image-classification.git
-git branch -M main
-git push -uf origin main
-```
+Ces fonctions offrent des fonctionnalités essentielles pour charger, traiter et diviser les données CIFAR-10 en ensembles d'entraînement et de test, ce qui est fondamental pour l'apprentissage des modèles sur ce jeu de données.
 
-## Integrate with your tools
 
-- [ ] [Set up project integrations](https://gitlab.ec-lyon.fr/tchellal/image-classification/-/settings/integrations)
+### Résumé du code K-NN
 
-## Collaborate with your team
+Le code fournit une implémentation de l'algorithme k-NN (k-Nearest Neighbors) pour la classification.
 
-- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
-- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
-- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
-- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
-- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
+#### Composants principaux :
+1. **`distance_matrix(train, test)` :** Cette fonction calcule la matrice des distances entre les ensembles d'entraînement (`train`) et de test (`test`). Utilise la racine de la somme des carrés des différences entre les vecteurs.
+   
+2. **`mode(x)` :** La fonction détermine le mode d'un ensemble `x`, c'est-à-dire la valeur la plus fréquente.
 
-## Test and Deploy
+3. **`knn_predict(dists, labels_train, k)` :** Basé sur la matrice de distances, cette fonction prédit les étiquettes pour les données de test en utilisant k voisins les plus proches.
 
-Use the built-in continuous integration in GitLab.
+4. **`evaluate_knn(data_train, labels_train, data_test, labels_test, k)` :** Évalue l'algorithme k-NN pour une valeur de `k` donnée, calculant la précision (accuracy) de la prédiction.
 
-- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
-- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
-- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
-- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
-- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
+5. **`evaluate_knn_for_k(data_train, labels_train, data_test, labels_test, k_max)` :** Évalue l'algorithme k-NN pour une plage de valeurs de `k` (de 1 à `k_max`). Retourne une liste de précisions pour chaque `k`.
 
-***
+6. **`plot_accuracy_versus_k(accuracies)` :** Trace un graphique illustrant la variation de la précision en fonction de la valeur de `k` dans l'algorithme k-NN. Les résultats sont enregistrés sous forme d'image.
 
-# Editing this README
+Ces fonctions permettent de calculer la précision de l'algorithme k-NN pour différents k, puis de visualiser graphiquement la variation de la précision en fonction de k.
 
-When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
 
-## Suggestions for a good README
-Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
+### Backpropagation in a Neural Network
 
-## Name
-Choose a self-explaining name for your project.
+#### Partial Derivatives with Chain Rule
 
-## Description
-Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
+1. **\(\frac{\partial C}{\partial A^{(2)}}\)**:
+   \(\frac{\partial C}{\partial A^{(2)}} = \frac{2}{N_{out}}(\hat{Y} - Y)\)
 
-## Badges
-On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
+2. **\(\frac{\partial C}{\partial Z^{(2)}}\)**:
+   \(\frac{\partial C}{\partial Z^{(2)}} = \frac{2}{N_{out}}(\hat{Y} - Y) \cdot \sigma(Z^{(2)}) \cdot (1 - \sigma(Z^{(2)}))\)
 
-## Visuals
-Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
+3. **\(\frac{\partial C}{\partial W^{(2)}}\)**:
+   \(\frac{\partial C}{\partial W^{(2)}} = \frac{\partial C}{\partial Z^{(2)}} \cdot A^{(1)T}\)
 
-## Installation
-Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
+4. **\(\frac{\partial C}{\partial B^{(2)}}\)**:
+   \(\frac{\partial C}{\partial B^{(2)}} = \frac{\partial C}{\partial Z^{(2)}}\)
 
-## Usage
-Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
+5. **\(\frac{\partial C}{\partial A^{(1)}}\)**:
+   \(\frac{\partial C}{\partial A^{(1)}} = (W^{(2)T} \cdot \frac{\partial C}{\partial Z^{(2)}})\)
 
-## Support
-Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
+6. **\(\frac{\partial C}{\partial Z^{(1)}}\)**:
+   \(\frac{\partial C}{\partial Z^{(1)}} = \frac{\partial C}{\partial A^{(1)}} \cdot \sigma'(Z^{(1)})\)
 
-## Roadmap
-If you have ideas for releases in the future, it is a good idea to list them in the README.
+7. **\(\frac{\partial C}{\partial W^{(1)}}\)**:
+   \(\frac{\partial C}{\partial W^{(1)}} = \frac{\partial C}{\partial Z^{(1)}} \cdot A^{(0)T}\)
 
-## Contributing
-State if you are open to contributions and what your requirements are for accepting them.
+8. **\(\frac{\partial C}{\partial B^{(1)}}\)**:
+   \(\frac{\partial C}{\partial B^{(1)}} = \frac{\partial C}{\partial Z^{(1)}\)
 
-For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
 
-You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
+# Neural Network Training and Testing Overview
 
-## Authors and acknowledgment
-Show your appreciation to those who have contributed to the project.
+Ce code Python implémente un réseau de neurones multicouches (MLP) pour l'apprentissage supervisé. Il utilise des fonctions pour l'entraînement, le test, la prédiction et la visualisation des performances du réseau.
 
-## License
-For open source projects, say how it is licensed.
+## Principales Fonctions :
 
-## Project status
-If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
+### `learn_once_mse`
+- Calcule l'erreur quadratique moyenne (MSE) et effectue une étape de descente de gradient.
+
+### `learn_once_cross_entropy`
+- Calcule la perte d'entropie croisée et effectue une étape de descente de gradient avec la fonction softmax pour la sortie.
+
+### `predict_mlp`
+- Prédit les étiquettes pour les données en utilisant le réseau entraîné.
+
+### `train_mlp`
+- Entraîne le MLP pendant un nombre spécifié d'époques en utilisant la fonction `learn_once_cross_entropy`. Affiche les pertes et les précisions d'entraînement à chaque époque.
+
+### `test_mlp`
+- Évalue les performances du MLP sur un ensemble de test.
+
+### `run_mlp_training`
+- Orchestre le processus d'entraînement et de test du MLP avec des paramètres spécifiques.
+
+### `plot_accuracy_versus_epoch`
+- Trace et sauvegarde un graphique montrant l'évolution de la précision sur les époques.
+
+## Utilisation :
+1. Initialisation aléatoire des poids et des biais du réseau.
+2. Entraînement du réseau sur les données d'entraînement.
+3. Évaluation des performances du réseau sur les données de test.
+4. Visualisation de la précision du réseau sur les époques.
+
+Le code utilise les bibliothèques `numpy` pour les calculs matriciels, `matplotlib` pour la visualisation et `time` pour mesurer le temps d'exécution.
+
+--- 
\ No newline at end of file
diff --git a/main.py b/main.py
index 6ac5b55542b3f6b1833953cfd8e75f5325e08da2..d817efb37c42c020c3c9834ead1fb040eef8a358 100644
--- a/main.py
+++ b/main.py
@@ -1,7 +1,7 @@
 from read_cifar import read_cifar, split_dataset
 from knn import evaluate_knn_for_k, plot_accuracy_versus_k
 import matplotlib.pyplot as plt
-from mlp import run_mlp_training, plot_accuracy_versus_epoch
+from mlp2 import run_mlp_training, plot_accuracy_versus_epoch
 
 
 
@@ -38,11 +38,12 @@ if __name__=="__main__":
     split_factor = 0.9
     data, labels = read_cifar("data\cifar-10-batches-py")
     data_train, labels_train, data_test, labels_test = split_dataset(data, labels, split=split_factor)
+    # print(len(data_test), len(data_train))
     data_train, data_test = data_train/255.0, data_test/255.0 # normalize ou data
     d_h = 64
     lr = 0.1
     num_epoch=100
-    accuracies, losses = run_mlp_training(data_train, labels_train, data_test,
+    accuracies, _ = run_mlp_training(data_train, labels_train, data_test,
                                                        labels_test, d_h, lr, num_epoch)
     # accuracies = [0.08788888888888889, 0.08990740740740741, 0.09135185185185185, 0.09296296296296297, 0.09514814814814815, 0.09631481481481481, 0.09724074074074074, 0.09787037037037037, 0.09820370370370371, 0.09883333333333333, 0.09844444444444445, 0.09859259259259259, 0.09857407407407408, 0.09885185185185186, 0.09872222222222223, 0.09855555555555555, 0.09872222222222223, 0.09883333333333333, 0.0989074074074074, 0.09881481481481481, 0.0987962962962963, 0.09898148148148148, 0.09916666666666667, 0.09938888888888889, 0.09961111111111111, 0.09975925925925926, 0.09975925925925926, 0.1, 0.10003703703703704, 0.09998148148148148, 0.10007407407407408, 0.10011111111111111, 0.10001851851851852, 0.10014814814814815, 0.10012962962962962, 0.09998148148148148, 0.1000925925925926, 0.1000925925925926, 0.10007407407407408, 0.10005555555555555, 0.10014814814814815, 0.10018518518518518, 0.1002037037037037, 0.10018518518518518, 0.10016666666666667, 0.10011111111111111, 0.10016666666666667, 0.10012962962962962, 0.10007407407407408, 0.10005555555555555, 0.1, 0.1, 0.1, 0.1, 0.1, 0.09998148148148148, 0.09998148148148148, 0.09996296296296296, 0.09996296296296296, 0.09996296296296296, 0.09994444444444445, 0.09994444444444445, 0.09994444444444445, 0.0999074074074074, 0.09994444444444445, 0.09996296296296296, 0.09996296296296296, 0.09996296296296296, 0.09998148148148148, 0.09996296296296296, 0.09998148148148148, 0.1, 0.1, 0.10003703703703704, 0.10003703703703704, 0.10005555555555555, 0.10007407407407408, 0.10007407407407408, 0.10007407407407408, 0.10003703703703704, 0.10001851851851852, 0.10003703703703704, 0.10003703703703704, 0.10003703703703704, 0.10001851851851852, 0.10001851851851852, 0.10003703703703704, 0.10003703703703704, 0.10005555555555555, 0.10007407407407408, 0.10007407407407408, 0.10007407407407408, 0.10007407407407408, 0.10005555555555555, 0.10005555555555555, 0.10005555555555555, 0.10007407407407408, 0.10007407407407408, 0.10007407407407408, 0.10007407407407408]
     # print(accuracies)
diff --git a/mlp.py b/mlp.py
index 6a2fc13b36d57171aeed1f3dd9f38eb301d7005d..5a3187de1b76b4950dfcfa84a58b9a34b89a29a4 100644
--- a/mlp.py
+++ b/mlp.py
@@ -4,50 +4,52 @@ import time
 
 
 def learn_once_mse(w1, b1, w2, b2, data, targets, lr):
-    # Forward pass
-    a0 = data  # Input of the first layer
-    z1 = np.matmul(a0, w1) + b1  # Input of the hidden layer
-    a1 = 1 / (1 + np.exp(-z1))  # Output of the hidden layer (sigmoid activation)
-    z2 = np.matmul(a1, w2) + b2  # Input of the output layer
-    a2 = 1 / (1 + np.exp(-z2))  # Output of the output layer (sigmoid activation)
-    predictions = a2  # Predicted values are the outputs of the output layer
-    # Compute loss (MSE)
+    # Passage en avant (Forward pass)
+    a0 = data  # Entrée de la première couche (Input of the first layer)
+    z1 = np.matmul(a0, w1) + b1  # Entrée de la couche cachée (Input of the hidden layer)
+    a1 = 1 / (1 + np.exp(-z1))  # Sortie de la couche cachée (Output of the hidden layer) - Activation sigmoïde
+    z2 = np.matmul(a1, w2) + b2  # Entrée de la couche de sortie (Input of the output layer)
+    a2 = 1 / (1 + np.exp(-z2))  # Sortie de la couche de sortie (Output of the output layer) - Activation sigmoïde
+    predictions = a2  # Les valeurs prédites sont les sorties de la couche de sortie
+    # Calcul de la perte (Mean Squared Error - MSE)
     loss = np.mean(np.square(predictions - targets))
-    # Compute gradients
+    # Calcul des gradients
     delta2 = predictions - targets
-    delta1 = np.dot(delta2, w2.T) * a1 * (1 - a1)  # Gradient for the hidden layer
-    # Update weights and biases using gradients
+    delta1 = np.dot(delta2, w2.T) * a1 * (1 - a1)  # Gradient pour la couche cachée
+    # Mise à jour des poids et des biais en utilisant les gradients
     w2 -= lr * np.dot(a1.T, delta2) / len(data)
     b2 -= lr * np.sum(delta2, axis=0) / len(data)
     w1 -= lr * np.dot(a0.T, delta1) / len(data)
     b1 -= lr * np.sum(delta1, axis=0) / len(data)
-    return w1, b1, w2, b2, loss
+    return w1, b1, w2, b2, loss  # Renvoie les poids, les biais et la perte
 
 
 def one_hot(x):
     n_classes = 10
     return np.eye(n_classes)[x]
+    # Convertit les étiquettes en représentation one-hot pour un nombre de classes donné
 
 
 def softmax(x):
     e_x = np.exp(x - np.max(x))
     return e_x / e_x.sum()
+    # Applique la fonction softmax aux scores de sortie du réseau pour obtenir des probabilités
 
 
 def learn_once_cross_entropy(w1, b1, w2, b2, data, targets, learning_rate):
     N = data.shape[0]
-    # Forward pass
-    a0 = data                       # the data are the input of the first layer
-    z1 = np.matmul(a0, w1) + b1     # input of the hidden layer
-    a1 = 1 / (1 + np.exp(-z1))      # output of the hidden layer (sigmoid activation function)
-    z2 = np.matmul(a1, w2) + b2     # input of the output layer
-    a2 = softmax(z2)                # output of the output layer (softmax activation function)
-    predictions = a2                # the predicted values are the outputs of the output layer
-    # One-hot encode the targets
+    # Passage en avant (Forward pass)
+    a0 = data                       # les données sont l'entrée de la première couche
+    z1 = np.matmul(a0, w1) + b1     # entrée de la couche cachée
+    a1 = 1 / (1 + np.exp(-z1))      # sortie de la couche cachée (fonction d'activation sigmoïde)
+    z2 = np.matmul(a1, w2) + b2     # entrée de la couche de sortie
+    a2 = softmax(z2)                # sortie de la couche de sortie (fonction d'activation softmax)
+    predictions = a2                # les valeurs prédites sont les sorties de la couche de sortie
+    # Encodage one-hot des cibles
     oh_targets = one_hot(targets)
-    # Compute the Cross-Entropy loss
+    # Calcul de la perte Cross-Entropy
     loss = - np.sum(oh_targets * np.log(predictions + 1e-9)) / N
-    # Backward pass
+    # Rétro-propagation (Backward pass)
     dz2 = predictions - oh_targets
     dw2 = np.dot(a1.T, dz2) / N
     db2 = np.sum(dz2, axis=0, keepdims=True) / N  
@@ -55,59 +57,61 @@ def learn_once_cross_entropy(w1, b1, w2, b2, data, targets, learning_rate):
     dz1 = da1 * a1 * (1 - a1)
     dw1 = np.dot(a0.T, dz1) / N
     db1 = np.sum(dz1, axis=0, keepdims=True) / N
-    # One step of gradient descent
+    # Une étape de descente de gradient
     w1 -= learning_rate * dw1
     w2 -= learning_rate * dw2
     b1 -= learning_rate * db1
     b2 -= learning_rate * db2
-    return w1, b1, w2, b2, loss
+    return w1, b1, w2, b2, loss  # Renvoie les poids, les biais et la perte
 
 
 def predict_mlp(w1, b1, w2, b2, data):
-    # Forward pass
-    a0 = data                    # the data are the input of the first layer
-    z1 = np.matmul(a0, w1) + b1  # input of the hidden layer
-    a1 = 1 / (1 + np.exp(-z1))   # output of the hidden layer (sigmoid activation function)
-    z2 = np.matmul(a1, w2) + b2  # input of the output layer
-    a2 = softmax(z2)             # output of the output layer (softmax activation function)
+    # Passage en avant (Forward pass)
+    a0 = data                    # les données sont l'entrée de la première couche
+    z1 = np.matmul(a0, w1) + b1  # entrée de la couche cachée
+    a1 = 1 / (1 + np.exp(-z1))   # sortie de la couche cachée (fonction d'activation sigmoïde)
+    z2 = np.matmul(a1, w2) + b2  # entrée de la couche de sortie
+    a2 = softmax(z2)             # sortie de la couche de sortie (fonction d'activation softmax)
     predictions = np.argmax(a2, axis=1)
     return predictions
 
 
 def train_mlp(w1, b1, w2, b2, data_train, labels_train, learning_rate, num_epoch):
-    # perform num_epoch of training steps
+    # effectue num_epoch d'itérations d'entraînement
     losses = []
     train_accuracies = [0] * num_epoch
     for epoch in range(num_epoch):
+        # Effectue une étape d'apprentissage avec la fonction de perte Cross-Entropy
         w1, b1, w2, b2, loss = learn_once_cross_entropy(w1, b1, w2, b2, data_train, labels_train, learning_rate)
         losses.append(loss)
+        # Prédit les étiquettes pour les données d'entraînement
         labels_pred = predict_mlp(w1, b1, w2, b2, data_train)
-        accuracy = np.mean(labels_pred == labels_train)
+        accuracy = np.mean(labels_pred == labels_train)  # Calcule l'exactitude des prédictions
         train_accuracies[epoch] = accuracy
         print(f"Epoch loss [{epoch+1}/{num_epoch}] : {loss} --- accuracy : {accuracy}")
-        # Update weights and biases for the next iteration
-        # Pass the updated parameters to the next iteration
+        # Met à jour les poids et les biais pour l'itération suivante
+        # Passe les paramètres mis à jour à l'itération suivante
     return w1, b1, w2, b2, train_accuracies
 
 
 def test_mlp(w1, b1, w2, b2, data_test, labels_test):
-    #testing the network on the test set 
-    labels_pred = predict_mlp(w1, b1, w2, b2, data_test)
-    test_accuracy = np.mean(labels_pred == labels_test)
+    # teste le réseau sur l'ensemble de données de test
+    labels_pred = predict_mlp(w1, b1, w2, b2, data_test)  # Prédiction des étiquettes pour les données de test
+    test_accuracy = np.mean(labels_pred == labels_test)  # Calcul de la précision des prédictions
     return test_accuracy
 
 
 def run_mlp_training(data_train, labels_train, data_test, labels_test, d_h, lr, num_epoch):
-    """Train an MLP with given parameters."""
+    """Entraîne un MLP avec les paramètres donnés."""
     print("Starting Training...")
     tic = time.time()
-    d_in = data_train.shape[1]
-    d_out = len(set(labels_train))
-    # Random initialization of the network weights and biaises
-    w1 = 2 * np.random.rand(d_in, d_h) - 1  # first layer weights
-    b1 = np.zeros((1, d_h))                 # first layer biaises
-    w2 = 2 * np.random.rand(d_h, d_out) - 1 # second layer weights
-    b2 = np.zeros((1, d_out))               # second layer biaises
+    d_in = data_train.shape[1]  # Type d'entrée : tableau de données d'entraînement (nombre de colonnes)
+    d_out = len(set(labels_train))  # Type de sortie : nombre d'étiquettes uniques dans les données d'entraînement
+    # Initialisation aléatoire des poids et des biais du réseau
+    w1 = 2 * np.random.rand(d_in, d_h) - 1  # Poids de la première couche
+    b1 = np.zeros((1, d_h))  # Biais de la première couche
+    w2 = 2 * np.random.rand(d_h, d_out) - 1  # Poids de la deuxième couche
+    b2 = np.zeros((1, d_out))  # Biais de la deuxième couche
     w1, b1, w2, b2, accuracies = train_mlp(w1, b1, w2, b2, data_train, labels_train, lr, num_epoch)
     toc = time.time()
     print("Finished Training.")
@@ -128,4 +132,4 @@ def plot_accuracy_versus_epoch(accuracies):
     plt.xlabel("Epochs")
     plt.ylabel("Accuracy")
     plt.grid(axis='both', which='both')
-    plt.savefig('./results/mlp.png')
+    plt.savefig('./results/mlp1.png')
diff --git a/read_cifar.py b/read_cifar.py
index 90fadea026b1b669da0f43ed49557a6378f0ec78..3d49d26ac2a0eeb383f46469668ae7474111278d 100644
--- a/read_cifar.py
+++ b/read_cifar.py
@@ -1,5 +1,6 @@
 import numpy as np
 import os
+from sklearn.model_selection import train_test_split
 
 
 def unpickle(file):
@@ -33,11 +34,12 @@ def read_cifar(path):
     return DATA, LABELS
 
 
-def split_dataset(data, labels, split=0.6):
+def split_dataset(data, labels, split):
     print(f"Splitting data into train/test with split={split}")
     n = data.shape[0]
     indices = np.random.permutation(n)
     train_idx, test_idx = indices[:int(split*n)], indices[int(split*n):]
     data_train, data_test = data[train_idx,:].astype(np.float32), data[test_idx,:].astype(np.float32)
     labels_train, labels_test = labels[train_idx].astype(np.int64), labels[test_idx].astype(np.int64)
+    # data_train, data_test, labels_train, labels_test = train_test_split(data, labels,test_size=split, shuffle= True)
     return data_train, labels_train, data_test, labels_test 
\ No newline at end of file