You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

History.cs 1.7 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace Tensorflow.Keras.Callbacks
  5. {
  6. public class History : ICallback
  7. {
  8. List<int> epochs;
  9. CallbackParams _parameters;
  10. public Dictionary<string, List<float>> history { get; set; }
  11. public History(CallbackParams parameters)
  12. {
  13. _parameters = parameters;
  14. }
  15. public void on_train_begin()
  16. {
  17. epochs = new List<int>();
  18. history = new Dictionary<string, List<float>>();
  19. }
  20. public void on_epoch_begin(int epoch)
  21. {
  22. }
  23. public void on_train_batch_begin(long step)
  24. {
  25. }
  26. public void on_train_batch_end(long end_step, Dictionary<string, float> logs)
  27. {
  28. }
  29. public void on_epoch_end(int epoch, Dictionary<string, float> epoch_logs)
  30. {
  31. epochs.Add(epoch);
  32. foreach (var log in epoch_logs)
  33. {
  34. if (!history.ContainsKey(log.Key))
  35. {
  36. history[log.Key] = new List<float>();
  37. }
  38. history[log.Key].Add((float)log.Value);
  39. }
  40. }
  41. public void on_predict_begin()
  42. {
  43. epochs = new List<int>();
  44. history = new Dictionary<string, List<float>>();
  45. }
  46. public void on_predict_batch_begin(long step)
  47. {
  48. }
  49. public void on_predict_batch_end(long end_step, Dictionary<string, Tensors> logs)
  50. {
  51. }
  52. public void on_predict_end()
  53. {
  54. }
  55. }
  56. }