Public Member Functions | Public Attributes | List of all members
my_callbacks.IterationsCallback Class Reference
Inheritance diagram for my_callbacks.IterationsCallback:

Public Member Functions

def __init__ (self, validation_generator, validation_steps)
 
def on_train_begin (self, logs={})
 
def on_batch_end (self, batch, logs={})
 
def on_epoch_end (self, epoch, logs={})
 

Public Attributes

 validation_generator
 
 validation_steps
 
 fil
 
 losses
 
 iteration
 

Detailed Description

Definition at line 223 of file my_callbacks.py.

Constructor & Destructor Documentation

def my_callbacks.IterationsCallback.__init__ (   self,
  validation_generator,
  validation_steps 
)

Definition at line 225 of file my_callbacks.py.

225  def __init__(self, validation_generator, validation_steps):
226  self.validation_generator = validation_generator
227  self.validation_steps = validation_steps
228  self.fil = '/scratch/cvn/branch/log/resnet34'
229 
def __init__(self, validation_generator, validation_steps)

Member Function Documentation

def my_callbacks.IterationsCallback.on_batch_end (   self,
  batch,
  logs = {} 
)

Definition at line 241 of file my_callbacks.py.

241  def on_batch_end(self, batch, logs={}):
242  if self.iteration % 1000 == 0:
243  val_loss, val_acc = self.model.evaluate_generator(self.validation_generator, steps=self.validation_steps)
244  self.losses.append([self.iteration, logs.get('acc'), logs.get('loss'), val_acc, val_loss])
245  self.iteration += 1
246 
def on_batch_end(self, batch, logs={})
def my_callbacks.IterationsCallback.on_epoch_end (   self,
  epoch,
  logs = {} 
)

Definition at line 247 of file my_callbacks.py.

247  def on_epoch_end(self, epoch, logs={}):
248  with open(self.fil, 'a') as fil:
249  for iteration, acc, loss, val_acc, val_loss in self.losses:
250  fil.write(str(iteration) + ' ' + str(acc) + ' ' + str(loss) + ' ' + str(val_acc) + ' ' + str(val_loss) + '\n')
251 
252  self.losses = []
253  return
254 
255 
int open(const char *, int)
Opens a file descriptor.
def on_epoch_end(self, epoch, logs={})
static QCString str
def my_callbacks.IterationsCallback.on_train_begin (   self,
  logs = {} 
)

Definition at line 230 of file my_callbacks.py.

230  def on_train_begin(self, logs={}):
231  self.losses = []
232  self.iteration = 0
233 
234  with open(self.fil, 'ar+') as fil:
235  if os.stat(self.fil).st_size == 0:
236  self.losses.append(['iter', 'acc', 'loss', 'val_acc', 'val_loss'])
237 
238  else:
239  self.iteration = int(fil.read().split('\n')[-2].split(' ')[0]) + 1
240 
int open(const char *, int)
Opens a file descriptor.
def on_train_begin(self, logs={})
void split(std::string const &s, char c, OutIter dest)
Definition: split.h:35

Member Data Documentation

my_callbacks.IterationsCallback.fil

Definition at line 228 of file my_callbacks.py.

my_callbacks.IterationsCallback.iteration

Definition at line 232 of file my_callbacks.py.

my_callbacks.IterationsCallback.losses

Definition at line 231 of file my_callbacks.py.

my_callbacks.IterationsCallback.validation_generator

Definition at line 226 of file my_callbacks.py.

my_callbacks.IterationsCallback.validation_steps

Definition at line 227 of file my_callbacks.py.


The documentation for this class was generated from the following file: