# Neural Network Training

Neural network training is performed in the following general way:

1. Each image in the image set that is being used for training (defined in the Training Set dialog) is sampled across its full extent, using the specified Feature Size.
2. The resulting samples are provided as input to the VisionPro Deep Learning deep neural network.
3. For each sample, the neural network produces a specific response (depending on the tool type), and this response is compared with the image labeling associated with the sample's location in the training image.
4. The internal weights within the network are repeatedly adjusted as the samples are processed and reprocessed. The network training system continually adjusts the network weights with a goal of reducing the error (difference or discrepancy) between the network's response and the labeling provided by the user.
5. This overall process is repeated many times, until every sample from every training image has been included at least the number of times specified by he Epoch Count parameter.

1 | The sampling region.
2 | The user-drawn, labeled defect region.
3 | The neural network.
4 | The response by the network.
5 | The iterative process of adjusting the weights to reduce the discrepancy (in other words, error) between the labeled defect (in yellow) and the network response (in blue).

The specific characteristics of the neural network training vary somewhat depending on the type of tool being trained.

- Blue Locate Tool Network Training

  The Blue Locate tool network is trained to locate and identify features in an image. The Blue tool labeling that you perform identifies the locations and identities of all the features of interest in the image. For a given sampling region within the image, the goal of training is for the network to correctly return the pose of any features that lie within the sampling region. If a sampling region does not include any features, then the network should produce no response for that sample.

  The goal for Blue Locate tool network training is to reduce the discrepancy between the actual feature pose and identity, as defined by your labeling of the image, and the detected pose and identity.

- Blue Read Tool Network Training

  The Blue Read tool uses the a similar approach to the Blue Locate tool, although less attention is paid to pose mismatch.

- Red Analyze Tool Focused Supervised Mode Network Training

  The Red Analyze tool in Red Focused Supervised network is trained to locate and identify defect regions within an image. The labeling that you perform for the Red Analyze tool in Supervised Mode labels all of the defect pixels in the labeled image. For a given sampling region within the image, the goal of training is for the network to correctly identify the defect pixels as defects.

  - Sampling Region and Sampling Parameter

    Red Analyze Focused Supervised samples pixels with the sampler that is tied to a sampling region defined by the users with Red Analyze Tool Supervised Mode Sampling Tool Parameters. If a sampling region does not include any defect pixels, then the network should produce no response.

  - Training with Validation

    Red Analyze Focused Supervised does not support the training with the validation scheme and so it doesn't have the validation data set nor require configuring the validation set in Tool Parameters. The purpose of adopting the validation data is to validate each trained neural network and with the results from this validation data for selecting the most performing and stable neural network with the given training set. For the details of the training with validation scheme, see Statistics

  The goal for network training of the Red Analyze tool in Supervised Mode is to reduce the spatial discrepancy between the defect labeling and the detected defects.

- Red Analyze Tool High Detail Mode & High Detail Quick Mode Network Training

  The Red Analyze tool in Red Analyze Tool – High Detail or Red Analyze Tool – High Detail Quick network is also trained to locate and identify defect regions within an image, like Red Analyze Focused Supervised. The labeling that you perform for the Red Analyze tool in High Detail and High Detail Quick labels all of the defect pixels in the labeled image.

  - Sampling Region and Sampling Parameter

    While Red Analyze Focused Supervised samples pixels with a sampling region defined by the users, Red Analyze High Detail and Red Analyze High Detail Quick samples from the entire image, so they don't have a sampling region, not requiring the sampling parameters in training.

  - Training with Validation

    Red Analyze High Detail and Red Analyze High Detail Quick shares most aspects in training (and also in processing) as they come from the same architectural origin, but Red Analyze High Detail uses validation data set to validate each trained neural network and with these validation results selects the most performing and stable neural network with the given training set while Red Analyze High Detail Quick does not. Red Analyze High Detail Quick didn't adopt the validation of neural networks in training phase to serve its built-in purpose: faster speed of training than High Detail. For the details of the training with validation scheme, see Statistics

- Red Analyze Tool (Unsupervised Mode) Network Training

  The Red Analyze tool (in Unsupervised) network is trained to locate defect regions within an image. The training image set for the Red Analyze tool in Unsupervised Mode is simply a collection of known defect-free images. The goal for training is simple – to produce a network that generates no response to any sample from the training image set.

- Green Classify Tool Network Training

  The Green Classify tool is unique among the Deep Learning tools in that it produces a single result for the entire input image. There are High Detail mode, High Detail Quick mode, and Focused mode for the Green Classify tool. The tool still collects image samples in the same way as the other tools, but the samples are pooled during processing and a single result for the entire image is produced.

  The goal for the Green Classify tool network training is to reduce the number of mismatches between labeled and detected classes.

  - Sampling Region and Sampling Parameter

    While Green Classify Focused samples pixels with a sampling region defined by the users, Green Classify High Detail and Green Classify High Detail Quick samples from the entire image, so they don't have a sampling region, not requiring the sampling parameters in training.

  - Training with Validation

    Green Classify High Detail and Green Classify High Detail Quick shares most aspects in training (and also in processing) as they come from the same architectural origin, but Green Classify High Detail uses the validation data to validate each trained neural network and with these validation results selects the most performing and stable neural network with the given training set while Green Classify High Detail Quick does not. Green Classify High Detail Quick didn't adopt the validation of neural networks in training phase to serve its built-in purpose: faster speed of training than High Detail. For the details of the training with validation scheme, see Statistics

- Controlling Network Training

  The largest single determinant that you can use to affect the network training phase is the composition of the training image set. The default behavior for all tools is to train using 50% of the images in the image set, with the images selected at random.