-
### Dropout Layer
Dropout is a regularization technique to prevent overfitting in neural networks by randomly setting a fraction of input units to zero at each update during training time.
- **Input Shape:** The data from the previous layer.
- **Dropout Rate:** The fraction of units to drop (e.g., 0.5 for 50% dropout).
- **Output:** The same shape as the input, with some units set to zero.
-
-
- dropout rate = 0.3
-
- 8 | 8 | 0 | 8 | 0 | 0 | 5 | 0 | 5 | 0 | 5 | 5 | 0 | 3 | 3 |
-
-
+
+
- The updated 0 values represents the dropped units.
@@ -402,9 +211,8 @@ class CNN:
# Output dimensions
conv_height = (height - filter_size[0]) // strides[0] + 1
conv_width = (width - filter_size[1]) // strides[1] + 1
-
output_matrix = np.zeros((conv_height, conv_width, channels))
-
+
# Convolution Operation
for i in range(0, height - filter_size[0] + 1, strides[0]):
for j in range(0, width - filter_size[1] + 1, strides[1]):
@@ -443,7 +251,7 @@ class CNN:
return input_matrix * dropout_mask
```
-Run the below command to generate output, based on random input and filter matrices.
+Run the below command to generate output with random input and filter matrices, depending on the given size.
```python
input_shape = (5, 5)
@@ -470,4 +278,4 @@ dropout_output = cnn_model.dropout(flattened_output, dropout_rate=0.3)
print("\nDropout Output:\n", dropout_output)
```
-Feel free to play around with the parameters!
+Feel free to play around with the parameters!
\ No newline at end of file
diff --git a/contrib/machine-learning/assets/cnn-dropout.png b/contrib/machine-learning/assets/cnn-dropout.png
new file mode 100644
index 0000000..9cb18f9
Binary files /dev/null and b/contrib/machine-learning/assets/cnn-dropout.png differ
diff --git a/contrib/machine-learning/assets/cnn-filters.png b/contrib/machine-learning/assets/cnn-filters.png
new file mode 100644
index 0000000..463ca60
Binary files /dev/null and b/contrib/machine-learning/assets/cnn-filters.png differ
diff --git a/contrib/machine-learning/assets/cnn-flattened.png b/contrib/machine-learning/assets/cnn-flattened.png
new file mode 100644
index 0000000..2d1ca6f
Binary files /dev/null and b/contrib/machine-learning/assets/cnn-flattened.png differ
diff --git a/contrib/machine-learning/assets/cnn-input_shape.png b/contrib/machine-learning/assets/cnn-input_shape.png
new file mode 100644
index 0000000..34379f1
Binary files /dev/null and b/contrib/machine-learning/assets/cnn-input_shape.png differ
diff --git a/contrib/machine-learning/assets/cnn-ouputs.png b/contrib/machine-learning/assets/cnn-ouputs.png
new file mode 100644
index 0000000..2797226
Binary files /dev/null and b/contrib/machine-learning/assets/cnn-ouputs.png differ
diff --git a/contrib/machine-learning/assets/cnn-padding.png b/contrib/machine-learning/assets/cnn-padding.png
new file mode 100644
index 0000000..a441b2b
Binary files /dev/null and b/contrib/machine-learning/assets/cnn-padding.png differ
diff --git a/contrib/machine-learning/assets/cnn-pooling.png b/contrib/machine-learning/assets/cnn-pooling.png
new file mode 100644
index 0000000..c3ada5c
Binary files /dev/null and b/contrib/machine-learning/assets/cnn-pooling.png differ
diff --git a/contrib/machine-learning/assets/cnn-strides.png b/contrib/machine-learning/assets/cnn-strides.png
new file mode 100644
index 0000000..26339a9
Binary files /dev/null and b/contrib/machine-learning/assets/cnn-strides.png differ