From 69c99ec75a085990e0be69f74ae5409681c976be Mon Sep 17 00:00:00 2001 From: carb0n <58676303+carb0n@users.noreply.github.com> Date: Tue, 4 Aug 2020 23:47:32 -0400 Subject: [PATCH] replace usage of ops.name_scope() with tf_with() --- src/TensorFlowNET.Core/Operations/math_ops.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/TensorFlowNET.Core/Operations/math_ops.cs b/src/TensorFlowNET.Core/Operations/math_ops.cs index 756b9a89..8a349846 100644 --- a/src/TensorFlowNET.Core/Operations/math_ops.cs +++ b/src/TensorFlowNET.Core/Operations/math_ops.cs @@ -232,18 +232,19 @@ namespace Tensorflow public static Tensor real(Tensor input, string name = null) { - using (var name_ = ops.name_scope(name, "Real", new [] {input})) + return tf_with(ops.name_scope(name, "Real", new [] {input}), scope => { + // name = scope; input = ops.convert_to_tensor(input, name: "input"); if (input.dtype.is_complex()) { var real_dtype = input.dtype.real_dtype(); - return real(input, name: name); + return real(input, name: scope); } else { return input; } - } + }); } /// @@ -317,11 +318,11 @@ namespace Tensorflow name = "reduce_std"; // else {name = name;} - using (ops.name_scope(name)) + return tf_with(ops.name_scope(name, "reduce_std", new [] {input_tensor}), scope => { var variance = reduce_variance(input_tensor, axis: axis, keepdims: keepdims); return gen_math_ops.sqrt(variance); - } + }); } public static Tensor reduce_variance(Tensor input_tensor, int[] axis = null, bool keepdims = false, string name = null) @@ -330,7 +331,7 @@ namespace Tensorflow name = "reduce_variance"; // else {name = name;} - using (ops.name_scope(name)) + return tf_with(ops.name_scope(name, "reduce_variance", new [] {input_tensor}), scope => { var means = reduce_mean(input_tensor, axis: axis, keepdims: true); if (means.dtype.is_integer()) @@ -348,7 +349,7 @@ namespace Tensorflow squared_deviations = gen_math_ops.square(diff); } return reduce_mean(squared_deviations, axis: axis, keepdims: keepdims); - } + }); } public static Tensor sigmoid(T x, string name = null)