mirror of
https://github.com/skishore/makemeahanzi.git
synced 2025-10-31 02:45:49 +08:00
Restore trained stroke extractor
This commit is contained in:
19
lib/classifier.js
Normal file
19
lib/classifier.js
Normal file
@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
|
||||
Meteor.startup(() => {
|
||||
const input = new convnetjs.Vol(1, 1, 8 /* feature vector dimensions */);
|
||||
const net = new convnetjs.Net();
|
||||
net.fromJSON(NEURAL_NET_TRAINED_FOR_STROKE_EXTRACTION);
|
||||
const weight = 0.8;
|
||||
|
||||
const trainedClassifier = (features) => {
|
||||
input.w = features;
|
||||
const softmax = net.forward(input).w;
|
||||
return softmax[1] - softmax[0];
|
||||
}
|
||||
|
||||
stroke_extractor.combinedClassifier = (features) => {
|
||||
return stroke_extractor.handTunedClassifier(features) +
|
||||
weight*trainedClassifier(features);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user