How to decode / de-normalize output from network

gshank's picture

I use the DataNormalization class to normalize my training input and ideal data plus my network input data but I don't see anything on how to decode or de-normalize the NeuralData output from BasicNetwork.compute(NeuralData input). Please help. Thanks.

jeffheaton's picture

This is an area of the normalization classes that I plan to expand. But for now, some of the output fields provide a method named "covertBack", which is used something like this.

OutputFieldRangeMapped mpgField = (OutputFieldRangeMapped)((List)norm.getOutputFields()).get(0);

return mpgField.convertBack(output.getData(0));

This is from the MPG example.

gshank's picture

Thanks, I wondered if I should use that but wasn't sure. Works great!!

gshank's picture

I just wanted to verify that I'm doing this correctly - right now I'm normalizing my training input data separately from my training ideal data - is that correct or should I be normalizing both at the same time? Here's a code snippet of how I'm doing it currently.

double[][] input = ..... build training input data .....
double[][] ideal = ..... build training ideal data .....
input = normalizeData(input, false);
ideal = normalizeData(ideal, true);
Train train = new Backpropagation(network, new BasicNeuralDataSet(input, ideal, 0.0001, 0.1);

private double[][] normalizeData(double[][] data, boolean isIdeal) {
double[][] output = .... create output array ....
BasicNeuralDataSet bnds = new BasicNeuralDataSet(data, null);
NormalizationStorageArray2D target = new NormalizationStorageArray2D(output);
DataNormalization norm = new DataNormalization();
norm.setTarget(target);
InputField i1, i2;
norm.addInputField(i1 = new InputFieldNeuralDataSet(false, bnds, 0));
norm.addInputField(i2 = new InputFieldNeuralDataSet(false, bnds, 1));
norm.addOutputField(new OutputFieldRangeMapped(i1, 0, 1), isIdeal);
norm.addOutputField(new OutputFieldRangeMapped(i2, 0, 1), isIdeal);
norm.process();
return output;
}
I'm guessing this is the right way to do this but just wanted to double-check.
Thanks
Gary


Copyright 2005 - 2012 by Heaton Research, Inc.. Heaton Research™ and Encog™ are trademarks of Heaton Research. Click here for copyright, license and trademark information.