Skip to content

Commit

Permalink
BK fix seppo spellings
Browse files Browse the repository at this point in the history
  • Loading branch information
erinmgraham committed Feb 9, 2024
1 parent 808a7ce commit 505ed5c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
20 changes: 10 additions & 10 deletions episodes/02-image-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Before we learn about some of these tasks in more detail, we need to understand

### Pixels

It is important to realise that images are stored as rectangular arrays of hundreds, thousands, or millions of discrete "picture elements," otherwise known as pixels. Each pixel can be thought of as a single square point of colored light.
It is important to realise that images are stored as rectangular arrays of hundreds, thousands, or millions of discrete "picture elements," otherwise known as pixels. Each pixel can be thought of as a single square point of coloured light.

For example, consider this image of a Jabiru, with a square area designated by a red box:

Expand All @@ -112,11 +112,11 @@ Now, if we zoomed in close enough to the red box, the individual pixels would st

![](fig/02_Jabiru_TGS_marked_zoom_enlarged.jpg){alt='zoomed in area of Jabiru where the individual pixels stand out'}

Note each square in the enlarged image area (i.e. each pixel) is all one color, but each pixel can be a different color from its neighbors. Viewed from a distance, these pixels seem to blend together to form the image.
Note each square in the enlarged image area (i.e. each pixel) is all one colour, but each pixel can be a different colour from its neighbours. Viewed from a distance, these pixels seem to blend together to form the image.

### Working with Pixels

As noted, in practice, real world images will typically be made up of a vast number of pixels, and each of these pixels will be one of potentially millions of colors. In python, an image can be represented as a multidimensional array, also known as a `tensor`, where each element in the array corresponds to a pixel value in the image. In the context of images, these arrays often have dimensions for height, width, and color channels (if applicable).
As noted, in practice, real world images will typically be made up of a vast number of pixels, and each of these pixels will be one of potentially millions of colours. In python, an image can be represented as a multidimensional array, also known as a `tensor`, where each element in the array corresponds to a pixel value in the image. In the context of images, these arrays often have dimensions for height, width, and colour channels (if applicable).

::::::::::::::::::::::::::::::::::::::::: callout

Expand All @@ -139,7 +139,7 @@ Two of the most commonly used libraries for image representation and manipulatio
- `from PIL import Image`
- [PIL Image Module] documentation

- TensorFlow images are often represented as tensors that have dimensions for batch size, height, width, and color channels. This framework provide tools to load, preprocess, and work with image data seamlessly.
- TensorFlow images are often represented as tensors that have dimensions for batch size, height, width, and colour channels. This framework provide tools to load, preprocess, and work with image data seamlessly.
- `from tensorflow import keras`
- [image preprocessing] documentation
- Note Keras image functions also use PIL
Expand Down Expand Up @@ -168,7 +168,7 @@ The new image is of type : <class 'PIL.JpegImagePlugin.JpegImageFile'> and has t

### Image Dimensions - Resizing

The new image has shape `(573, 552, 3)`, meaning it is much larger in size, 573x552 pixels; a rectangle instead of a square; and consists of three color channels (RGB).
The new image has shape `(573, 552, 3)`, meaning it is much larger in size, 573x552 pixels; a rectangle instead of a square; and consists of three colour channels (RGB).

Recall from the introduction that our training data set consists of 50000 images of 32x32 pixels and three channels.

Expand Down Expand Up @@ -203,7 +203,7 @@ Normalizing the RGB values to be between 0 and 1 is a common pre-processing step

2. **Faster Convergence**: Normalizing the RGB values often helps in faster convergence during the training process. Neural networks and other optimization algorithms rely on gradient descent techniques, and having inputs in a consistent range aids in smoother and faster convergence.

3. **Equal Weightage for All Channels**: In RGB images, each channel (Red, Green, Blue) represents different color intensities. By normalizing to the range [0, 1], you ensure that each channel is treated with equal weightage during training. This is important because some machine learning algorithms could assign more importance to larger values.
3. **Equal Weightage for All Channels**: In RGB images, each channel (Red, Green, Blue) represents different colour intensities. By normalizing to the range [0, 1], you ensure that each channel is treated with equal weightage during training. This is important because some machine learning algorithms could assign more importance to larger values.

4. **Generalization**: Normalization helps the model to generalize better to unseen data. When the input features are in the same range, the learned weights and biases can be more effectively applied to new examples, making the model more robust.

Expand Down Expand Up @@ -257,11 +257,11 @@ A neural network can only take numerical inputs and outputs, and learns by calcu

One-hot encoding is a technique to represent categorical data as binary vectors, making it compatible with machine learning algorithms. Each category becomes a separate feature, and the presence or absence of a category is indicated by 1s and 0s in the respective columns.

Let's say you have a dataset with a "Color" column containing three categories: Red, Blue, Green.
Let's say you have a dataset with a "colour" column containing three categories: Red, Blue, Green.

Table 1. Original Data.

| color | |
| colour | |
| ------ | --------------: |
| red | :red_square: |
| green | :green_square: |
Expand All @@ -270,7 +270,7 @@ Table 1. Original Data.

Table 2. After One-Hot Encoding.

| Color_red | Color_blue | Color_green |
| colour_red | colour_blue | colour_green |
| ------ | :------: | ------: |
| 1 | 0 | 0 |
| 0 | 1 | 0 |
Expand Down Expand Up @@ -329,7 +329,7 @@ There are several ways to augment your data to increase the diversity of the tra
- rotation, translation, scaling, zooming, cropping
- Flipping or Mirroring
- some classes, like horse, have a different shape when facing left or right and you want your model to recognize both
- Color properties
- colour properties
- brightness, contrast, or hue
- these changes simulate variations in lighting conditions

Expand Down
6 changes: 3 additions & 3 deletions episodes/03-build-cnn.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,13 @@ A **convolution matrix**, or **kernel**, is a matrix transformation that we 'sli
[0, 0, 0]
[1, 1, 1]]
```
This kernel will give a high value to a pixel if it is on a horizontal border between dark and light areas. Note for RGB images, the kernel should also have a depth of 3, one for each color channel.
This kernel will give a high value to a pixel if it is on a horizontal border between dark and light areas. Note for RGB images, the kernel should also have a depth of 3, one for each colour channel.

In the following image, the effect of such a kernel on the values of a single-channel image stands out. The red cell in the output matrix is the result of multiplying and summing the values of the red square in the input, and the kernel. Applying this kernel to a real image demonstrates it does indeed detect horizontal edges.

![](fig/03_conv_matrix.png){alt='6x5 input matrix representing a single color channel image being multipled by a 3x3 kernel to produce a 4x4 output matrix to detect horizonal edges in an image '}
![](fig/03_conv_matrix.png){alt='6x5 input matrix representing a single colour channel image being multipled by a 3x3 kernel to produce a 4x4 output matrix to detect horizonal edges in an image '}

![](fig/03_conv_image.png){alt='single color channel image of a cat multiplied by a 3x3 kernel to produce an image of a cat where the edges stand out'}
![](fig/03_conv_image.png){alt='single colour channel image of a cat multiplied by a 3x3 kernel to produce an image of a cat where the edges stand out'}

Within our convolutional layer, the hidden units comprise multiple convolutional matrices, also known as kernels. The matrix values, serving as weights, are learned during the training process. The convolutional layer produces an 'image' for each kernel, representing the output derived by applying the kernel to each pixel.

Expand Down
2 changes: 1 addition & 1 deletion episodes/05-evaluate-predict-cnn.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ sns.heatmap(confusion_df, annot=True, fmt='3g')
- The `annot=True` parameter here will put the numbers from the confusion matrix in the heatmap.
- The `fmt=3g` will display the values with three significant digits.

![](fig/05_pred_v_true_confusion_matrix.png){alt='Confusion matrix of model predictions where the color scale goes from black to light to represent values from 0 to the total number of test observations in our test set of 1000. The diagonal has much lighter colors, indicating our model is predicting well, but a few non-diagonal cells also have a lighter color to indicate where the model is making a large number of prediction errors.'}
![](fig/05_pred_v_true_confusion_matrix.png){alt='Confusion matrix of model predictions where the colour scale goes from black to light to represent values from 0 to the total number of test observations in our test set of 1000. The diagonal has much lighter colours, indicating our model is predicting well, but a few non-diagonal cells also have a lighter colour to indicate where the model is making a large number of prediction errors.'}


::::::::::::::::::::::::::::::::::::: challenge
Expand Down

0 comments on commit 505ed5c

Please sign in to comment.