Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- neta1 = 0.01
- num_epoch = 0
- while True:
- bp_error_count = 0
- print "The epoch value is", num_epoch
- for row in numpy.arange(0,result.shape[0]):
- #bp_error_count = 0
- bp_feature_vector = result[row][1:result.shape[1]]
- bp_feature_vector = numpy.insert(bp_feature_vector,0,1,axis=0)
- bp_label = result[row][0]
- if (bp_label == 0):
- bp_label = -1
- else:
- bp_label = bp_label
- bp_dot_product = numpy.dot(bp_weight_vector,bp_feature_vector)
- bp_predicted = step(bp_dot_product)
- if (bp_predicted >=0 and bp_label == -1) or (bp_predicted <=0 and bp_label == 1):
- bp_temp_vector = bp_temp_vector + bp_label*bp_feature_vector
- #bp_weight_vector = bp_weight_vector + bp_label*bp_feature_vector
- bp_error_count = bp_error_count + 1
- bp_weight_vector = bp_weight_vector + neta1*bp_temp_vector
- neta1 = neta1*0.9
- bp_temp_vector = 0
- num_epoch = num_epoch + 1
- print(bp_error_count)
- print(num_epoch)
- if (bp_error_count == 0):
- break
- else:
- continue
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement