Browse Source

GC.Collect in ComputeGradient

tags/TimeSeries
Oceania2018 4 years ago
parent
commit
c93c21994c
1 changed files with 4 additions and 0 deletions
  1. +4
    -0
      src/TensorFlowNET.Core/Gradients/Tape.ComputeGradient.cs

+ 4
- 0
src/TensorFlowNET.Core/Gradients/Tape.ComputeGradient.cs View File

@@ -26,6 +26,7 @@ namespace Tensorflow.Gradients
tensor_tape_, tensor_tape_,
state.op_tape); state.op_tape);


int gcCollectFlag = 0;
while (!op_stack.empty()) while (!op_stack.empty())
{ {
var op = op_stack.Dequeue(); var op = op_stack.Dequeue();
@@ -154,6 +155,9 @@ namespace Tensorflow.Gradients
op_stack.Enqueue(op_id); op_stack.Enqueue(op_id);
} }
} }

if (gcCollectFlag++ % 10 == 0)
GC.Collect();
} }


if (state.op_tape.Count > 0) if (state.op_tape.Count > 0)


Loading…
Cancel
Save