Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LearnerObserver. This enables usage of BIDViz #159

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/main/scala/BIDMach/Learner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ case class Learner(
if (opts.updateAll) {
model.dobatchg(mats, ipass, here);
if (mixins != null) mixins map (_ compute(mats, here));
if (opts.observer != null) {
opts.observer.notify(ipass, model, mats)
}
if (updater != null) updater.update(ipass, here, gprogress);
}
val scores = model.evalbatchg(mats, ipass, here);
Expand All @@ -144,6 +147,9 @@ case class Learner(
} else {
model.dobatchg(mats, ipass, here)
if (mixins != null) mixins map (_ compute(mats, here))
if (opts.observer != null) {
opts.observer.notify(ipass, model, mats)
}
if (updater != null) updater.update(ipass, here, gprogress)
}
if (datasource.opts.putBack >= 0) datasource.putBack(mats, datasource.opts.putBack)
Expand Down Expand Up @@ -814,6 +820,11 @@ class ParLearnerF(
}

object Learner {
trait LearnerObserver {
def init = {}
def cleanup = {}
def notify(ipass:Int, model:Model, minibatch:Array[Mat]) = {}
}

class Options extends BIDMat.Opts {
var npasses = 2;
Expand All @@ -827,6 +838,7 @@ object Learner {
var cumScore = 0;
var checkPointFile:String = null;
var checkPointInterval = 0f;
var observer: LearnerObserver = null;
}

def numBytes(mat:Mat):Long = {
Expand Down