forked from davidtob/jobmansqlmonitor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjobman_monitor_extension.py
37 lines (31 loc) · 995 Bytes
/
jobman_monitor_extension.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""
.. todo::
WRITEME
"""
import numpy
np = numpy
from pylearn2.train_extensions import TrainExtension
import theano
import theano.tensor as T
from pylearn2.utils import serial
import jobman
class JobmanMonitor(TrainExtension):
def __init__( self ):
#self.__dict__.update(locals())
self.train_obj = None
self.channel = None
self.state = None
def set_train_obj( self, train_obj ):
self.train_obj = train_obj
def set_jobman_channel( self, channel ):
self.channel = channel
def set_jobman_state( self,state ):
self.state = state
def on_monitor(self, model, dataset, algorithm):
print "jobman on monitor"
if self.train_obj!=None and self.state!=None:
print "calling extract_results"
self.state.results = jobman.tools.resolve(self.state.extract_results)(self.train_obj)
if self.channel!=None:
print "calling channel save"
self.channel.save()