Skip to content

Add a Stop_training property #1008

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/TensorFlowNET.Core/Keras/Engine/IModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,5 @@ Tensors predict(Tensors x,

IKerasConfig get_config();

void set_stopTraining_true();
bool Stop_training { get;set; }
}
2 changes: 1 addition & 1 deletion src/TensorFlowNET.Keras/Callbacks/Earlystopping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void on_epoch_end(int epoch, Dictionary<string, float> epoch_logs)
if (_wait >= _paitence && epoch > 0)
{
_stopped_epoch = epoch;
_parameters.Model.set_stopTraining_true();
_parameters.Model.Stop_training = true;
if (_restore_best_weights && _best_weights != null)
{
if (_verbose > 0)
Expand Down
11 changes: 6 additions & 5 deletions src/TensorFlowNET.Keras/Engine/Model.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ public IOptimizer Optimizer
set => optimizer = value;
}

public bool Stop_training
{
get => stop_training;
set => stop_training = value;
}

public Model(ModelArgs args)
: base(args)
{
Expand Down Expand Up @@ -145,10 +151,5 @@ public override IDictionary<string, Trackable> _trackable_children(SaveType save
return children;
}


void IModel.set_stopTraining_true()
{
stop_training = true;
}
}
}