From 1140fd48bcbd951e56d8677bc3c98cd75c31c60c Mon Sep 17 00:00:00 2001 From: snoppy Date: Mon, 17 Jun 2024 10:36:36 +0800 Subject: [PATCH 1/4] chore: fix typos Signed-off-by: snoppy --- computer_vision/haralick_descriptors.py | 2 +- graphs/strongly_connected_components.py | 2 +- maths/points_are_collinear_3d.py | 2 +- neural_network/convolution_neural_network.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/computer_vision/haralick_descriptors.py b/computer_vision/haralick_descriptors.py index 712bd49668f8..634f0495797b 100644 --- a/computer_vision/haralick_descriptors.py +++ b/computer_vision/haralick_descriptors.py @@ -141,7 +141,7 @@ def transform( center_x, center_y = (x // 2 for x in kernel.shape) - # Use padded image when applying convolotion + # Use padded image when applying convolution # to not go out of bounds of the original the image transformed = np.zeros(image.shape, dtype=np.uint8) padded = np.pad(image, 1, "constant", constant_values=constant) diff --git a/graphs/strongly_connected_components.py b/graphs/strongly_connected_components.py index 325e5c1f33a3..4d4cf88035b5 100644 --- a/graphs/strongly_connected_components.py +++ b/graphs/strongly_connected_components.py @@ -38,7 +38,7 @@ def find_components( reversed_graph: dict[int, list[int]], vert: int, visited: list[bool] ) -> list[int]: """ - Use depth first search to find strongliy connected + Use depth first search to find strongly connected vertices. Now graph is reversed >>> find_components({0: [1], 1: [2], 2: [0]}, 0, 5 * [False]) [0, 1, 2] diff --git a/maths/points_are_collinear_3d.py b/maths/points_are_collinear_3d.py index 3bc0b3b9ebe5..caaa9d1e61dc 100644 --- a/maths/points_are_collinear_3d.py +++ b/maths/points_are_collinear_3d.py @@ -99,7 +99,7 @@ def are_collinear(a: Point3d, b: Point3d, c: Point3d, accuracy: int = 10) -> boo 1- Create tow vectors AB and AC. 2- Get the cross vector of the tow vectors. - 3- Calcolate the length of the cross vector. + 3- Calculate the length of the cross vector. 4- If the length is zero then the points are collinear, else they are not. The use of the accuracy parameter is explained in is_zero_vector docstring. diff --git a/neural_network/convolution_neural_network.py b/neural_network/convolution_neural_network.py index 3c551924442d..38262a59b916 100644 --- a/neural_network/convolution_neural_network.py +++ b/neural_network/convolution_neural_network.py @@ -135,7 +135,7 @@ def convolute(self, data, convs, w_convs, thre_convs, conv_step): ) data_featuremap.append(featuremap) - # expanding the data slice to One dimenssion + # expanding the data slice to One dimension focus1_list = [] for each_focus in data_focus: focus1_list.extend(self.Expand_Mat(each_focus)) From 2bf5a7201b6351da9fc665dd9ec09e9d307a6bf1 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 17 Jun 2024 08:32:54 -0400 Subject: [PATCH 2/4] Apply suggestions from code review Co-authored-by: Tianyi Zheng --- maths/points_are_collinear_3d.py | 4 ++-- neural_network/convolution_neural_network.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/maths/points_are_collinear_3d.py b/maths/points_are_collinear_3d.py index caaa9d1e61dc..7eb1d506d4be 100644 --- a/maths/points_are_collinear_3d.py +++ b/maths/points_are_collinear_3d.py @@ -97,8 +97,8 @@ def are_collinear(a: Point3d, b: Point3d, c: Point3d, accuracy: int = 10) -> boo """ Check if three points are collinear or not. - 1- Create tow vectors AB and AC. - 2- Get the cross vector of the tow vectors. + 1- Create two vectors AB and AC. + 2- Get the cross vector of the two vectors. 3- Calculate the length of the cross vector. 4- If the length is zero then the points are collinear, else they are not. diff --git a/neural_network/convolution_neural_network.py b/neural_network/convolution_neural_network.py index 38262a59b916..be0e0ea84719 100644 --- a/neural_network/convolution_neural_network.py +++ b/neural_network/convolution_neural_network.py @@ -135,7 +135,7 @@ def convolute(self, data, convs, w_convs, thre_convs, conv_step): ) data_featuremap.append(featuremap) - # expanding the data slice to One dimension + # expanding the data slice to one dimension focus1_list = [] for each_focus in data_focus: focus1_list.extend(self.Expand_Mat(each_focus)) From a97d835f99e66b76df092f0028d04d610173f1b3 Mon Sep 17 00:00:00 2001 From: Tianyi Zheng Date: Mon, 17 Jun 2024 05:56:28 -0700 Subject: [PATCH 3/4] Fix more typos in points_are_collinear_3d.py --- maths/points_are_collinear_3d.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/maths/points_are_collinear_3d.py b/maths/points_are_collinear_3d.py index 7eb1d506d4be..c7adddda9494 100644 --- a/maths/points_are_collinear_3d.py +++ b/maths/points_are_collinear_3d.py @@ -76,9 +76,9 @@ def get_3d_vectors_cross(ab: Vector3d, ac: Vector3d) -> Vector3d: def is_zero_vector(vector: Vector3d, accuracy: int) -> bool: """ - Check if vector is equal to (0, 0, 0) of not. + Check if vector is equal to (0, 0, 0) or not. - Sine the algorithm is very accurate, we will never get a zero vector, + Since the algorithm is very accurate, we will never get a zero vector, so we need to round the vector axis, because we want a result that is either True or False. In other applications, we can return a float that represents the collinearity ratio. From f5ddde1fdd45c30c473529bbab5cc3343b78189a Mon Sep 17 00:00:00 2001 From: Tianyi Zheng Date: Mon, 17 Jun 2024 05:59:27 -0700 Subject: [PATCH 4/4] Fix more typos in convolution_neural_network.py --- neural_network/convolution_neural_network.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/neural_network/convolution_neural_network.py b/neural_network/convolution_neural_network.py index be0e0ea84719..d4ac360a98de 100644 --- a/neural_network/convolution_neural_network.py +++ b/neural_network/convolution_neural_network.py @@ -1,7 +1,7 @@ """ - - - - - -- - - - - - - - - - - - - - - - - - - - - - - Name - - CNN - Convolution Neural Network For Photo Recognizing -Goal - - Recognize Handing Writing Word Photo +Goal - - Recognize Handwriting Word Photo Detail: Total 5 layers neural network * Convolution layer * Pooling layer @@ -304,7 +304,7 @@ def draw_error(): plt.grid(True, alpha=0.5) plt.show() - print("------------------Training Complished---------------------") + print("------------------Training Complete---------------------") print((" - - Training epoch: ", rp, f" - - Mse: {mse:.6f}")) if draw_e: draw_error() @@ -353,5 +353,5 @@ def convolution(self, data): if __name__ == "__main__": """ - I will put the example on other file + I will put the example in another file """