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.8 kB

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