From 5ed47f0e3ca15aa2a9f5940b748793e7a2a2be20 Mon Sep 17 00:00:00 2001 From: Lee Reid Date: Thu, 25 Mar 2021 14:21:44 +0100 Subject: [PATCH] Fixed _min --- src/TensorFlowNET.Core/Operations/gen_math_ops.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/TensorFlowNET.Core/Operations/gen_math_ops.cs b/src/TensorFlowNET.Core/Operations/gen_math_ops.cs index b4db7d88..bf3f47fc 100644 --- a/src/TensorFlowNET.Core/Operations/gen_math_ops.cs +++ b/src/TensorFlowNET.Core/Operations/gen_math_ops.cs @@ -476,8 +476,11 @@ namespace Tensorflow return _op.outputs[0]; } - public static Tensor _max(Tx input, Ty axis, bool keep_dims = false, string name = null) - => tf.Context.ExecuteOp("Max", name, new ExecuteOpArgs(input, axis) + /// + /// Subroutine for Min or Max functions. See _min and _max + /// + private static Tensor MinOrMax(Tx input, Ty axis, string methodName, bool keep_dims = false, string name = null) + => tf.Context.ExecuteOp(methodName, name, new ExecuteOpArgs(input, axis) { GetGradientAttrs = (op) => new { @@ -487,12 +490,12 @@ namespace Tensorflow } }.SetAttributes(new { keep_dims, reduction_indices = axis })); + public static Tensor _max(Tx input, Ty axis, bool keep_dims = false, string name = null) + => MinOrMax(input, axis, "Max", keep_dims: keep_dims, name: name); + public static Tensor _min(Tx input, Ty axis, bool keep_dims = false, string name = null) - { - var _op = tf.OpDefLib._apply_op_helper("Min", name, new { input, reduction_indices = axis, keep_dims }); + => MinOrMax(input, axis, "Min", keep_dims: keep_dims, name: name); - return _op.outputs[0]; - } public static Tensor pow(Tx x, Ty y, string name = null) => tf.Context.ExecuteOp("Pow", name, new ExecuteOpArgs(x, y));