| @@ -23,6 +23,7 @@ namespace Tensorflow | |||||
| { | { | ||||
| public GFile gfile = new GFile(); | public GFile gfile = new GFile(); | ||||
| public Tensor read_file(string filename, string name = null) => gen_io_ops.read_file(filename, name); | public Tensor read_file(string filename, string name = null) => gen_io_ops.read_file(filename, name); | ||||
| public Tensor read_file(Tensor filename, string name = null) => gen_io_ops.read_file(filename, name); | |||||
| public ITensorOrOperation[] import_graph_def(GraphDef graph_def, | public ITensorOrOperation[] import_graph_def(GraphDef graph_def, | ||||
| Dictionary<string, Tensor> input_map = null, | Dictionary<string, Tensor> input_map = null, | ||||
| @@ -1,6 +1,8 @@ | |||||
| using System; | using System; | ||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||
| using System.IO; | |||||
| using System.Text; | using System.Text; | ||||
| using Google.Protobuf; | |||||
| namespace Tensorflow | namespace Tensorflow | ||||
| { | { | ||||
| @@ -15,17 +17,30 @@ namespace Tensorflow | |||||
| /// <param name="outputs">the model outputs</param> | /// <param name="outputs">the model outputs</param> | ||||
| /// <param name="transforms">transform names and parameters</param> | /// <param name="transforms">transform names and parameters</param> | ||||
| /// <returns></returns> | /// <returns></returns> | ||||
| public GraphDef TransformGraph(GraphDef input_graph_def, | |||||
| string[] inputs, | |||||
| string[] outputs, | |||||
| public GraphDef TransformGraph(GraphDef input_graph_def, | |||||
| string[] inputs, | |||||
| string[] outputs, | |||||
| string[] transforms) | string[] transforms) | ||||
| { | { | ||||
| var input_graph_def_string = input_graph_def.ToString(); | |||||
| var input_graph_def_string = input_graph_def.ToByteArray(); | |||||
| var inputs_string = string.Join(",", inputs); | var inputs_string = string.Join(",", inputs); | ||||
| var outputs_string = string.Join(",", outputs); | var outputs_string = string.Join(",", outputs); | ||||
| var transforms_string = string.Join(",", transforms); | |||||
| var transforms_string = string.Join(" ", transforms); | |||||
| using (var status = new Status()) | |||||
| { | |||||
| var buffer = new Buffer(); | |||||
| var len = c_api.TransformGraphWithStringInputs(input_graph_def_string, | |||||
| input_graph_def_string.Length, | |||||
| inputs_string, | |||||
| outputs_string, | |||||
| transforms_string, | |||||
| buffer, | |||||
| status); | |||||
| throw new NotImplementedException(""); | |||||
| status.Check(false); | |||||
| var bytes = buffer.ToArray(); | |||||
| return GraphDef.Parser.ParseFrom(bytes); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -0,0 +1,33 @@ | |||||
| /***************************************************************************** | |||||
| Copyright 2018 The TensorFlow.NET Authors. All Rights Reserved. | |||||
| Licensed under the Apache License, Version 2.0 (the "License"); | |||||
| you may not use this file except in compliance with the License. | |||||
| You may obtain a copy of the License at | |||||
| http://www.apache.org/licenses/LICENSE-2.0 | |||||
| Unless required by applicable law or agreed to in writing, software | |||||
| distributed under the License is distributed on an "AS IS" BASIS, | |||||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
| See the License for the specific language governing permissions and | |||||
| limitations under the License. | |||||
| ******************************************************************************/ | |||||
| using System; | |||||
| using System.Runtime.InteropServices; | |||||
| namespace Tensorflow | |||||
| { | |||||
| public partial class c_api | |||||
| { | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static extern int TransformGraphWithStringInputs(byte[] graph_def_string, | |||||
| int graph_def_string_len, | |||||
| string inputs_string, | |||||
| string outputs_string, | |||||
| string transforms_string, | |||||
| IntPtr output_buffer, | |||||
| IntPtr status); | |||||
| } | |||||
| } | |||||
| @@ -34,7 +34,7 @@ namespace Tensorflow | |||||
| return _op.outputs; | return _op.outputs; | ||||
| } | } | ||||
| public static Tensor read_file(string filename, string name = null) | |||||
| public static Tensor read_file<T>(T filename, string name = null) | |||||
| { | { | ||||
| var _op = _op_def_lib._apply_op_helper("ReadFile", name: name, args: new { filename }); | var _op = _op_def_lib._apply_op_helper("ReadFile", name: name, args: new { filename }); | ||||
| @@ -5,7 +5,7 @@ | |||||
| <AssemblyName>TensorFlow.NET</AssemblyName> | <AssemblyName>TensorFlow.NET</AssemblyName> | ||||
| <RootNamespace>Tensorflow</RootNamespace> | <RootNamespace>Tensorflow</RootNamespace> | ||||
| <TargetTensorFlow>1.14.1</TargetTensorFlow> | <TargetTensorFlow>1.14.1</TargetTensorFlow> | ||||
| <Version>0.14.0</Version> | |||||
| <Version>0.15.0</Version> | |||||
| <Authors>Haiping Chen, Meinrad Recheis, Eli Belash</Authors> | <Authors>Haiping Chen, Meinrad Recheis, Eli Belash</Authors> | ||||
| <Company>SciSharp STACK</Company> | <Company>SciSharp STACK</Company> | ||||
| <GeneratePackageOnBuild>true</GeneratePackageOnBuild> | <GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||||
| @@ -18,15 +18,11 @@ | |||||
| <Description>Google's TensorFlow full binding in .NET Standard. | <Description>Google's TensorFlow full binding in .NET Standard. | ||||
| Building, training and infering deep learning models. | Building, training and infering deep learning models. | ||||
| https://tensorflownet.readthedocs.io</Description> | https://tensorflownet.readthedocs.io</Description> | ||||
| <AssemblyVersion>0.14.0.0</AssemblyVersion> | |||||
| <PackageReleaseNotes>Changes since v0.13.0: | |||||
| 1: Upgrade NumSharp to v0.20.5 | |||||
| 2: Return byte[] for TF_String | |||||
| 3: Fix return_tensors for import_graph_def | |||||
| 4: Add tf.nn.ctc_greedy_decoder | |||||
| 5: Fix calling RegisterGradientFunction too early</PackageReleaseNotes> | |||||
| <AssemblyVersion>0.15.0.0</AssemblyVersion> | |||||
| <PackageReleaseNotes>Changes since v0.14.0: | |||||
| 1: Add TransformGraphWithStringInputs.</PackageReleaseNotes> | |||||
| <LangVersion>7.3</LangVersion> | <LangVersion>7.3</LangVersion> | ||||
| <FileVersion>0.14.0.0</FileVersion> | |||||
| <FileVersion>0.15.0.0</FileVersion> | |||||
| <PackageLicenseFile>LICENSE</PackageLicenseFile> | <PackageLicenseFile>LICENSE</PackageLicenseFile> | ||||
| <PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance> | <PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance> | ||||
| <SignAssembly>true</SignAssembly> | <SignAssembly>true</SignAssembly> | ||||