I want to compare different neural network architectures using MSE. I know that for a single output network, it is straightforward. But I am not sure how to calculate MSE for multi-output network especially outputs have different units? Is it okay to calculate the MSE for each output set separately and get average value? Can someone help me with creating a code to calculate the MSE of the following network?
Thank you
x = Input;t = Output;trainFcn = 'trainlm'; net = fitnet([25,25],trainFcn);net.trainParam.max_fail=10;net.layers{1}.transferFcn = 'tansig';net.layers{2}.transferFcn = 'logsig';net.input.processFcns = {'removeconstantrows','mapminmax'};net.output.processFcns = {'removeconstantrows','mapminmax'};net.divideFcn = 'dividerand'; % Divide data randomly
net.divideMode = 'sample'; % Divide up every sample
net.divideParam.trainRatio = 70/100;net.divideParam.valRatio = 15/100;net.divideParam.testRatio = 15/100;net.performFcn = 'mse'; % Mean Squared Error
net.plotFcns = {'plotperform','plottrainstate','ploterrhist', ... 'plotregression', 'plotfit'};[net,tr] = train(net,x,t);y = net(x);e = gsubtract(t,y);performance = perform(net,t,y);trainTargets = t .* tr.trainMask{1};valTargets = t .* tr.valMask{1};testTargets = t .* tr.testMask{1};trainPerformance = perform(net,trainTargets,y);valPerformance = perform(net,valTargets,y);testPerformance = perform(net,testTargets,y);%siimulating the outputs
alloutputs = sim(net,x);% Getting the training targets
trainTargets = gmultiply(t,tr.trainMask);SSE = sse(net,trainTargets,alloutputs); % Sum of Squared Errors for the training set
n = length(tr.trainInd); % Number of training cases
p = length(getwb(net)); % Number of parameters (weights and biases)
% Schwarz's Bayesian criterion (or BIC) (Schwarz, 1978)
SBC = n * log(SSE/n) + p * log(n);% Akaike's information criterion (Akaike, 1969)
AIC = n * log(SSE/n) + 2 * p;% Corrected AIC (Hurvich and Tsai, 1989)
AICc = n * log(SSE/n) + (n + p) / (1 - (p + 2) / n);
Best Answer