SHARE
TWEET

Untitled

a guest May 23rd, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def train(self, patterns):
  2.         '''
  3.         Compute weight matrix analytically
  4.         '''
  5.         #print('patterns',type(patterns),patterns)
  6.         self.W = np.zeros((self.dim, self.dim))
  7.         #print('self.W',self.W.shape,self.W)
  8.         # P = len(patterns)
  9.         P = patterns.shape[0]
  10.         for i in range(self.W.shape[0]):
  11.             for j in range(self.W.shape[1]):
  12.                 if i != j:
  13.                     sum = 0
  14.                     for p in range(len(patterns)):
  15.                         sum += patterns[p][i]*patterns[p][j]
  16.                     self.W[i,j] = (1/P)*sum
  17.                 else:
  18.                     self.W[i,j] = 0
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top