This is beginner level question.
I have several training inputs in binary and for the neural network I am using a sigmoid thresholding function SigmoidFn(Input1*Weights)
where
SigmoidFn(x) = 1./(1+exp(-1.*x));
The use of the above function will give continuous real numbers. But, I want the output to be in binary since the network is a Hopfield neural net (single layer 5 input nodes and 5 output nodes). The problem which I am facing is I am unable to correctly understand the usage and implementation of the various thresholding fucntions. The weights given below are the true weights and provided in the paper. So, I am using the weights to generate several training examples, several output samples by keeping the weight fixed, that is just run the neural network several times.
Weights = [0.0 0.5 0.0 0.2 0.0
0.0 0.0 1.0 0.0 0.0
0.0 0.0 0.0 1.0 0.0
0.0 1.0 0.0 0.0 0.0
0.0 0.0 0.0 -0.6 0.0];
Input1 = [0,1,0,0,0]
x = Input1*Weights; % x = 0 0 1 0 0
As can be seen the result of the multiplication is the second row of the Weights. Is this a mere coincidence?
Next,
SigmoidFn = 1./(1+exp(-1.*x)) SigmoidFn = 0.5000 0.5000 0.7311 0.5000 0.5000
round(SigmoidFn) ans = 1 1 1 1 1
Input2 = [1,0,0,0,0] x = Input2*Weights x = 0 0.5000 0 0.2000 0 SigmoidFn = 1./(1+exp(-1.*x)) SigmoidFn = 0.5000 0.6225 0.5000 0.5498 0.5000 >> round(SigmoidFn) ans = 1 1 1 1 1
Is it a good practice to use the round function
round(SigmoidFn(x))
. ? The result obtained is not correct. or how should I obtain binary result when I use any threshold function: (a) HArd Limit (b) Logistic sigmoid (c) Tanh
Can somebody please show the proper code for thresholding and a brief explanation of when to use which activation function?I mean there should be certain logic otherwise why are there different kinds of functions? EDIT : Implementation of Hopfield to recall the input pattern by successive iterations by keeping the weight fixed.
Training1 = [1,0,0,0,0];
offset = 0;
t = 1;
X(t,:) = Training1;
err = 1;
while(err~=0)
Out = X(t,:)*Weights > offset;
err = ((Out - temp)*(Out - temp).')/numel(temp);
t = t+1
X(t,:) = temp;
end