forked from SciSharp/TensorFlow.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHistory.cs
More file actions
88 lines (67 loc) · 1.73 KB
/
History.cs
File metadata and controls
88 lines (67 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
using Tensorflow.Keras.Engine;
namespace Tensorflow.Keras.Callbacks;
public class History : ICallback
{
List<int> epochs;
CallbackParams _parameters;
public Dictionary<string, List<float>> history { get; set; }
public History(CallbackParams parameters)
{
_parameters = parameters;
}
public void on_train_begin()
{
epochs = new List<int>();
history = new Dictionary<string, List<float>>();
}
public void on_test_begin()
{
epochs = new List<int>();
history = new Dictionary<string, List<float>>();
}
public void on_train_end() { }
public void on_epoch_begin(int epoch)
{
}
public void on_train_batch_begin(long step)
{
}
public void on_train_batch_end(long end_step, Dictionary<string, float> logs)
{
}
public void on_epoch_end(int epoch, Dictionary<string, float> epoch_logs)
{
epochs.Add(epoch);
foreach (var log in epoch_logs)
{
if (!history.ContainsKey(log.Key))
{
history[log.Key] = new List<float>();
}
history[log.Key].Add(log.Value);
}
}
public void on_predict_begin()
{
epochs = new List<int>();
history = new Dictionary<string, List<float>>();
}
public void on_predict_batch_begin(long step)
{
}
public void on_predict_batch_end(long end_step, Dictionary<string, Tensors> logs)
{
}
public void on_predict_end()
{
}
public void on_test_batch_begin(long step)
{
}
public void on_test_batch_end(long end_step, Dictionary<string, float> logs)
{
}
public void on_test_end(Dictionary<string, float> logs)
{
}
}