From c88d190a59cdf320cafdf9a07c83bb67b8e5dbe8 Mon Sep 17 00:00:00 2001 From: Oceania2018 Date: Wed, 18 Sep 2019 07:55:25 -0500 Subject: [PATCH] tf.reverse #396 --- src/TensorFlowNET.Core/APIs/tf.array.cs | 13 +++++++++++++ src/TensorFlowNET.Core/Operations/gen_array_ops.cs | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/src/TensorFlowNET.Core/APIs/tf.array.cs b/src/TensorFlowNET.Core/APIs/tf.array.cs index 5aeae19c..77549574 100644 --- a/src/TensorFlowNET.Core/APIs/tf.array.cs +++ b/src/TensorFlowNET.Core/APIs/tf.array.cs @@ -98,6 +98,19 @@ namespace Tensorflow public Tensor transpose(T1 a, int[] perm = null, string name = "transpose", bool conjugate = false) => array_ops.transpose(a, perm, name, conjugate); + /// + /// Reverses specific dimensions of a tensor. + /// + /// + /// + /// + /// + public static Tensor reverse(Tensor tensor, int[] axis, string name = null) + => gen_array_ops.reverse(tensor, axis, name: name); + + public static Tensor reverse(Tensor tensor, Tensor axis, string name = null) + => gen_array_ops.reverse(tensor, axis, name: name); + /// /// Returns the rank of a tensor. /// diff --git a/src/TensorFlowNET.Core/Operations/gen_array_ops.cs b/src/TensorFlowNET.Core/Operations/gen_array_ops.cs index a67ce996..6ed03040 100644 --- a/src/TensorFlowNET.Core/Operations/gen_array_ops.cs +++ b/src/TensorFlowNET.Core/Operations/gen_array_ops.cs @@ -228,6 +228,12 @@ namespace Tensorflow return (_op.outputs[0], _op.outputs[1]); } + public static Tensor reverse(Tensor tensor, T axis, string name = null) + { + var _op = _op_def_lib._apply_op_helper("ReverseV2", name, new { tensor, axis }); + return _op.output; + } + public static Tensor reshape(T1 tensor, T2 shape, string name = null) { var _op = _op_def_lib._apply_op_helper("Reshape", name, new { tensor, shape });