def update()

in tools/stats.py [0:0]


    def update(self, preds, time_start=None,
               freeze_iter=False, stat_set='train'):

        if self.epoch == -1:  # uninitialized
            print(
                "warning: epoch==-1 means uninitialized stats structure\
                 -> new_epoch() called")
            self.new_epoch()

        if stat_set not in self.stats:
            self.stats[stat_set] = {}
            self.it[stat_set] = -1

        if not freeze_iter:
            self.it[stat_set] += 1

        epoch = self.epoch
        it = self.it[stat_set]

        for stat in self.log_vars:

            if stat not in self.stats[stat_set]:
                self.stats[stat_set][stat] = AverageMeter()

            if stat == 'sec/it':  # compute speed
                if time_start is None:
                    elapsed = 0.
                else:
                    elapsed = time.time() - time_start
                time_per_it = float(elapsed) / float(it+1)
                val = time_per_it
            else:
                if stat in preds:
                    try:
                        val = self.gather_value(preds[stat])
                    except:
                        raise ValueError("could not extract prediction %s\
                                          from the prediction dictionary" %
                                         stat)
                else:
                    val = None

            if val is not None:
                self.stats[stat_set][stat].update(val, epoch=epoch, n=1)