-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBAM_network.m
More file actions
137 lines (111 loc) · 3.04 KB
/
BAM_network.m
File metadata and controls
137 lines (111 loc) · 3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
clc
close all
clear all
A=[-1 1 -1 ; 1 -1 1 ; 1 1 1 ; 1 -1 1 ; 1 -1 1];
B=[1 1 1 ; 1 -1 1 ; 1 1 1 ; 1 -1 1 ; 1 1 1];
C=[-1 1 1 ; 1 -1 -1 ; 1 -1 -1 ; 1 -1 -1 ; -1 1 1];
D=[-1 1 -1 ; 1 -1 1 ; 1 -1 1 ; 1 -1 1 ; -1 1 -1];
E=[1 1 1 ; 1 -1 -1 ; 1 1 1 ; 1 -1 -1 ; 1 1 1];
F=[1 1 1 ; 1 -1 -1 ; 1 1 1 ; 1 -1 -1 ; 1 -1 -1];
G=[1 1 1 ; 1 -1 -1 ; 1 1 1 ; 1 -1 1 ; 1 1 1];
H=[1 -1 1 ; 1 -1 1 ; 1 1 1 ; 1 -1 1 ; 1 -1 1];
I=[1 1 1 ; -1 1 -1 ; -1 1 -1 ; -1 1 -1 ; 1 1 1];
J=[1 1 1 ; -1 1 -1 ; -1 1 -1 ; -1 1 -1 ; 1 1 -1];
K=[1 -1 1 ; 1 1 -1 ; 1 -1 -1 ; 1 1 -1 ; 1 -1 1];
L=[1 -1 -1 ; 1 -1 -1 ; 1 -1 -1 ; 1 -1 -1 ; 1 1 1];
M=[1 -1 1 ; 1 1 1 ; 1 1 1 ; 1 -1 -1 ; 1 -1 -1];
N=[1 -1 1 ; 1 -1 1 ; 1 1 1 ; 1 1 1 ; 1 -1 1];
O=[1 1 1 ; 1 -1 1 ; 1 -1 1 ; 1 -1 1 ; 1 1 1];
P=[1 1 1 ; 1 -1 1 ; 1 1 1 ; 1 -1 -1 ; 1 -1 -1];
Q=[-1 1 -1 ; 1 -1 1 ; 1 -1 1 ; 1 1 1 ; -1 1 -1];
R=[1 1 1 ; 1 -1 1 ; 1 1 1 ; 1 1 -1 ; 1 -1 1];
S=[-1 1 1 ; 1 -1 -1 ; -1 1 1 ; -1 -1 1 ; 1 1 -1];
T=[1 1 1 ; -1 1 -1 ; -1 1 -1 ; -1 1 -1 ; -1 1 -1];
U=[1 -1 1 ; 1 -1 1 ; 1 -1 1 ; 1 -1 1 ; 1 1 1];
V=[1 -1 1 ; 1 -1 1 ; 1 -1 1 ; 1 -1 1 ; -1 1 -1];
W=[1 -1 1 ; 1 -1 1 ; 1 -1 1 ; 1 1 1 ; 1 -1 1];
X=[1 -1 1 ; 1 -1 1 ; -1 1 -1 ; 1 -1 1 ; 1 -1 1];
Y=[1 -1 1 ; 1 -1 1 ; -1 1 -1 ; -1 1 -1 ; -1 1 -1];
Z=[1 1 1 ; -1 -1 1 ; -1 1 -1 ; 1 -1 -1 ; 1 1 1];
x=input('input first character : ')
w1=input('input the output of first character : ')
x1=reshape(x',[1,15])
y=input('input second character : ')
w2=input('input the output of second character : ')
y1=reshape(y',[1,15]);
t1=(0:1:1)
t2=(0:1:14)
subplot(4,1,1)
stem(t1,w1)
title('output weights of the first character')
subplot(4,1,2)
stem(t2,x1)
title('Character 1 ')
subplot(4,1,3)
stem(t1,w2)
title('output weights of the second character ')
subplot(4,1,4)
stem(t2,y1)
title('Character 2 ')
ch1=zeros(15,2)
ch2=zeros(15,2)
for i=1:15
ch1(i,1)=w1(1)*x1(i);
ch1(i,2)=w1(2)*x1(i);
ch2(i,1)=w2(1)*y1(i);
ch2(i,2)=w2(2)*y1(i);
end
ch1
ch2
w=ch1+ch2
figure (2)
stem(w)
title(' weight matrix')
input_pat1= x1*w
input_pat2= y1*w
for i=1:2
if(input_pat1(i)>0)
input_pat1(i)=1;
else
input_pat1(i)=-1;
end
if(input_pat2(i)>0)
input_pat2(i)=1;
else
input_pat2(i)=-1;
end
end
input_pat1
input_pat2
figure (3)
subplot(2,1,1)
stem(t1,input_pat1)
title('input pattern for character 1')
subplot(2,1,2)
stem(t1,input_pat2)
title('input pattern for character 2')
% To check the bidirectional nature of the net
w_transpose=w'
rev1=w1*w_transpose
rev2=w2*w_transpose
for i=1:15
if(rev1(i)>0)
rev1(i)=1;
else
rev1(i)=-1;
end
if(rev2(i)>0)
rev2(i)=1;
else
rev2(i)=-1;
end
end
rev1 % the original input pattern of character 1
rev2 % the original input pattern of character 2
figure (4)
subplot(2,1,1)
stem(t2,rev1)
title(' input vector associated with character 1 ')
subplot(2,1,2)
stem(t2,rev2)
title(' input vector associated with character 2 ')