Training a Neural Network
Learn to train a neural network with a tabular dataset.
We'll cover the following...
Classification means placing an object into one of the possible categories, referred to as classes. For example, fruits are moving on a conveyor, and we want to sort them according to their type; apples must go in one basket, and oranges must go in another basket. Deciding if an image represents one type of fruit or the other is a classification task.
In this lesson, we collected images of 1000 objects from one of two categories: Rubik’s cubes and balls. A human annotated the dataset, i.e., they assigned the label 0
for a Rubik’s cube and 1
for a ball for each image. Let’s assume that we previously wrote a computer vision program to extract two features from each image.
What are image features?
The presence of strong horizontal and vertical lines could be an attribute to differentiate the two classes (Rubik’s cube vs. ball), so an engineer would choose to detect the presence of vertical and horizontal lines. Strong linear features are an indication of a Rubik’s cube, and the absence of strong linear features is an indication of a ball. Linear features can be obtained by the average of the vertical and horizontal Sobel images. We can recall that Sobel images highlight the pixels of vertical or horizontal edges:
import cv2# ...sobelx_img = cv2.Sobel(image, ddepth=cv2.CV_32F, dx=1, dy=0)sobely_img = cv2.Sobel(image, ddepth=cv2.CV_32F, dx=0, dy=1)feature0 = cv2.mean(sobelx_img)[0]feature1 = cv2.mean(sobely_img)[0]
In lines 7 and 8, we extract the mean of the Sobel values (which are high in the presence of well-defined edges) ...