forked from SciSharp/TensorFlow.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModel.Save.cs
More file actions
41 lines (39 loc) · 1.25 KB
/
Model.Save.cs
File metadata and controls
41 lines (39 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System.Collections.Generic;
using Tensorflow.Functions;
using Tensorflow.Keras.Metrics;
using Tensorflow.Keras.Saving;
using Tensorflow.Keras.Saving.SavedModel;
using Tensorflow.ModelSaving;
namespace Tensorflow.Keras.Engine
{
public partial class Model
{
ModelSaver saver = new ModelSaver();
/// <summary>
/// Saves the model to Tensorflow SavedModel or a single HDF5 file.
/// </summary>
/// <param name="filepath"></param>
/// <param name="overwrite"></param>
/// <param name="include_optimizer"></param>
public void save(string filepath,
bool overwrite = true,
bool include_optimizer = true,
string save_format = "tf",
SaveOptions? options = null,
ConcreteFunction? signatures = null,
bool save_traces = true)
{
if (save_format != "tf")
{
saver.save(this, filepath);
}
else
{
using (SharedObjectSavingScope.Enter())
{
KerasSavedModelUtils.save_model(this, filepath, overwrite, include_optimizer, signatures, options, save_traces);
}
}
}
}
}