Skip to content

Commit 0006bba

Browse files
hcurEsther2013
authored andcommitted
implement check_ops.assert_greater_equal()
* implement check_ops.assert_greater_equal() * add outward-facing api function
1 parent 08862d2 commit 0006bba

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,15 @@ public Tensor assert_equal<T1, T2>(T1 t1,
4040
message: message,
4141
name: name);
4242

43+
public Tensor assert_greater_equal<T1, T2>(Tensor x,
44+
Tensor y,
45+
object[] data = null,
46+
string message = null,
47+
string name = null)
48+
=> check_ops.assert_greater_equal(x,
49+
y,
50+
data: data,
51+
message: message,
52+
name: name);
4353
}
4454
}

src/TensorFlowNET.Core/Operations/check_ops.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,37 @@ public static Operation assert_equal<T1, T2>(T1 t1, T2 t2, object[] data = null,
5656
return control_flow_ops.Assert(condition, data);
5757
});
5858
}
59+
60+
public static Operation assert_greater_equal(Tensor x, Tensor y, object[] data = null, string message = null,
61+
string name = null)
62+
{
63+
if (message == null)
64+
message = "";
65+
66+
return tf_with(ops.name_scope(name, "assert_greater_equal", new {x, y, data}), delegate
67+
{
68+
x = ops.convert_to_tensor(x, name: "x");
69+
y = ops.convert_to_tensor(y, name: "y");
70+
string x_name = x.name;
71+
string y_name = y.name;
72+
if (data == null)
73+
{
74+
data = new object[]
75+
{
76+
message,
77+
"Condition x >= y did not hold element-wise:",
78+
$"x (%s) = {x_name}",
79+
x,
80+
$"y (%s) = {y_name}",
81+
y
82+
};
83+
}
84+
85+
var condition = math_ops.reduce_all(gen_math_ops.greater_equal(x, y));
86+
return control_flow_ops.Assert(condition, data);
87+
});
88+
}
89+
5990

6091
public static Operation assert_positive(Tensor x, object[] data = null, string message = null, string name = null)
6192
{

0 commit comments

Comments
 (0)