sclass TrainVAD { replace Recognizer with F1<BWImage, Bool>. new Best<Recognizer> best; LPair<BWImage, Bool> trainingList; float stepSizeRatio = 0.25f; int clipLength; Recognizer go() { final BWImage img1 = frequencyImage(voiceMegaMix()); final BWImage img2 = frequencyImage(nonVoiceMegaMix()); clipLength = iround(2.0*spectro_pixelsPerSecond()); int stepSize = max(1, iround(clipLength*stepSizeRatio)); print(+clipLength); print(+stepSize); L<BWImage> images1 = map(func(IntRange r) -> BWImage { bwHorizontalClip(img1, r) }, stepIntRange(clipLength, intRange(0, img1.getWidth()), stepSize)); L<BWImage> images2 = map(func(IntRange r) -> BWImage { bwHorizontalClip(img2, r) }, stepIntRange(clipLength, intRange(0, img2.getWidth()), stepSize)); print(allImageSizes(concatLists(images1, images2))); print(l(images1) + " + " + l(images2) + " images"); trainingList = trueFalseBPairs(images1, images2); // dummy recognizers first test(func(BWImage img) -> bool { false }); test(func(BWImage img) -> bool { true }); new AIStrategy_RandomWithVariation<Recognizer> strategy; strategy.best = best; strategy.submit = f1_scorePreciseRecognizer(trainingList); strategy.random = func -> Recognizer { nu(VAD_1, streakLength := random(1, clipLength/2), threshold := randomFloat(), band := audio_randomBand()) }; strategy.vary = func(Recognizer r) -> Recognizer { if (r cast VAD_1) ret nu(VAD_1, streakLength := varyInt(r.streakLength), threshold := varyFloat(r.threshold), band := audio_varyBand(r.band)); null; }; runStrategyWhileImprovement(best, strategy); /*for (int streakLength = 1; streakLength <= clipLength/2; streakLength++) test(nu(VAD_1, +streakLength));*/ ret best!; } void test(Recognizer r) { scorePreciseRecognizer(best, r, trainingList); } void showErrors(Recognizer r) { if (r == null) ret; new L<BWImage> errorImages; for (Pair<BWImage, Bool> p : trainingList) if (r.get(p.a) != p.b) errorImages.add(bwAutoContrast(p.a)); if (nempty(errorImages)) showImage("Errors", mergeBWImagesVertically(errorImages)); } }
download show line numbers debug dex old transpilations
Travelled to 12 computer(s): bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1019262 |
Snippet name: | TrainVAD |
Eternal ID of this version: | #1019262/2 |
Text MD5: | 6fce017840486024fbec2d4a8af56229 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-10-28 17:44:06 |
Source code size: | 2375 bytes / 67 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 352 / 889 |
Version history: | 1 change(s) |
Referenced in: | #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674) |