public void Invoke(int epoch, int nbatch, EvalMetric eval_metric, FuncArgs locals = null) { if (nbatch % _period == 0 && eval_metric != null) { var name_values = eval_metric.GetNameValue(); foreach (var item in name_values) { Logger.Log(string.Format("Iter: {0} Batch: {1} Train-{2}={3}", epoch, nbatch, item.Key, item.Value)); } if (_auto_reset) { eval_metric.ResetLocal(); } } }
public void Invoke(int epoch, int nbatch, EvalMetric eval_metric, FuncArgs locals = null) { var count = nbatch; float speed; string msg; if (last_count > count) { init = false; } last_count = count; if (init) { if (count % _frequent == 0) { try { speed = (float)Math.Round(_frequent * (float)_batch_size / (DateTime.Now.Ticks - tic)); } catch (DivideByZeroException ex) { speed = float.PositiveInfinity; } if (eval_metric != null) { var name_value = eval_metric.GetNameValue(); if (_auto_reset) { eval_metric.ResetLocal(); msg = string.Format("Epoch[{0}] Batch [{1}-{2}]\tSpeed: {3} samples/sec", epoch, count - _frequent, count, speed); foreach (var item in name_value) { msg += string.Format("\t {0}={1}", item.Key, item.Value); } Logger.Log(msg); } else { msg = string.Format("Epoch[{0}] Batch [0-{1}]\tSpeed: {2} samples/sec", epoch, count, speed); foreach (var item in name_value) { msg += string.Format("\t {0}={1}", item.Key, item.Value); } Logger.Log(msg); } } else { Logger.Log(string.Format("Iter[{0}] Batch [{1}]\tSpeed: {} samples/sec", epoch, _batch_size, speed)); } tic = DateTime.Now.Ticks; } else { init = true; tic = DateTime.Now.Ticks; } } }