Browse Source

replace usage of ops.name_scope() with tf_with()

pull/598/head
carb0n GitHub 5 years ago
parent
commit
69c99ec75a
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 7 deletions
  1. +8
    -7
      src/TensorFlowNET.Core/Operations/math_ops.cs

+ 8
- 7
src/TensorFlowNET.Core/Operations/math_ops.cs View File

@@ -232,18 +232,19 @@ namespace Tensorflow
public static Tensor real(Tensor input, string name = null) 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"); input = ops.convert_to_tensor(input, name: "input");
if (input.dtype.is_complex()) if (input.dtype.is_complex())
{ {
var real_dtype = input.dtype.real_dtype(); var real_dtype = input.dtype.real_dtype();
return real(input, name: name);
return real(input, name: scope);
} else } else
{ {
return input; return input;
} }
}
});
} }


/// <summary> /// <summary>
@@ -317,11 +318,11 @@ namespace Tensorflow
name = "reduce_std"; name = "reduce_std";
// else {name = name;} // 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); var variance = reduce_variance(input_tensor, axis: axis, keepdims: keepdims);
return gen_math_ops.sqrt(variance); return gen_math_ops.sqrt(variance);
}
});
} }
public static Tensor reduce_variance(Tensor input_tensor, int[] axis = null, bool keepdims = false, string name = null) 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"; name = "reduce_variance";
// else {name = name;} // 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); var means = reduce_mean(input_tensor, axis: axis, keepdims: true);
if (means.dtype.is_integer()) if (means.dtype.is_integer())
@@ -348,7 +349,7 @@ namespace Tensorflow
squared_deviations = gen_math_ops.square(diff); squared_deviations = gen_math_ops.square(diff);
} }
return reduce_mean(squared_deviations, axis: axis, keepdims: keepdims); return reduce_mean(squared_deviations, axis: axis, keepdims: keepdims);
}
});
} }


public static Tensor sigmoid<T>(T x, string name = null) public static Tensor sigmoid<T>(T x, string name = null)


Loading…
Cancel
Save