What is the image normalization procedure for trainNetwork?

1 vue (au cours des 30 derniers jours)
Louis Vaickus
Louis Vaickus le 4 Mai 2018
Commenté : Louis Vaickus le 2 Fév 2021
I'm attempting to train a semantic segmentation network (vgg19) on 1.4x10^6 images and the 'initializing image normalization' phase has been ongoing for 12 hours and counting.
This seems unreasonably long (at 12 hours the processing rate would be 32 images / second).
Prior to this step I ran a script which queried every pixel value in every image and created a new categorical uint8 image at 500 images / second.
1. Why is this part of the process so slow?
2. What is the normalization procedure? (so I can normalize prior to running trainNetwork).
3. Having done #2, how can I skip the image normalization step in trainNetwork?
Thanks!
System: Ubuntu 18.04, Matlab 2018a, i7-6950x, 128GB RAM, 3X Titan V.
  2 commentaires
Louis Vaickus
Louis Vaickus le 4 Mai 2018
I've tracked normalization down to (I think?) 4 Functions:
Trainer.m
->initializeNetworkNormalization
-->TrainerGPUStrategy.m
-->Precision.m
Within Trainer.m the function initializeNetworkNormalization contains two lines:
avgI = this.ExecutionStrategy.computeAverageImage(data, augmentations, executionSettings);
net.Layers{1}.AverageImage = precision.cast(avgI);
this.ExecutionStrategy = nnet.internal.cnn.TrainerGPUStrategy:
classdef TrainerGPUStrategy < nnet.internal.cnn.TrainerExecutionStrategy
% TrainerGPUStrategy Execution stategy for running the Trainer on the
% GPU
% Copyright 2016 The Mathworks, Inc.
methods
function Y = environment(~, X)
Y = gpuArray(X);
end
function [avgI, numImages] = computeAccumImage(~, data, augmentations)
data.start();
avgI = gpuArray(0);
numImages = 0;
while ~data.IsDone
X = data.next();
if ~isempty(X)
X = apply(augmentations, X);
X = gpuArray(double(X));
avgI = avgI + sum(X, 4);
numImages = numImages + size(X,4);
end
end
end
end
end
I'm no expert but I'm assuming X = data.next() is pulling the individual images and keeping a running tally of average pixel values and the number of images (to divide by?)? In which case I can't see why this should take so long?
Joss Knight
Joss Knight le 8 Mai 2018
Are you using an augmentedImageDatastore with BackgroundDispatch set to true?
To skip the normalization you need to replace your input layer with a new input layer, but with 'Normalization' set to 'none'.
layers(1) = imageInputLayer([227 227 3], 'Normalization', 'none');

Connectez-vous pour commenter.

Réponses (1)

Youshan Zhang
Youshan Zhang le 2 Fév 2021
Did you solve this problem?
  1 commentaire
Louis Vaickus
Louis Vaickus le 2 Fév 2021
As I recall, it was zero center normalization.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Deep Learning Toolbox dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by