| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 9edada5 commit 70df2bb
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -43,7 +43,8 @@ public Optimizer AdamOptimizer(Tensor learning_rate, string name = "Adam") | |||
| 43 | 43 | public ExponentialMovingAverage ExponentialMovingAverage(float decay) | |
| 44 | 44 | => new ExponentialMovingAverage(decay); | |
| 45 | 45 | ||
| 46 | - public Saver Saver(VariableV1[] var_list = null) => new Saver(var_list: var_list); | ||
| 46 | + public Saver Saver(VariableV1[] var_list = null, int max_to_keep = 5) | ||
| 47 | + => new Saver(var_list: var_list, max_to_keep: max_to_keep); | ||
| 47 | 48 | ||
| 48 | 49 | public string write_graph(Graph graph, string logdir, string name, bool as_text = true) | |
| 49 | 50 | => graph_io.write_graph(graph, logdir, name, as_text); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -108,10 +108,7 @@ public static Tensor[] _GradientsHelper(Tensor[] ys, | |||
| 108 | 108 | { | |
| 109 | 109 | // generate gradient subgraph for op. | |
| 110 | 110 | var op = queue.Dequeue(); | |
| 111 | - if(tf.get_default_graph()._nodes_by_name.Count >= 23868) | ||
| 112 | - { | ||
| 113 | 111 | ||
| 114 | - } | ||
| 115 | 112 | _maybe_colocate_with(op, gradient_uid, colocate_gradients_with_ops); | |
| 116 | 113 | //if (loop_state != null) | |
| 117 | 114 | //loop_state.EnterGradWhileContext(op, before: true); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -54,6 +54,8 @@ public class Main : IExample | |||
| 54 | 54 | List<RefVariable> first_stage_trainable_var_list; | |
| 55 | 55 | Operation train_op_with_frozen_variables; | |
| 56 | 56 | Operation train_op_with_all_variables; | |
| 57 | + Saver loader; | ||
| 58 | + Saver saver; | ||
| 57 | 59 | #endregion | |
| 58 | 60 | ||
| 59 | 61 | public bool Run() | |
@@ -74,7 +76,9 @@ public bool Run() | |||
| 74 | 76 | ||
| 75 | 77 | public void Train(Session sess) | |
| 76 | 78 | { | |
| 77 | - | ||
| 79 | + sess.run(tf.global_variables_initializer()); | ||
| 80 | + print($"=> Restoring weights from: {cfg.TRAIN.INITIAL_WEIGHT} ... "); | ||
| 81 | + loader.restore(sess, cfg.TRAIN.INITIAL_WEIGHT); | ||
| 78 | 82 | } | |
| 79 | 83 | ||
| 80 | 84 | public void Test(Session sess) | |
@@ -184,6 +188,21 @@ public Graph BuildGraph() | |||
| 184 | 188 | }); | |
| 185 | 189 | }); | |
| 186 | 190 | ||
| 191 | + tf_with(tf.name_scope("loader_and_saver"), delegate | ||
| 192 | + { | ||
| 193 | + loader = tf.train.Saver(net_var); | ||
| 194 | + saver = tf.train.Saver(tf.global_variables(), max_to_keep: 10); | ||
| 195 | + }); | ||
| 196 | + | ||
| 197 | + tf_with(tf.name_scope("summary"), delegate | ||
| 198 | + { | ||
| 199 | + tf.summary.scalar("learn_rate", learn_rate); | ||
| 200 | + tf.summary.scalar("giou_loss", giou_loss); | ||
| 201 | + tf.summary.scalar("conf_loss", conf_loss); | ||
| 202 | + tf.summary.scalar("prob_loss", prob_loss); | ||
| 203 | + tf.summary.scalar("total_loss", loss); | ||
| 204 | + }); | ||
| 205 | + | ||
| 187 | 206 | return graph; | |
| 188 | 207 | } | |
| 189 | 208 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -60,7 +60,7 @@ public class TrainConfig | |||
| 60 | 60 | public TrainConfig(string root) | |
| 61 | 61 | { | |
| 62 | 62 | _root = root; | |
| 63 | - INITIAL_WEIGHT = Path.Combine(_root, "data", "checkpoint", "yolov3_coco_demo.ckpt"); | ||
| 63 | + INITIAL_WEIGHT = Path.Combine(_root, "checkpoint", "yolov3_coco_demo.ckpt"); | ||
| 64 | 64 | ANNOT_PATH = Path.Combine(_root, "data", "dataset", "voc_train.txt"); | |
| 65 | 65 | } | |
| 66 | 66 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments