public void Invoke(int epoch, EvalMetric eval_metric) { if (eval_metric == null) { return; } var name_value = eval_metric.GetNameValue(); foreach (var item in name_value) { Logger.Log(string.Format("Epoch[{0}] Validation-{1}={2}", epoch, item.Key, Math.Round(item.Value, 2))); } }
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 Dictionary <string, float> Score(DataIter eval_data, EvalMetric eval_metric, int?num_batch = null, IBatchEndCallback[] batch_end_callback = null, IScoreEndCallback[] score_end_callback = null, bool reset = true, int epoch = 0, Func <DataBatch, NDArrayDict> sparse_row_id_fn = null) { if (!Binded && !ParamsInitialized) { throw new Exception("Module not binded and param initialized"); } eval_metric.Reset(); var actual_num_batch = 0; while (eval_data.End()) { if (num_batch.HasValue && eval_data.Cursor == num_batch.Value) { break; } var eval_batch = eval_data.Next(); Prepare(eval_batch, sparse_row_id_fn); Forward(eval_batch, false); UpdateMetric(eval_metric, eval_batch.Label, true); if (batch_end_callback != null) { foreach (var callback in batch_end_callback) { callback.Invoke(epoch, eval_data.Cursor, eval_metric); } } actual_num_batch++; } if (score_end_callback != null) { foreach (var callback in score_end_callback) { callback.Invoke(epoch, actual_num_batch, eval_metric, new FuncArgs()); } } return(eval_metric.GetNameValue()); }
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; } } }