|
1 | 1 | using System; |
2 | 2 | using System.Collections.Generic; |
3 | 3 | using System.Text; |
| 4 | +using Tensorflow.Keras.Engine; |
4 | 5 |
|
5 | | -namespace Tensorflow.Keras.Callbacks |
| 6 | +namespace Tensorflow.Keras.Callbacks; |
| 7 | + |
| 8 | +public class CallbackList |
6 | 9 | { |
7 | | - public class CallbackList |
8 | | - { |
9 | | - List<ICallback> callbacks = new List<ICallback>(); |
10 | | - public History History => callbacks[0] as History; |
11 | | - |
12 | | - public CallbackList(CallbackParams parameters) |
13 | | - { |
14 | | - callbacks.Add(new History(parameters)); |
15 | | - callbacks.Add(new ProgbarLogger(parameters)); |
16 | | - } |
17 | | - |
18 | | - public void on_train_begin() |
19 | | - { |
20 | | - callbacks.ForEach(x => x.on_train_begin()); |
21 | | - } |
22 | | - |
23 | | - public void on_epoch_begin(int epoch) |
24 | | - { |
25 | | - callbacks.ForEach(x => x.on_epoch_begin(epoch)); |
26 | | - } |
27 | | - |
28 | | - public void on_train_batch_begin(long step) |
29 | | - { |
30 | | - callbacks.ForEach(x => x.on_train_batch_begin(step)); |
31 | | - } |
32 | | - |
33 | | - public void on_train_batch_end(long end_step, Dictionary<string, float> logs) |
34 | | - { |
35 | | - callbacks.ForEach(x => x.on_train_batch_end(end_step, logs)); |
36 | | - } |
37 | | - |
38 | | - public void on_epoch_end(int epoch, Dictionary<string, float> epoch_logs) |
39 | | - { |
40 | | - callbacks.ForEach(x => x.on_epoch_end(epoch, epoch_logs)); |
41 | | - } |
42 | | - |
43 | | - public void on_predict_begin() |
44 | | - { |
45 | | - callbacks.ForEach(x => x.on_predict_begin()); |
46 | | - } |
47 | | - |
48 | | - public void on_predict_batch_begin(long step) |
49 | | - { |
50 | | - callbacks.ForEach(x => x.on_predict_batch_begin(step)); |
51 | | - } |
52 | | - |
53 | | - public void on_predict_batch_end(long end_step, Dictionary<string, Tensors> logs) |
54 | | - { |
55 | | - callbacks.ForEach(x => x.on_predict_batch_end(end_step, logs)); |
56 | | - } |
57 | | - |
58 | | - public void on_predict_end() |
59 | | - { |
60 | | - callbacks.ForEach(x => x.on_predict_end()); |
61 | | - } |
| 10 | + List<ICallback> callbacks = new List<ICallback>(); |
| 11 | + public History History => callbacks[0] as History; |
| 12 | + |
| 13 | + public CallbackList(CallbackParams parameters) |
| 14 | + { |
| 15 | + callbacks.Add(new History(parameters)); |
| 16 | + callbacks.Add(new ProgbarLogger(parameters)); |
| 17 | + } |
| 18 | + |
| 19 | + public void on_train_begin() |
| 20 | + { |
| 21 | + callbacks.ForEach(x => x.on_train_begin()); |
| 22 | + } |
| 23 | + |
| 24 | + public void on_epoch_begin(int epoch) |
| 25 | + { |
| 26 | + callbacks.ForEach(x => x.on_epoch_begin(epoch)); |
| 27 | + } |
| 28 | + |
| 29 | + public void on_train_batch_begin(long step) |
| 30 | + { |
| 31 | + callbacks.ForEach(x => x.on_train_batch_begin(step)); |
| 32 | + } |
| 33 | + |
| 34 | + public void on_train_batch_end(long end_step, Dictionary<string, float> logs) |
| 35 | + { |
| 36 | + callbacks.ForEach(x => x.on_train_batch_end(end_step, logs)); |
| 37 | + } |
| 38 | + |
| 39 | + public void on_epoch_end(int epoch, Dictionary<string, float> epoch_logs) |
| 40 | + { |
| 41 | + callbacks.ForEach(x => x.on_epoch_end(epoch, epoch_logs)); |
| 42 | + } |
| 43 | + |
| 44 | + public void on_predict_begin() |
| 45 | + { |
| 46 | + callbacks.ForEach(x => x.on_predict_begin()); |
| 47 | + } |
| 48 | + |
| 49 | + public void on_predict_batch_begin(long step) |
| 50 | + { |
| 51 | + callbacks.ForEach(x => x.on_predict_batch_begin(step)); |
| 52 | + } |
| 53 | + |
| 54 | + public void on_predict_batch_end(long end_step, Dictionary<string, Tensors> logs) |
| 55 | + { |
| 56 | + callbacks.ForEach(x => x.on_predict_batch_end(end_step, logs)); |
| 57 | + } |
| 58 | + |
| 59 | + public void on_predict_end() |
| 60 | + { |
| 61 | + callbacks.ForEach(x => x.on_predict_end()); |
62 | 62 | } |
63 | 63 | } |
0 commit comments