Browse Source

Merge pull request #239 from JuanuMusic/master

Added get_tensor_by_name method to Graph
tags/v0.9
Haiping GitHub 6 years ago
parent
commit
212061a0cc
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions
  1. +13
    -1
      src/TensorFlowNET.Core/Graphs/Graph.cs
  2. +2
    -0
      src/TensorFlowNET.Core/ops.GraphKeys.cs

+ 13
- 1
src/TensorFlowNET.Core/Graphs/Graph.cs View File

@@ -388,7 +388,7 @@ namespace Tensorflow
var handle = return_oper_handle.node + Marshal.SizeOf<TF_Operation>() * i; var handle = return_oper_handle.node + Marshal.SizeOf<TF_Operation>() * i;
return_opers[i] = new Operation(*(IntPtr*)handle); return_opers[i] = new Operation(*(IntPtr*)handle);
} }
return return_opers; return return_opers;
} }


@@ -439,6 +439,18 @@ namespace Tensorflow
c_api.TF_DeleteGraph(_handle); c_api.TF_DeleteGraph(_handle);
} }


/// <summary>
/// Returns the <see cref="Tensor"/> with the given <paramref name="name"/>.
/// This method may be called concurrently from multiple threads.
/// </summary>
/// <param name="name">The name of the `Tensor` to return.</param>
/// <exception cref="KeyError">If <paramref name="name"/> does not correspond to a tensor in this graph.</exception>
/// <returns>The `Tensor` with the given <paramref name="name"/>.</returns>
public Tensor get_tensor_by_name(string name)
{
return (Tensor)this.as_graph_element(name, allow_tensor: true, allow_operation: false);
}

public void __enter__() public void __enter__()
{ {
} }


+ 2
- 0
src/TensorFlowNET.Core/ops.GraphKeys.cs View File

@@ -35,6 +35,8 @@ namespace Tensorflow


public static string TRAIN_OP = "train_op"; 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" }; public static string[] _VARIABLE_COLLECTIONS = new string[] { "variables", "trainable_variables" };
/// <summary> /// <summary>
/// Key to collect BaseSaverBuilder.SaveableObject instances for checkpointing. /// Key to collect BaseSaverBuilder.SaveableObject instances for checkpointing.


Loading…
Cancel
Save