Skip to content

Commit 8cf46d2

Browse files
committed
_registered_ops NearestNeighbors
1 parent 86d1741 commit 8cf46d2

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

src/TensorFlowNET.Core/Framework/op_def_registry.py.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Text;
4+
using static Tensorflow.OpDef.Types;
45

56
namespace Tensorflow
67
{
@@ -19,9 +20,32 @@ public static Dictionary<string, OpDef> get_registered_ops()
1920

2021
foreach (var op_def in op_list.Op)
2122
_registered_ops[op_def.Name] = op_def;
23+
24+
if (!_registered_ops.ContainsKey("NearestNeighbors"))
25+
_registered_ops["NearestNeighbors"] = op_NearestNeighbors();
2226
}
2327

2428
return _registered_ops;
2529
}
30+
31+
/// <summary>
32+
/// Doesn't work because the op can't be found on binary
33+
/// </summary>
34+
/// <returns></returns>
35+
private static OpDef op_NearestNeighbors()
36+
{
37+
var def = new OpDef
38+
{
39+
Name = "NearestNeighbors"
40+
};
41+
42+
def.InputArg.Add(new ArgDef { Name = "points", Type = DataType.DtFloat });
43+
def.InputArg.Add(new ArgDef { Name = "centers", Type = DataType.DtFloat });
44+
def.InputArg.Add(new ArgDef { Name = "k", Type = DataType.DtInt64 });
45+
def.OutputArg.Add(new ArgDef { Name = "nearest_center_indices", Type = DataType.DtInt64 });
46+
def.OutputArg.Add(new ArgDef { Name = "nearest_center_distances", Type = DataType.DtFloat });
47+
48+
return def;
49+
}
2650
}
2751
}

test/TensorFlowNET.Examples/KMeansClustering.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ public class KMeansClustering : Python, IExample
3333

3434
public bool Run()
3535
{
36+
tf.train.import_meta_graph("kmeans.meta");
37+
3638
// Input images
3739
var X = tf.placeholder(tf.float32, shape: new TensorShape(-1, num_features));
3840
// Labels (for assigning a label to a centroid and testing)

0 commit comments

Comments
 (0)