Browse Source

Expose tf.shape() API.

tags/v0.12
Oceania2018 6 years ago
parent
commit
b1bd05c1a1
5 changed files with 20 additions and 6 deletions
  1. +10
    -0
      src/TensorFlowNET.Core/APIs/tf.array.cs
  2. +1
    -1
      src/TensorFlowNET.Core/Operations/array_ops.py.cs
  3. +1
    -1
      src/TensorFlowNET.Core/TensorFlowNET.Core.csproj
  4. +5
    -2
      test/TensorFlowNET.Examples/ImageProcessing/YOLO/common.cs
  5. +3
    -2
      test/TensorFlowNET.UnitTest/ImageTest.cs

+ 10
- 0
src/TensorFlowNET.Core/APIs/tf.array.cs View File

@@ -124,5 +124,15 @@ namespace Tensorflow
/// <returns>A `Tensor`. Has the same type as `input`.</returns>
public Tensor placeholder_with_default<T>(T input, int[] shape, string name = null)
=> gen_array_ops.placeholder_with_default(input, shape, name: name);

/// <summary>
/// Returns the shape of a tensor.
/// </summary>
/// <param name="input"></param>
/// <param name="name"></param>
/// <param name="out_type"></param>
/// <returns></returns>
public Tensor shape(Tensor input, string name = null, TF_DataType out_type = TF_DataType.TF_INT32)
=> array_ops.shape_internal(input, name, optimize: true, out_type: out_type);
}
}

+ 1
- 1
src/TensorFlowNET.Core/Operations/array_ops.py.cs View File

@@ -338,7 +338,7 @@ namespace Tensorflow
public static Tensor size(Tensor input, string name = null, bool optimize = true, TF_DataType out_type = TF_DataType.TF_INT32)
=> size_internal(input, name, optimize: optimize, out_type: out_type);
private static Tensor shape_internal(Tensor input, string name = null, bool optimize = true, TF_DataType out_type = TF_DataType.TF_INT32)
public static Tensor shape_internal(Tensor input, string name = null, bool optimize = true, TF_DataType out_type = TF_DataType.TF_INT32)
{
return tf_with(ops.name_scope(name, "Shape", new { input }), scope =>
{


+ 1
- 1
src/TensorFlowNET.Core/TensorFlowNET.Core.csproj View File

@@ -26,7 +26,7 @@ Docs: https://tensorflownet.readthedocs.io</Description>
5. Overload session.run(), make syntax simpler.
6. Add Local Response Normalization.
7. Add tf.image related APIs.
8. Add tf.random_normal, tf.constant, tf.pad.
8. Add tf.random_normal, tf.constant, tf.pad, tf.shape.
9. MultiThread is safe.</PackageReleaseNotes>
<LangVersion>7.3</LangVersion>
<FileVersion>0.11.2.0</FileVersion>


+ 5
- 2
test/TensorFlowNET.Examples/ImageProcessing/YOLO/common.cs View File

@@ -65,11 +65,14 @@ namespace TensorFlowNET.Examples.ImageProcessing.YOLO
Tensor output = null;
if (method == "resize")
{

tf_with(tf.variable_scope(name), delegate
{
var input_shape = tf.shape(input_data);
});
}
else if(method == "deconv")
{
throw new NotImplementedException("upsample.deconv");
}

return output;


+ 3
- 2
test/TensorFlowNET.UnitTest/ImageTest.cs View File

@@ -14,10 +14,11 @@ namespace TensorFlowNET.UnitTest
[TestClass]
public class ImageTest
{
string imgPath = "../../../../../data/shasta-daisy.jpg";
string imgPath = "shasta-daisy.jpg";
Tensor contents;

public ImageTest()
[TestInitialize]
public void Initialize()
{
imgPath = Path.GetFullPath(imgPath);
contents = tf.read_file(imgPath);


Loading…
Cancel
Save