Skip to content

Instantly share code, notes, and snippets.

@claytantor
Created September 11, 2016 19:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save claytantor/f1782e3dd93963c13357e4e781bdadae to your computer and use it in GitHub Desktop.
Save claytantor/f1782e3dd93963c13357e4e781bdadae to your computer and use it in GitHub Desktop.
alt approach to training
// ----- Train the network, evaluating the test set performance at each epoch -----
int nEpochs = 400;
for (int i = 0; i < nEpochs; i++) {
net.fit(trainData);
trainData.reset();
}
//Evaluate on the test set:
List<String> labels = new ArrayList<>();
List<Integer> keys = new ArrayList(classifiers.keySet());
Collections.sort(keys);
for(Integer i:keys){
labels.add(classifiers.get(i));
}
Evaluation evaluation = net.evaluate(testData, labels);
String str = "Test set evaluation at epoch %d: Accuracy = %.2f, F1 = %.2f";
log.info(String.format(str, nEpochs, evaluation.accuracy(), evaluation.f1()));
testData.reset();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment