Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. neta1 = 0.01
  2.  
  3. num_epoch = 0
  4. while True:
  5. bp_error_count = 0
  6. print "The epoch value is", num_epoch
  7. for row in numpy.arange(0,result.shape[0]):
  8. #bp_error_count = 0
  9. bp_feature_vector = result[row][1:result.shape[1]]
  10. bp_feature_vector = numpy.insert(bp_feature_vector,0,1,axis=0)
  11. bp_label = result[row][0]
  12. if (bp_label == 0):
  13. bp_label = -1
  14. else:
  15. bp_label = bp_label
  16. bp_dot_product = numpy.dot(bp_weight_vector,bp_feature_vector)
  17. bp_predicted = step(bp_dot_product)
  18. if (bp_predicted >=0 and bp_label == -1) or (bp_predicted <=0 and bp_label == 1):
  19. bp_temp_vector = bp_temp_vector + bp_label*bp_feature_vector
  20. #bp_weight_vector = bp_weight_vector + bp_label*bp_feature_vector
  21. bp_error_count = bp_error_count + 1
  22. bp_weight_vector = bp_weight_vector + neta1*bp_temp_vector
  23. neta1 = neta1*0.9
  24. bp_temp_vector = 0
  25. num_epoch = num_epoch + 1
  26. print(bp_error_count)
  27. print(num_epoch)
  28. if (bp_error_count == 0):
  29. break
  30. else:
  31. continue
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement