Skip to content

Commit 977e708

Browse files
[EXTERNAL] docs(keras2): use categorical_crossentropy for single-label multi-class (#3048)
* [EXTERNAL] fix(numpy): clarify that CSV header is excluded when loading data ### Fix ambiguous instruction about row indexing #### What changed The sentence: > "Load the data using genfromtxt, specifying the delimiter as ';', and optimize the numpy array size by reducing the data types. Use np.float32 and verify that the resulting numpy array weighs 76800 bytes." was unclear about whether the CSV header should be skipped or not. It now says: > "Load the data using genfromtxt, specifying the delimiter as ';' with excluding the headers, and optimize the numpy array size by reducing the data types. Use np.float32 and verify that the resulting numpy array weighs 76800 bytes." #### Why Later instructions refer to specific row numbers (like the 2nd, 7th, and 12th rows). Without stating whether the header counts as a row, the meaning is ambiguous — it affects the indexing. This fix makes it clear that the header should be excluded. #### No code changes This is a documentation fix only. * docs(keras2): use categorical_crossentropy for single-label multi-class in Exercise 4 ## Summary Docs-only fix in **Keras 2 → Exercise 4 (Multi-class classification – Optimize)**: Replace the incorrect mention of `binary_crossentropy` with the correct `categorical_crossentropy` for **single-label multi-class** classification. ## Why `binary_crossentropy` is intended for **binary** or **multi-label** tasks. For **single-label multi-class** with a softmax output, the appropriate loss is **`categorical_crossentropy`**. This correction prevents learner confusion and aligns the subject with standard Keras practice. ## Scope of Change * **Updated text** in Exercise 4 to say `categorical_crossentropy` instead of `binary_crossentropy`. * Update README.md --------- Co-authored-by: Abdelhak ELYakoubi <87140828+EldritchGriffin@users.noreply.github.com>
1 parent 5742b16 commit 977e708

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

subjects/ai/keras-2/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ Let us assume we want to classify images and we know they contain either apples,
136136

137137
### Exercise 4: Multi classification - Optimize
138138

139-
The goal of this exercise is to learn to optimize a multi-classification neural network. As learnt previously, the loss function used in binary classification is the log loss - also called in Keras `binary_crossentropy`. This function is defined for binary classification and can be extended to multi-classification. In Keras, the extended loss that supports multi-classification is `binary_crossentropy`. There's no code to run in that exercise.
139+
The goal of this exercise is to learn to optimize a multi-classification neural network. As learnt previously, the loss function used in binary classification is the log loss - also called in Keras `binary_crossentropy`. This function is defined for binary classification and can be extended to multi-classification. In Keras, the extended loss that supports multi-classification is `categorical_crossentropy`. There's no code to run in that exercise.
140140

141141
1. Fill the chunk of code below in order to optimize the neural network defined in the previous exercise. Choose the adapted loss, adam as optimizer and the accuracy as metric.
142142

subjects/ai/numpy/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ The goal of this exercise is to perform fundamental data analysis on real data u
296296

297297
The dataset chosen for this task was the [red wine dataset](./data/winequality-red.csv). You can find more info [HERE](./data/)
298298

299-
1. Load the data using `genfromtxt`, specifying the delimiter as ';', and optimize the numpy array size by reducing the data types. Use `np.float32` and verify that the resulting numpy array weighs **76800 bytes**.
299+
1. Load the data using `genfromtxt`, specifying the delimiter as ';' with excluding the headers, and optimize the numpy array size by reducing the data types. Use `np.float32` and verify that the resulting numpy array weighs **76800 bytes**.
300300

301301
2. Display the 2nd, 7th, and 12th rows as a two-dimensional array. Exclude `np.nan` values if present.
302302

0 commit comments

Comments
 (0)