From 03562ea034be73405cf37ce8615418481c898991 Mon Sep 17 00:00:00 2001 From: carb0n <58676303+carb0n@users.noreply.github.com> Date: Thu, 9 Jul 2020 18:17:13 -0400 Subject: [PATCH] add check_ops.assert_greater_equal --- .../Operations/check_ops.cs | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/TensorFlowNET.Core/Operations/check_ops.cs b/src/TensorFlowNET.Core/Operations/check_ops.cs index ef2ea3b6..b4123f70 100644 --- a/src/TensorFlowNET.Core/Operations/check_ops.cs +++ b/src/TensorFlowNET.Core/Operations/check_ops.cs @@ -56,6 +56,38 @@ namespace Tensorflow return control_flow_ops.Assert(condition, data); }); } + + public static Operation assert_greater_equal(Tensor x, Tensorflow y, object[] data = null, string message = null, + string name = null) + { + if (message == null) + message = ""; + + return tf_with(ops.name_scope(name, "assert_greater_equal", new { x, y, data}), delegate + { + x = ops.convert_to_tensor(x, name: "x"); + y = ops.convert_to_tensor(y, name: "y"); + string x_name = x.name; + string y_name = y.name; + if (data == null) + { + data = new object[] + { + message, + "Condition x >= y did not hold element-wise:", + $"x (%s) = {x_name}", + x, + $"y (%s) = {y_name}", + y + }; + } + + var condition = math_ops.reduce_all(gen_math_ops.greater_equal(x, y)); + var x_static = tensor_util.constant_value(x); + var y_static = tensor_util.constant_value(y); + return control_flow_ops.Assert(condition, data); + }); + } public static Operation assert_positive(Tensor x, object[] data = null, string message = null, string name = null) {