Browse Source

update tf.constant

tags/v0.1.0-Tensor
Oceania2018 6 years ago
parent
commit
518095db75
5 changed files with 30 additions and 6 deletions
  1. +4
    -3
      src/TensorFlowNET.Core/Graph.cs
  2. +4
    -0
      src/TensorFlowNET.Core/TensorFlowNET.Core.csproj
  3. +6
    -3
      src/TensorFlowNET.Core/Tensorflow.cs
  4. +15
    -0
      src/TensorFlowNET.Core/tensor_util.cs
  5. +1
    -0
      test/TensorFlowNET.Examples/HelloWorld.cs

+ 4
- 3
src/TensorFlowNET.Core/Graph.cs View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;

@@ -26,7 +27,7 @@ namespace TensorFlowNET.Core
_nodes_by_name = new Dictionary<string, Operation>();
}

public unsafe Operation create_op(object inputs, string op_type = "", string name = "")
public unsafe Operation create_op(string op_type, object inputs, TF_DataType[] dtypes, TF_DataType[] input_types = null, string name = "")
{
if (String.IsNullOrEmpty(name))
{
@@ -51,9 +52,9 @@ namespace TensorFlowNET.Core
return ++_next_id_counter;
}

public void get_operations()
public Operation[] get_operations()
{
return _nodes_by_name.Values.Select(x => x).ToArray();
}
}
}

+ 4
- 0
src/TensorFlowNET.Core/TensorFlowNET.Core.csproj View File

@@ -9,6 +9,10 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\NumSharp\src\NumSharp.Core\NumSharp.Core.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="libtensorflow.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>


+ 6
- 3
src/TensorFlowNET.Core/Tensorflow.cs View File

@@ -3,8 +3,6 @@ using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;



namespace TensorFlowNET.Core
{
public static class Tensorflow
@@ -14,7 +12,7 @@ namespace TensorFlowNET.Core
public static unsafe Tensor constant(object value)
{
var g = ops.get_default_graph();
g.create_op(value, "Const");
g.create_op("Const", value, new TF_DataType[] { TF_DataType.TF_DOUBLE });

return new Tensor();
}
@@ -29,6 +27,11 @@ namespace TensorFlowNET.Core

public static string VERSION => Marshal.PtrToStringAnsi(c_api.TF_Version());

public static Graph get_default_graph()
{
return ops.get_default_graph();
}

public static Graph Graph()
{
Graph g = new Graph(c_api.TF_NewGraph());


+ 15
- 0
src/TensorFlowNET.Core/tensor_util.cs View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;
using np = NumSharp.Core.NumPy;

namespace TensorFlowNET.Core
{
public static class tensor_util
{
public static void make_tensor_proto(object values, Type dtype = null)
{
var nparray = np.array(values as Array, dtype);
}
}
}

+ 1
- 0
test/TensorFlowNET.Examples/HelloWorld.cs View File

@@ -18,6 +18,7 @@ namespace TensorFlowNET.Examples
The value returned by the constructor represents the output
of the Constant op.*/
var graph = tf.get_default_graph();
var hello = tf.constant(4.0);
//var hello = tf.constant("Hello, TensorFlow!");



Loading…
Cancel
Save