Skip to content

Commit 8fa1f21

Browse files
committed
change ops.name_scope interface.
1 parent bdd9bec commit 8fa1f21

File tree

23 files changed

+51
-47
lines changed

23 files changed

+51
-47
lines changed

src/TensorFlowNET.Core/Framework/importer.py.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public static ITensorOrOperation[] import_graph_def(GraphDef graph_def,
2626

2727
string prefix = "";
2828
var graph = ops.get_default_graph();
29-
with(new ops.name_scope(name, "import", input_map.Values), scope =>
29+
with(ops.name_scope(name, "import", input_map.Values), scope =>
3030
{
3131
prefix = scope;
3232
/*if (!string.IsNullOrEmpty(prefix))

src/TensorFlowNET.Core/Framework/tf.ops.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ public static object get_collection(string key, string scope = "") => get_defaul
1616
/// <param name="default_name">The default name to use if the name argument is None.</param>
1717
/// <param name="values">The list of Tensor arguments that are passed to the op function.</param>
1818
/// <returns>The scope name.</returns>
19-
public static ops.name_scope name_scope(string name,
19+
public static ops.NameScope name_scope(string name,
2020
string default_name = "",
21-
object values = null) => new ops.name_scope(name, default_name, values);
21+
object values = null) => new ops.NameScope(name, default_name, values);
2222
}
2323
}

src/TensorFlowNET.Core/Gradients/gradients_impl.py.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public static Tensor[] _GradientsHelper(Tensor[] ys,
5858
**/
5959
var grads = new Dictionary<string, Tensor[][]>();
6060

61-
with(new ops.name_scope(name, "gradients", values: all), scope =>
61+
with(ops.name_scope(name, "gradients", values: all), scope =>
6262
{
6363
string grad_scope = scope;
6464
// Get a uid for this call to gradients that can be used to help
@@ -131,7 +131,7 @@ public static Tensor[] _GradientsHelper(Tensor[] ys,
131131
// for ops that do not have gradients.
132132
var grad_fn = ops.get_gradient_function(op);
133133

134-
with(new ops.name_scope(op.name + "_grad"), scope1 =>
134+
with(ops.name_scope(op.name + "_grad"), scope1 =>
135135
{
136136
string name1 = scope1;
137137
if (grad_fn != null)

src/TensorFlowNET.Core/Keras/Engine/Layer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public Tensor __call__(Tensor inputs,
3131
bool build_graph = tf_utils.are_all_symbolic_tensors(input_list);
3232

3333
// Handle Keras mask propagation from previous layer to current layer.
34-
Python.with(new ops.name_scope(_name_scope()), delegate
34+
Python.with(ops.name_scope(_name_scope()), delegate
3535
{
3636
if (!built)
3737
{

src/TensorFlowNET.Core/Layers/Layer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ protected virtual void add_weight()
9292
auxiliary_name_scope: false), scope =>
9393
{
9494
_current_scope = scope;
95-
Python.with(new ops.name_scope(_name_scope()), delegate
95+
Python.with(ops.name_scope(_name_scope()), delegate
9696
{
9797

9898

src/TensorFlowNET.Core/Operations/Distributions/normal.py.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public Normal (Tensor loc, Tensor scale, bool validate_args=false, bool allow_na
3333
parameters.Add("validate_args", validate_args);
3434
parameters.Add("allow_nan_stats", allow_nan_stats);
3535

36-
with(new ops.name_scope(name, "", new { loc, scale }), scope =>
36+
with(ops.name_scope(name, "", new { loc, scale }), scope =>
3737
{
3838
with(ops.control_dependencies(validate_args ? new Operation[] { scale.op} : new Operation[] { }), cd =>
3939
{

src/TensorFlowNET.Core/Operations/Losses/losses_impl.py.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public Tensor sparse_softmax_cross_entropy(Tensor labels,
1212
string scope = "",
1313
string loss_collection= "losses")
1414
{
15-
with(new ops.name_scope(scope,
15+
with(ops.name_scope(scope,
1616
"sparse_softmax_cross_entropy_loss",
1717
(logits, labels, weights)),
1818
namescope =>

src/TensorFlowNET.Core/Operations/OpDefLibrary.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public Operation _apply_op_helper(string op_type_name, string name = null, dynam
4444
var input_types = new List<TF_DataType>();
4545
dynamic values = null;
4646

47-
return with(new ops.name_scope(name), scope =>
47+
return with(ops.name_scope(name), scope =>
4848
{
4949
var inferred_from = new Dictionary<string, object>();
5050
var base_types = new List<TF_DataType>();

src/TensorFlowNET.Core/Operations/array_ops.py.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class array_ops : Python
1212
public static Tensor zeros(Shape shape, TF_DataType dtype = TF_DataType.TF_FLOAT, string name = null)
1313
{
1414
dtype = dtype.as_base_dtype();
15-
return with(new ops.name_scope(name, "zeros", shape), scope =>
15+
return with(ops.name_scope(name, "zeros", shape), scope =>
1616
{
1717
name = scope;
1818
switch (dtype)
@@ -68,7 +68,7 @@ public static Tensor ones_like<T>(T tensor, TF_DataType dtype = TF_DataType.DtIn
6868

6969
private static Tensor ones_like_impl<T>(T tensor, TF_DataType dtype, string name, bool optimize = true)
7070
{
71-
return with(new ops.name_scope(name, "ones_like", new { tensor }), scope =>
71+
return with(ops.name_scope(name, "ones_like", new { tensor }), scope =>
7272
{
7373
name = scope;
7474
var tensor1 = ops.convert_to_tensor(tensor, name: "tensor");
@@ -84,7 +84,7 @@ private static Tensor ones_like_impl<T>(T tensor, TF_DataType dtype, string name
8484
public static Tensor ones(Tensor shape, TF_DataType dtype = TF_DataType.TF_FLOAT, string name = null)
8585
{
8686
dtype = dtype.as_base_dtype();
87-
return with(new ops.name_scope(name, "ones", new { shape }), scope =>
87+
return with(ops.name_scope(name, "ones", new { shape }), scope =>
8888
{
8989
name = scope;
9090
var output = gen_array_ops.fill(shape, constant_op.constant(1.0f, dtype: dtype), name: name);
@@ -130,7 +130,7 @@ public static Tensor size(Tensor input, string name = null, bool optimize = true
130130

131131
private static Tensor shape_internal(Tensor input, string name = null, bool optimize = true, TF_DataType out_type = TF_DataType.TF_INT32)
132132
{
133-
return with(new ops.name_scope(name, "Shape", new { input }), scope =>
133+
return with(ops.name_scope(name, "Shape", new { input }), scope =>
134134
{
135135
name = scope;
136136

@@ -151,7 +151,7 @@ private static Tensor shape_internal(Tensor input, string name = null, bool opti
151151

152152
private static Tensor size_internal(Tensor input, string name = null, bool optimize = true, TF_DataType out_type = TF_DataType.TF_INT32)
153153
{
154-
return with(new ops.name_scope(name, "Size", new Tensor[] { input }), scope =>
154+
return with(ops.name_scope(name, "Size", new Tensor[] { input }), scope =>
155155
{
156156
name = scope;
157157

@@ -182,7 +182,7 @@ private static Tensor size_internal(Tensor input, string name = null, bool optim
182182

183183
public static Tensor zeros_like(Tensor tensor, TF_DataType dtype = TF_DataType.DtInvalid, string name = null, bool optimize = true)
184184
{
185-
return with(new ops.name_scope(name, "zeros_like", new Tensor[] { tensor }), scope =>
185+
return with(ops.name_scope(name, "zeros_like", new Tensor[] { tensor }), scope =>
186186
{
187187
name = scope;
188188
tensor = ops.convert_to_tensor(tensor, name: "tensor");

src/TensorFlowNET.Core/Operations/control_flow_ops.py.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class control_flow_ops : Python
99
{
1010
public static Operation group<T>(T[] inputs, string name = null) where T : ITensorOrOperation
1111
{
12-
return with(new ops.name_scope(name, "group_deps", inputs), scope =>
12+
return with(ops.name_scope(name, "group_deps", inputs), scope =>
1313
{
1414
name = scope;
1515

@@ -83,7 +83,7 @@ private static bool IsLoopExit(Operation op)
8383

8484
public static Tensor[] tuple(Tensor[] tensors, string name = null, Operation[] control_inputs = null)
8585
{
86-
return with(new ops.name_scope(name, "tuple", tensors), scope =>
86+
return with(ops.name_scope(name, "tuple", tensors), scope =>
8787
{
8888
name = scope;
8989
var gating_ops = tensors.Select(x => x.op).ToList();
@@ -115,7 +115,7 @@ public static Tensor with_dependencies(Operation[] dependencies, Tensor output_t
115115
values.AddRange(dependencies);
116116
values.Add(output_tensor);
117117

118-
return with(new ops.name_scope(name, "control_dependency", values), scope =>
118+
return with(ops.name_scope(name, "control_dependency", values), scope =>
119119
{
120120
name = scope;
121121

0 commit comments

Comments
 (0)