Normalizing data for neural networks

Hi,
I've read that it is good practice to normalize data before training a neural network.
There are different ways of normalizing data.
Does the data have to me normalized between 0 and 1? or can it be done using the standardize function - which won't necessarily give you numbers between 0 and 1 and could give you negative numbers.
Many thanks

 採用された回答

Chandra Kurniawan
Chandra Kurniawan 2012 年 1 月 10 日

1 投票

Hi,
I've heard that the artificial neural network training data must be normalized before the training process.
I have a code that can normalize your data into spesific range that you want.
p = [4 4 3 3 4;
2 1 2 1 1;
2 2 2 4 2];
a = min(p(:));
b = max(p(:));
ra = 0.9;
rb = 0.1;
pa = (((ra-rb) * (p - a)) / (b - a)) + rb;
Let say you want to normalize p into 0.1 to 0.9.
p is your data.
ra is 0.9 and rb is 0.1.
Then your normalized data is pa

4 件のコメント

Greg Heath
Greg Heath 2012 年 1 月 11 日
Demos in the comp.a.neural-nets FAQ indicate that better precision is obtained when the input data is relatively balanced about 0 AND TANSIG (instead of LOGSIG) activation functions are used in hidden layers.
Hope this helps.
Greg
Kaushal Raval
Kaushal Raval 2015 年 7 月 4 日
i want to find out my output in original form how can i find it ? please help me
Greg Heath
Greg Heath 2015 年 7 月 10 日
If you use the standard programs e.g., FITNET, PATTERNNET, TIMEDELAYNET, NARNET & NARXNET,
All of the normalization and de-normalization is done automatically (==>DONWORRIBOUTIT).
All you have to do is run the example programs in, e.g.,
help fitnet
doc fitnet
If you need additional sample data
help nndatasets
doc nndatasets
For more detailed examples search in the NEWSGROUP and ANSWERS. For example
NEWSGROUP 2014-15 all-time
tutorial 58 2575
tutorial neural 16 127
tutorial neural greg 15 58
Hope this helps.
Greg
murat tuna
murat tuna 2019 年 3 月 22 日
Sorry, where is NEWSGROUP?

サインインしてコメントする。

その他の回答 (4 件)

Greg Heath
Greg Heath 2012 年 1 月 11 日

3 投票

The best combination to use for a MLP (e.g., NEWFF) with one or more hidden layers is
1. TANSIG hidden layer activation functions
2. EITHER standardization (zero-mean/unit-variance: doc MAPSTD)
OR [ -1 1 ] normalization ( [min,max] => [ -1, 1 ] ): doc MAPMINMAX)
Convincing demonstrations are available in the comp.ai.neural-nets FAQ.
For classification among c classes, using columns of the c-dimensional unit matrix eye(c) as targets guarantees that the outputs can be interpreted as valid approximatations to input conditional posterior probabilities. For that reason, the commonly used normalization to [0.1 0.9] is not recommended.
WARNING: NEWFF automatically uses the MINMAX normalization as a default. Standardization must be explicitly specified.
Hope this helps.
Greg

4 件のコメント

John
John 2012 年 1 月 11 日
Hi Greg,
Thank you for your detailed response.
I'm only new matlab so to be honest I don't really understand some of it. However I've googled the terms and I think your advising me if I was building my own network?
I intend to use the nprtool GUI to classify data, which is a 2 layed feed forward network. This means that I will have to standardize the inputs before I import them into the tool.
What method would you recommend I that I use to standardize these? The standardize function or between 0 and 1?
Many thanks
John
owr
owr 2012 年 1 月 11 日
I dont have access to the Neural Network Toolbox anymore, but if I recall correctly you should be able to generate code from the nprtool GUI (last tab maybe?). You can use this code to do your work without the GUI, customize it as need be, and also learn from it to gain a deeper understanding.
What I think Greg is referring to above is the fact that the function "newff" (a quick function to initialize a network) uses the built in normalization (see toolbox function mapminmax). If you want to change this, you'll have to make some custom changes. I dont recall if the nprtool uses newff - this can be verified by generating and viewing the code.
This is all from memory as I dont have access to the toolbox anymore - so take my comments as general guidelines, not as absolute.
Good luck.
John
John 2012 年 1 月 12 日
Thank you
Greg Heath
Greg Heath 2012 年 1 月 13 日
Standardization means zero-mean/unit-variance.
My preferences:
1. TANSIG in hidden layers
2. Standardize reals and mixtures of reals and binary.
3. {-1,1} for binary and reals that have bounds imposed by math or physics.
Hope this helps.
Greg

サインインしてコメントする。

Greg Heath
Greg Heath 2012 年 1 月 14 日

1 投票

In general, if you decide to standardize or normalize, each ROW is treated SEPARATELY.
If you do this, either use MAPSTD, MAPMNMX, or the following:
[I N] = size(p)
%STANDARDIZATION
meanp = repmat(mean(p,2),1,N);
stdp = repmat(std(p,0,2),1,N);
pstd = (p-meanp)./stdp ;
%NORMALIZATION
minp = repmat(min(p,[],2),1,N);
maxp = repmat(max(p,[],2),1,N);
pn = minpn +(maxpn-minpn).*(p-minp)./(maxp-pmin);
Hope this helps
Greg

4 件のコメント

John
John 2012 年 1 月 16 日
Many thanks
fehmi zarzoum
fehmi zarzoum 2017 年 5 月 24 日
hi, Undefined function or variable 'pmin'.
Greg Heath
Greg Heath 2017 年 5 月 31 日
Yeah, should be minp.
electronx engr
electronx engr 2017 年 11 月 4 日
plz can u help me in this that after training with normalized data, how can I get the network (using gensim command) that works on unnormalized input, since I have created and trained the network using normalized input and output?

サインインしてコメントする。

Sarillee
Sarillee 2013 年 3 月 25 日

0 投票

y=(x-min(x))/(max(x)-min(x))
try this...
x is input....
y is the output...

1 件のコメント

Greg Heath
Greg Heath 2013 年 5 月 10 日
Not valid for matrix inputs

サインインしてコメントする。

Imran Babar
Imran Babar 2013 年 5 月 8 日

0 投票

mu_input=mean(trainingInput); std_input=std(trainingInput); trainingInput=(trainingInput(:,:)-mu_input(:,1))/std_input(:,1);
I hope this will serve your purpose

2 件のコメント

Greg Heath
Greg Heath 2013 年 5 月 10 日
Not valid for matrix inputs
Abul Fujail
Abul Fujail 2013 年 12 月 12 日
in case of matrix data, the min and max value corresponds to a column or the whole dataset. E.g. i have 5 input columns of data, in this case whether i should choose min/max for each column and do the normalization or min/max form all over the column and calculate.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeDeep Learning Toolbox についてさらに検索

質問済み:

2012 年 1 月 10 日

コメント済み:

2019 年 3 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by