Skip to content

Commit 43febca

Browse files
committed
added many not implemented interfaces for Object Detection API. SciSharp#386
1 parent dc4a4c2 commit 43febca

17 files changed

Lines changed: 242 additions & 22 deletions

File tree

src/TensorFlowNET.Core/APIs/tf.estimator.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,25 @@ public Estimator Estimator(RunConfig config)
3232
public RunConfig RunConfig(string model_dir)
3333
=> new RunConfig(model_dir: model_dir);
3434

35-
public void train_and_evaluate()
36-
=> Training.train_and_evaluate();
35+
public void train_and_evaluate(Estimator estimator, TrainSpec train_spec, EvalSpec eval_spec)
36+
=> Training.train_and_evaluate(estimator: estimator, train_spec: train_spec, eval_spec: eval_spec);
37+
38+
public TrainSpec TrainSpec(Action input_fn, int max_steps)
39+
=> new TrainSpec(input_fn: input_fn, max_steps: max_steps);
40+
41+
/// <summary>
42+
/// Create an `Exporter` to use with `tf.estimator.EvalSpec`.
43+
/// </summary>
44+
/// <param name="name"></param>
45+
/// <param name="serving_input_receiver_fn"></param>
46+
/// <param name="as_text"></param>
47+
/// <returns></returns>
48+
public FinalExporter FinalExporter(string name, Action serving_input_receiver_fn, bool as_text = false)
49+
=> new FinalExporter(name: name, serving_input_receiver_fn: serving_input_receiver_fn,
50+
as_text: as_text);
51+
52+
public EvalSpec EvalSpec(string name, Action input_fn, FinalExporter exporters)
53+
=> new EvalSpec(name: name, input_fn: input_fn, exporters: exporters);
3754
}
3855
}
3956
}

src/TensorFlowNET.Core/Binding.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Dynamic;
34
using System.Text;
45

56
namespace Tensorflow
@@ -17,6 +18,7 @@ public static partial class Binding
1718
/// <summary>
1819
/// Used for TensorShape None
1920
/// </summary>
21+
///
2022
public static readonly int Unknown = -1;
2123
}
2224
}

src/TensorFlowNET.Core/Estimators/Estimator.cs

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,44 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Text;
4+
using static Tensorflow.Binding;
45

56
namespace Tensorflow.Estimators
67
{
8+
/// <summary>
9+
/// Estimator class to train and evaluate TensorFlow models.
10+
/// </summary>
711
public class Estimator : IObjectLife
812
{
9-
public RunConfig config;
13+
RunConfig _config;
14+
ConfigProto _session_config;
15+
string _model_dir;
1016

1117
public Estimator(RunConfig config)
1218
{
13-
this.config = config;
19+
_config = config;
20+
_model_dir = _config.model_dir;
21+
_session_config = _config.session_config;
22+
}
23+
24+
public Estimator train(Action input_fn, int max_steps = 1,
25+
_NewCheckpointListenerForEvaluate[] saving_listeners = null)
26+
{
27+
_train_model();
28+
throw new NotImplementedException("");
29+
}
30+
31+
private void _train_model()
32+
{
33+
_train_model_default();
34+
}
35+
36+
private void _train_model_default()
37+
{
38+
using (var g = tf.Graph().as_default())
39+
{
40+
41+
}
1442
}
1543

1644
public void __init__()
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace Tensorflow.Estimators
6+
{
7+
public class EvalSpec
8+
{
9+
public EvalSpec(string name, Action input_fn, FinalExporter exporters)
10+
{
11+
12+
}
13+
}
14+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace Tensorflow.Estimators
6+
{
7+
public abstract class Exporter
8+
{
9+
public abstract void export(Estimator estimator, string export_path, string checkpoint_path);
10+
}
11+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace Tensorflow.Estimators
6+
{
7+
public class FinalExporter
8+
{
9+
public FinalExporter(string name, Action serving_input_receiver_fn, bool as_text = false)
10+
{
11+
12+
}
13+
}
14+
}

src/TensorFlowNET.Core/Estimators/RunConfig.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ namespace Tensorflow.Estimators
44
{
55
public class RunConfig
66
{
7+
public string model_dir { get; set; }
8+
public ConfigProto session_config { get; set; }
9+
710
public RunConfig(string model_dir)
811
{
9-
12+
this.model_dir = model_dir;
1013
}
1114
}
1215
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace Tensorflow.Estimators
6+
{
7+
public class TrainSpec
8+
{
9+
public int max_steps { get; set; }
10+
11+
public TrainSpec(Action input_fn, int max_steps)
12+
{
13+
this.max_steps = max_steps;
14+
}
15+
}
16+
}

src/TensorFlowNET.Core/Estimators/Training.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ namespace Tensorflow.Estimators
66
{
77
public class Training
88
{
9-
public static void train_and_evaluate()
9+
public static void train_and_evaluate(Estimator estimator, TrainSpec train_spec, EvalSpec eval_spec)
1010
{
11-
var executor = new _TrainingExecutor();
11+
var executor = new _TrainingExecutor(estimator: estimator, train_spec: train_spec, eval_spec: eval_spec);
1212
executor.run();
1313
}
1414
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace Tensorflow.Estimators
6+
{
7+
public class _Evaluator
8+
{
9+
public _Evaluator(Estimator estimator, EvalSpec eval_spec, int max_training_steps)
10+
{
11+
12+
}
13+
}
14+
}

0 commit comments

Comments
 (0)