From 31a106dc23083207c3082a80fe726505edb39d18 Mon Sep 17 00:00:00 2001 From: Juanu Haedo Date: Wed, 1 May 2019 19:48:30 -0300 Subject: [PATCH 1/3] Added get_tensor_by_name to the Graph class --- src/TensorFlowNET.Core/Graphs/Graph.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/TensorFlowNET.Core/Graphs/Graph.cs b/src/TensorFlowNET.Core/Graphs/Graph.cs index f1a33371..adfbfcb9 100644 --- a/src/TensorFlowNET.Core/Graphs/Graph.cs +++ b/src/TensorFlowNET.Core/Graphs/Graph.cs @@ -388,7 +388,7 @@ namespace Tensorflow var handle = return_oper_handle.node + Marshal.SizeOf() * i; return_opers[i] = new Operation(*(IntPtr*)handle); } - + return return_opers; } @@ -439,6 +439,18 @@ namespace Tensorflow c_api.TF_DeleteGraph(_handle); } + /// + /// Returns the with the given . + /// This method may be called concurrently from multiple threads. + /// + /// The name of the `Tensor` to return. + /// If does not correspond to a tensor in this graph. + /// The `Tensor` with the given . + public ITensorOrOperation get_tensor_by_name(string name) + { + return this.as_graph_element(name, allow_tensor: true, allow_operation: false); + } + public void __enter__() { } From c654c6bc61363d22d48d06172a119ba6ab087e05 Mon Sep 17 00:00:00 2001 From: Juanu Haedo Date: Wed, 1 May 2019 21:06:47 -0300 Subject: [PATCH 2/3] - Changed return value of get_tensor_by_name --- src/TensorFlowNET.Core/Graphs/Graph.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/TensorFlowNET.Core/Graphs/Graph.cs b/src/TensorFlowNET.Core/Graphs/Graph.cs index adfbfcb9..ab228c47 100644 --- a/src/TensorFlowNET.Core/Graphs/Graph.cs +++ b/src/TensorFlowNET.Core/Graphs/Graph.cs @@ -446,9 +446,9 @@ namespace Tensorflow /// The name of the `Tensor` to return. /// If does not correspond to a tensor in this graph. /// The `Tensor` with the given . - public ITensorOrOperation get_tensor_by_name(string name) + public Tensor get_tensor_by_name(string name) { - return this.as_graph_element(name, allow_tensor: true, allow_operation: false); + return (Tensor)this.as_graph_element(name, allow_tensor: true, allow_operation: false); } public void __enter__() From eb4475c9bc39d2f88d859f292f935e897eaf8c4f Mon Sep 17 00:00:00 2001 From: Juanu Haedo Date: Wed, 1 May 2019 21:09:26 -0300 Subject: [PATCH 3/3] Added GLOBAL_STEP GraphKey --- src/TensorFlowNET.Core/ops.GraphKeys.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/TensorFlowNET.Core/ops.GraphKeys.cs b/src/TensorFlowNET.Core/ops.GraphKeys.cs index 9e1e72f2..7babae11 100644 --- a/src/TensorFlowNET.Core/ops.GraphKeys.cs +++ b/src/TensorFlowNET.Core/ops.GraphKeys.cs @@ -35,6 +35,8 @@ namespace Tensorflow public static string TRAIN_OP = "train_op"; + public static string GLOBAL_STEP = GLOBAL_STEP = "global_step"; + public static string[] _VARIABLE_COLLECTIONS = new string[] { "variables", "trainable_variables" }; /// /// Key to collect BaseSaverBuilder.SaveableObject instances for checkpointing.