From 87eac0c0f88547ea4d1ff7100f9c3b9d87b098eb Mon Sep 17 00:00:00 2001 From: Oceania2018 Date: Mon, 15 Apr 2019 20:59:32 -0500 Subject: [PATCH] add math.round --- src/TensorFlowNET.Core/APIs/tf.math.cs | 3 +++ .../Operations/gen_math_ops.cs | 22 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/TensorFlowNET.Core/APIs/tf.math.cs b/src/TensorFlowNET.Core/APIs/tf.math.cs index fbf3dd00..5c31fce0 100644 --- a/src/TensorFlowNET.Core/APIs/tf.math.cs +++ b/src/TensorFlowNET.Core/APIs/tf.math.cs @@ -287,6 +287,9 @@ namespace Tensorflow public static Tensor reduce_mean(Tensor input_tensor, int[] axis = null, bool keepdims = false, string name = null, int? reduction_indices = null) => math_ops.reduce_mean(input_tensor, axis: axis, keepdims: keepdims, name: name, reduction_indices: reduction_indices); + public static Tensor round(Tensor x, string name = null) + => gen_math_ops.round(x, name: name); + public static Tensor cast(Tensor x, TF_DataType dtype = TF_DataType.DtInvalid, string name = null) => math_ops.cast(x, dtype, name); diff --git a/src/TensorFlowNET.Core/Operations/gen_math_ops.cs b/src/TensorFlowNET.Core/Operations/gen_math_ops.cs index 56477442..ee6f3a39 100644 --- a/src/TensorFlowNET.Core/Operations/gen_math_ops.cs +++ b/src/TensorFlowNET.Core/Operations/gen_math_ops.cs @@ -429,6 +429,28 @@ namespace Tensorflow return _op.outputs[0]; } + /// + /// Rounds the values of a tensor to the nearest integer, element-wise. + /// + /// + /// + /// + /// If specified, the created operation in the graph will be this one, otherwise it will be named 'Round'. + /// + /// + /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. + /// + /// + /// Rounds half to even. Also known as bankers rounding. If you want to round + /// according to the current system rounding mode use std::cint. + /// + public static Tensor round(Tensor x, string name = "Round") + { + var op = _op_def_lib._apply_op_helper("Round", name: name, new { x }); + + return op.output; + } + /// /// Computes reciprocal of square root of x element-wise. ///