Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2015
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. def kerperceptron_batch(data, labels, sigma_squared=25.0):
  2. c = np.zeros(len(data)).astype('float')
  3. i, t = 0, 0
  4. batches = list()
  5.  
  6. while (i < 10):
  7. t = 0
  8. for image in data:
  9. if (t == 0):
  10. numerrors = 0
  11. currerrors = np.zeros(len(data)).astype('int')
  12. batches.append(currerrors)
  13.  
  14. y = int(summation_kernel(c,t,data, sigma_squared) >= 0)
  15.  
  16. if (y == 0) and (labels[t] == 1):
  17. c[t] += 1
  18. numerrors += 1
  19. elif (y == 1) and (labels[t] == -1):
  20. c[t] -= -1
  21. numerrors += 1
  22.  
  23. currerrors[t] = numerrors
  24. t += 1
  25.  
  26. i += 1
  27.  
  28. batches = np.array(batches)
  29. return c, batches, i
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement