Assistant

Helper modules for training and testing routines.

class slayerSNN.auto.assistant.Assistant(net, trainLoader, testLoader, error, optimizer, scheduler=None, stats=None, dataParallel=False, showTimeSteps=False, lossScale=None, printInterval=1)[source]

This class provides standard assistant functionalities for traiing and testing workflow. If you want a different workflow than what is available, you should inherit this module and overload the particular module to your need.

Arguments:
  • net: the SLAYER network to be run.

  • trainLoader: training dataloader.

  • testLoader: testing dataloader.

  • error: a function object or a lamda function that takes (output, target, label) as its input and returns

    a scalar error value.

  • optimizer: the learning optimizer.

  • scheduler: the learning scheduler. Default: None meaning no scheduler will be used.

  • stats: the SLAYER learning stats logger: slayerSNN.stats. Default: None meaning no stats will be used.

  • dataParallel: flag if dataParallel execution needs to be handled. Default: False.

  • showTimeSteps: flag to print timesteps of the sample or not. Default: False.

  • lossScale: a scale factor to be used while printing the loss. Default: None meaning no scaling is done.

  • printInterval: number of epochs to print the lerning output once. Default: 1.

Usage:

assist = assistant(net, trainLoader, testLoader, lambda o, t, l: error.numSpikes(o, t), optimizer, stats)

for epoch in range(maxEpoch): 
    assist.train(epoch)
    assist.test(epoch)
test(epoch=0, evalLoss=True, slidingWindow=None, breakIter=None)[source]

Testing assistant fucntion.

Arguments:
  • epoch: training epoch number.

  • evalLoss: a flag to enable or disable loss evalutaion. Default: True.

  • slidingWindow: the length of sliding window to use for continuous output prediction over time.

    None means total spike count is used to produce one output per sample. If it is not None, evalLoss is overwritten to False. Default: None.

  • breakIter: number of samples to wait before breaking out of the testing loop.

    None means go over the complete training samples. Default: None.

train(epoch=0, breakIter=None)[source]

Training assistant fucntion.

Arguments:
  • epoch: training epoch number.

  • breakIter: number of samples to wait before breaking out of the training loop.

    None means go over the complete training samples. Default: None.