Skip to content

Commit 178cdbc

Browse files
lsylusiyaoEsther2013
authored andcommitted
Add verbose function
1 parent d89609a commit 178cdbc

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/TensorFlowNET.Keras/Engine/Model.Fit.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public void fit(NDArray x, NDArray y,
5151
StepsPerExecution = _steps_per_execution
5252
});
5353

54-
FitInternal(epochs);
54+
FitInternal(epochs, verbose);
5555
}
5656

5757
public void fit(IDatasetV2 dataset,
@@ -80,10 +80,10 @@ public void fit(IDatasetV2 dataset,
8080
StepsPerExecution = _steps_per_execution
8181
});
8282

83-
FitInternal(epochs);
83+
FitInternal(epochs, verbose);
8484
}
8585

86-
void FitInternal(int epochs)
86+
void FitInternal(int epochs, int verbose)
8787
{
8888
stop_training = false;
8989
_train_counter.assign(0);
@@ -96,8 +96,11 @@ void FitInternal(int epochs)
9696
{
9797
// callbacks.on_train_batch_begin(step)
9898
var results = train_step_function(iterator);
99-
var result_pairs = string.Join(", ", results.Select(x => $"{x.Item1}: {(float)x.Item2:F6}"));
100-
Console.WriteLine($"Epoch: {epoch + 1:D3}/{epochs:D3}, Step: {step + 1:D4}/{data_handler.Inferredsteps:D4}, {result_pairs}");
99+
if (verbose == 1)
100+
{
101+
var result_pairs = string.Join(", ", results.Select(x => $"{x.Item1}: {(float)x.Item2:F6}"));
102+
Console.WriteLine($"Epoch: {epoch + 1:D3}/{epochs:D3}, Step: {step + 1:D4}/{data_handler.Inferredsteps:D4}, {result_pairs}");
103+
}
101104
}
102105

103106
GC.Collect();

0 commit comments

Comments
 (0)