FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

GC.Collect in ComputeGradient · MSavameri/TensorFlow.NET@c93c219 · GitHub

Commit c93c219

Browse files
committed
GC.Collect in ComputeGradient
1 parent de80bfe commit c93c219

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎src/TensorFlowNET.Core/Gradients/Tape.ComputeGradient.cs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public Tensor[] ComputeGradient(Tensor[] target_tensor_ids,
2626
tensor_tape_,
2727
state.op_tape);
2828

29+
int gcCollectFlag = 0;
2930
while (!op_stack.empty())
3031
{
3132
var op = op_stack.Dequeue();
@@ -154,6 +155,9 @@ public Tensor[] ComputeGradient(Tensor[] target_tensor_ids,
154155
op_stack.Enqueue(op_id);
155156
}
156157
}
158+
159+
if (gcCollectFlag++ % 10 == 0)
160+
GC.Collect();
157161
}
158162

159163
if (state.op_tape.Count > 0)

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL