does anyone know why this neural network is not giving the right target values?

Technical Source
2 min readJul 1, 2021

--

%a=imread('A.bmp');
%a=imresize(a,[6,5]);
%a=imresize(a,[1,30]);
inp=[0 0 1 0 0 0 0 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 1 1 1 0 0 0 1];
out=[1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0];
net= newff(inp,out,10)
tol = 0.001; % Error tolerance
%net.trainParam.show = 50;
net.trainParam.lr = 0.007;
net.trainParam.epochs = 500;
net.trainParam.alpha = 0.5;
%net.trainParam.goal = 1e-5;
[net,tr]=train(net,inp,out);
a=sim(net,inp)

ANSWER

Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.

% Weird data set:

plot(input,target,'o')

The data does not represent points from reasonable function. The target says" Regardless of the input, if the output is 0, your error will only be 3.33%".

Looking at an escalation of models (H=0:9) shows that the Linear model (H=0, NN with no hidden layer) is the best with a coefficient of determination (Wikipedia/R-squared) of only 0.0264. It is only slightly better than the constant output = 0 model.

close all, clear all, clc

N =30
input = [0 0 1 0 0 0 0 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 1 1 1 0 0 0 1];
target = [ 1, zeros( 1,N-1)];

% The simplest model is the constant output model that outputs the mean of the target regardless of the input.

y00   = (1/N)*ones(1,N); % 0.0333*ones(1,30)
e00 = target-y00; ; % [ 0.9667, -0.0333*ones(1,29)]
MSE00 = mse(target-y00) % 0.0322

% The next simplest is the linear model

W0    =  target/[ ones(1,N) ; input ] % W0 = [ 0.0588 -0.0588 ]
y0 = W0 * [ ones(1,N) ; input ]; % y0 = 0.0588*(1-input)
e0 = target-y0; ; % [ 0.9412, -y0(2:end)]
MSE0 = mse(target-y0) % 0.0314 Not much better than constant model
R20 = 1 - MSE0/MSE00 % 0.0264 VERY BAD FIT

% Neural Model

SEE COMPLETE ANSWER CLICK THE LINK

--

--

Technical Source
Technical Source

Written by Technical Source

Simple! That is me, a simple person. I am passionate about knowledge and reading. That’s why I have decided to write and share a bit of my life and thoughts to.

No responses yet