Space In HIndi

 


Pages

Popular

Implementation of EXOR GATE USING RADIAL BASIC FUNCTION NETWORK Exp-5

                      Experiment No 5 

Implementation of EXOR GATE USING RADIAL BASIC FUNCTION NETWORK
clc;
clear all;
x=[0 0 1 1;0 1 0 1];
T=[0 1 1 0];
y=[0 0 0 0];
for i=1:7
net=newrb(x,T,0,i);
I=[0;0];
II=[0;1];
III=[1;0];
IIII=[1;1];
y(1)=sim(net,I)
y(2)=sim(net,II)
y(3)=sim(net,III)
y(4)=sim(net,IIII)
%disp('i=');
%disp(i);
if y==T
disp('y');
disp(y);
disp('spread value=');
disp(i);
break;
%elseif i==10
disp('sorry');
end
end

NEWRB Design a radial basis network.

Synopsis

[net,tr] = newrb(P,T,GOAL,SPREAD,MN,DF)

Description

Radial basis networks can be used to
approximate
functions. NEWRB adds neurons to the hidden
layer of a radial basis network until it
meets
the specified mean squared error goal.

NEWRB(P,T,GOAL,SPREAD,MN,DF) takes these
arguments,
P - RxQ matrix of Q input vectors.
T - SxQ matrix of Q target class
vectors.
GOAL - Mean squared error goal, default =
0.0.
SPREAD - Spread of radial basis functions,
default = 1.0.
MN - Maximum number of neurons, default
is Q.
DF - Number of neurons to add between
displays, default = 25.
and returns a new radial basis network.

The larger that SPREAD is the smoother the
function approximation
will be. Too large a spread means a lot of
neurons will be
required to fit a fast changing function.
Too small a spread
means many neurons will be required to fit a
smooth function,
and the network may not generalize well.
Call NEWRB with
different spreads to find the best value for
a given problem.

Examples

Here we design a radial basis network given
inputs P
and targets T.

P = [1 2 3];
T = [2.0 4.1 5.9];
net = newrb(P,T);

Here the network is simulated for a new
input.

P = 1.5;
Y = sim(net,P)

Algorithm

NEWRB creates a two layer network. The first
layer has RADBAS
neurons, and calculates its weighted inputs
with DIST, and
its net input with NETPROD. The second
layer has PURELIN neurons,
calculates its weighted input with DOTPROD
and its net inputs with
NETSUM. Both layers have biases.

Initially the RADBAS layer has no neurons.
The following steps
are repeated until the network's mean
squared error falls below GOAL
or the maximum number of neurons are reached:
1) The network is simulated
2) The input vector with the greatest error
is found
3) A RADBAS neuron is added with weights
equal to that vector.
4) The PURELIN layer weights are redesigned
to minimize error.
NEWRBE Design an exact radial basis network.

Synopsis

net = newrbe(P,T,SPREAD)

Description

Radial basis networks can be used to
approximate functions.
NEWRBE very quickly designs a radial basis
network with
zero error on the design vectors.

NEWRBE(P,T,SPREAD) takes two or three
arguments,
P - RxQ matrix of Q input vectors.
T - SxQ matrix of Q target class
vectors.
SPREAD - of radial basis functions, default
= 1.0.
and returns a new exact radial basis
network.

The larger that SPREAD, is the smoother the
function approximation
will be. Too large a spread can cause
numerical problems.

Examples

Here we design a radial basis network, given
inputs P
and targets T.

P = [1 2 3];
T = [2.0 4.1 5.9];
net = newrbe(P,T);

Here the network is simulated for a new
input.

P = 1.5;
Y = sim(net,P)

Algorithm

NEWRBE creates a two layer network. The
first layer has RADBAS
neurons, and calculates its weighted inputs
with DIST, and its
net input with NETPROD. The second layer
has PURELIN neurons,
and calculates its weighted input with
DOTPROD and its net inputs
with NETSUM. Both layer's have biases.

NEWRBE sets the first layer weights to P',
and the first
layer biases are all set to 0.8326/SPREAD,
resulting in
radial basis functions that cross 0.5 at
weighted inputs
of +/- SPREAD.

The second layer weights IW{2,1} and biases
b{2} are found by
simulating the first layer outputs A{1}, and
then solving the
following linear expression:

[W{2,1} b{2}] * [A{1}; ones] = T

See also sim, newrb, newgrnn, newpnn.

Reference page in Help browser
doc newrbe

SIM Simulate a Simulink model
SIM('model') will simulate your Simulink
model using all simulation
parameter dialog settings including Workspace
I/O options.

The SIM command also takes the following
parameters. By default
time, state, and output are saved to the
specified left hand side
arguments unless OPTIONS overrides this. If
there are no left hand side
arguments, then the simulation parameters
dialog Workspace I/O settings
are used to specify what data to log.

[T,X,Y] =
SIM('model',TIMESPAN,OPTIONS,UT)
[T,X,Y1,...,Yn] =
SIM('model',TIMESPAN,OPTIONS,UT)

T : Returned time vector.

X : Returned state in matrix
or structure format.
The state matrix contains
continuous states followed by
discrete states.
Y : Returned output in matrix
or structure format.
For block diagram models
this contains all root-level
outport blocks.
Y1,...,Yn : Can only be specified for
block diagram models, where n
must be the number of
root-level outport blocks. Each
outport will be returned
in the Y1,...,Yn variables.

'model' : Name of a block diagram
model.
TIMESPAN : One of:
TFinal,

[TStart TFinal], or
[TStart OutputTimes

TFinal].
OutputTimes are time
points which will be returned in
T, but in general T will
include additional time points.
OPTIONS : Optional simulation
parameters. This is a structure

created with SIMSET using
name value pairs.
UT : Optional external inputs.
UT can be:
- A MATLAB function
(expressed as a string) that
specifies the input u =
UT(t) at each simulation
time step.
- A table of input values
versus time for all input ports
UT = [T, U1, ... Un]
where T = [t1, ..., tm]'
- A structure array
containing data for all input
ports.
- A comma-separated list
of tables. Each table
corresponds to a
specific input port, and must be
an array, a structure, a
Simulink.Timeseries object,
or a Simulink.TsArray
object.

Specifying any right hand side argument to
SIM as the empty matrix, [],
will cause the default for the argument to be
used.

Only the first parameter is required. All
defaults will be taken from the
block diagram, including unspecified options.
Any optional arguments
specified will override the settings in the
block diagram.

See also sldebug, simset.

No comments: