Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. /**
  2. * learn training data, printing SSE at 10 of the epochs, evenly spaced
  3. * if a validation set available, learning stops when SSE on validation set rises
  4. * this check is done by summing SSE over 10 epochs
  5. * @param numEpochs number of epochs
  6. * @param lRate learning rate
  7. * @param momentum momentum
  8. * @return String with data about learning eg SSEs at relevant epoch
  9. */
  10. public String doLearn (int numEpochs, double lRate, double momentum) {
  11. String s = "";
  12. String tmp = "";
  13.  
  14. if (validationData==null) s = super.doLearn(numEpochs, lRate, momentum);
  15. // if no validation set, just use normal doLearn
  16. else {
  17. if(hasLearned)return ""; //if has learnt , do not proceed
  18. validationData.clearSSELog(); //clear the validations data SSE log
  19. for (int epoch = 0; epoch < numEpochs; epoch+=10) { //for every epoch , step (10) (because we check the SSE every 10 epochs)
  20. presentDataSet(validationData);
  21. tmp=super.doLearn(10, lRate, momentum); //perform 10 learning epochs in the train data
  22. //present the validation data into the network
  23. if(validationData.getTotalSSE()>currSSE) { //if this SSE rises from the previous one
  24. hasLearned=true; //break and give info
  25. s+="Stopped after "+trainData.sizeSSELog();
  26. break;
  27. }
  28. if(trainData.sizeSSELog()%100==0) {
  29. s+=addEpochString(trainData.sizeSSELog())+":"+trainData.dataAnalysis()+"\n"; //add string with analytics
  30. }
  31.  
  32. currSSE=validationData.getTotalSSE(); //remember this SSE
  33. validationData.clearSSELog(); //clear the validation log
  34. }
  35. }
  36.  
  37. return s; // return string showing learning
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement