| @@ -19,7 +19,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TensorFlowHub", "src\Tensor | |||||
| EndProject | EndProject | ||||
| Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TensorFlowText", "src\TensorFlowText\TensorFlowText.csproj", "{B598E5D5-BD2D-4191-8532-F2FBAC31AB81}" | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TensorFlowText", "src\TensorFlowText\TensorFlowText.csproj", "{B598E5D5-BD2D-4191-8532-F2FBAC31AB81}" | ||||
| EndProject | EndProject | ||||
| Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NumSharp.Core", "..\NumSharp\src\NumSharp.Core\NumSharp.Core.csproj", "{F219B9B9-B873-4342-BF85-7E89E7F5D64F}" | |||||
| Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TensorFlowDatasets", "src\TensorFlowDatasets\TensorFlowDatasets.csproj", "{DF151A51-E9FD-41BD-B0F4-08A743755D44}" | |||||
| EndProject | |||||
| Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TensorFlowNET.Examples.GPU", "test\TensorFlowNET.Examples\TensorFlowNET.Examples.GPU.csproj", "{6F6B3382-8F87-4CD9-BF87-C81D5405685A}" | |||||
| EndProject | EndProject | ||||
| Global | Global | ||||
| GlobalSection(SolutionConfigurationPlatforms) = preSolution | GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||||
| @@ -59,10 +61,14 @@ Global | |||||
| {B598E5D5-BD2D-4191-8532-F2FBAC31AB81}.Debug|Any CPU.Build.0 = Debug|Any CPU | {B598E5D5-BD2D-4191-8532-F2FBAC31AB81}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||||
| {B598E5D5-BD2D-4191-8532-F2FBAC31AB81}.Release|Any CPU.ActiveCfg = Release|Any CPU | {B598E5D5-BD2D-4191-8532-F2FBAC31AB81}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||||
| {B598E5D5-BD2D-4191-8532-F2FBAC31AB81}.Release|Any CPU.Build.0 = Release|Any CPU | {B598E5D5-BD2D-4191-8532-F2FBAC31AB81}.Release|Any CPU.Build.0 = Release|Any CPU | ||||
| {F219B9B9-B873-4342-BF85-7E89E7F5D64F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||||
| {F219B9B9-B873-4342-BF85-7E89E7F5D64F}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||||
| {F219B9B9-B873-4342-BF85-7E89E7F5D64F}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||||
| {F219B9B9-B873-4342-BF85-7E89E7F5D64F}.Release|Any CPU.Build.0 = Release|Any CPU | |||||
| {DF151A51-E9FD-41BD-B0F4-08A743755D44}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||||
| {DF151A51-E9FD-41BD-B0F4-08A743755D44}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||||
| {DF151A51-E9FD-41BD-B0F4-08A743755D44}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||||
| {DF151A51-E9FD-41BD-B0F4-08A743755D44}.Release|Any CPU.Build.0 = Release|Any CPU | |||||
| {6F6B3382-8F87-4CD9-BF87-C81D5405685A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||||
| {6F6B3382-8F87-4CD9-BF87-C81D5405685A}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||||
| {6F6B3382-8F87-4CD9-BF87-C81D5405685A}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||||
| {6F6B3382-8F87-4CD9-BF87-C81D5405685A}.Release|Any CPU.Build.0 = Release|Any CPU | |||||
| EndGlobalSection | EndGlobalSection | ||||
| GlobalSection(SolutionProperties) = preSolution | GlobalSection(SolutionProperties) = preSolution | ||||
| HideSolutionNode = FALSE | HideSolutionNode = FALSE | ||||
| @@ -0,0 +1,24 @@ | |||||
| using System; | |||||
| namespace TensorFlowDatasets | |||||
| { | |||||
| /// <summary> | |||||
| /// Abstract base class for all datasets. | |||||
| /// </summary> | |||||
| public class DatasetBuilder | |||||
| { | |||||
| /// <summary> | |||||
| /// Downloads and prepares dataset for reading. | |||||
| /// </summary> | |||||
| /// <param name="download_dir"> | |||||
| /// directory where downloaded files are stored. | |||||
| /// </param> | |||||
| /// <param name="download_config"> | |||||
| /// further configuration for downloading and preparing dataset. | |||||
| /// </param> | |||||
| public void download_and_prepare(string download_dir = null, DownloadConfig download_config = null) | |||||
| { | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,10 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| namespace TensorFlowDatasets | |||||
| { | |||||
| public class DownloadConfig | |||||
| { | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,19 @@ | |||||
| <Project Sdk="Microsoft.NET.Sdk"> | |||||
| <PropertyGroup> | |||||
| <TargetFramework>netcoreapp2.2</TargetFramework> | |||||
| <PackageId>SciSharp.TensorFlowDatasets</PackageId> | |||||
| <Version>0.0.1</Version> | |||||
| <Authors>SciSharp Team</Authors> | |||||
| <Product>TensorFlow Datasets</Product> | |||||
| <GeneratePackageOnBuild>true</GeneratePackageOnBuild> | |||||
| <PackageIconUrl>https://avatars3.githubusercontent.com/u/44989469?s=200&v=4</PackageIconUrl> | |||||
| <PackageProjectUrl>http://scisharpstack.org</PackageProjectUrl> | |||||
| <Description>TensorFlow Datasets provides many public datasets as tf.data.Datasets.</Description> | |||||
| <RepositoryUrl>https://github.com/SciSharp/TensorFlow.NET</RepositoryUrl> | |||||
| <RepositoryType>git</RepositoryType> | |||||
| <PackageTags>SciSharp, Dataset, TensorFlow</PackageTags> | |||||
| <Copyright>Apache 2.0</Copyright> | |||||
| </PropertyGroup> | |||||
| </Project> | |||||
| @@ -486,7 +486,7 @@ namespace Tensorflow | |||||
| { | { | ||||
| if (tensorDType == TF_DataType.TF_STRING && nd.dtype.Name == "Byte") | if (tensorDType == TF_DataType.TF_STRING && nd.dtype.Name == "Byte") | ||||
| { | { | ||||
| var buffer = nd.ToArray<byte>(); | |||||
| var buffer = nd.Data<byte>(); | |||||
| var size = c_api.TF_StringEncodedSize((UIntPtr)buffer.Length); | var size = c_api.TF_StringEncodedSize((UIntPtr)buffer.Length); | ||||
| var handle = TF_AllocateTensor(TF_DataType.TF_STRING, IntPtr.Zero, 0, (UIntPtr)((ulong)size + 8)); | var handle = TF_AllocateTensor(TF_DataType.TF_STRING, IntPtr.Zero, 0, (UIntPtr)((ulong)size + 8)); | ||||
| @@ -524,30 +524,29 @@ namespace Tensorflow | |||||
| switch (nd.dtype.Name) | switch (nd.dtype.Name) | ||||
| { | { | ||||
| case "Boolean": | case "Boolean": | ||||
| var boolVals = Array.ConvertAll(nd1.ToArray<bool>(), x => Convert.ToByte(x)); | |||||
| var boolVals = Array.ConvertAll(nd1.Data<bool>(), x => Convert.ToByte(x)); | |||||
| Marshal.Copy(boolVals, 0, dotHandle, nd.size); | Marshal.Copy(boolVals, 0, dotHandle, nd.size); | ||||
| break; | break; | ||||
| case "Int16": | case "Int16": | ||||
| Marshal.Copy(nd1.ToArray<short>(), 0, dotHandle, nd.size); | |||||
| Marshal.Copy(nd1.Data<short>(), 0, dotHandle, nd.size); | |||||
| break; | break; | ||||
| case "Int32": | case "Int32": | ||||
| Marshal.Copy(nd1.ToArray<int>(), 0, dotHandle, nd.size); | |||||
| Marshal.Copy(nd1.Data<int>(), 0, dotHandle, nd.size); | |||||
| break; | break; | ||||
| case "Int64": | case "Int64": | ||||
| Marshal.Copy(nd1.ToArray<long>(), 0, dotHandle, nd.size); | |||||
| Marshal.Copy(nd1.Data<long>(), 0, dotHandle, nd.size); | |||||
| break; | break; | ||||
| case "Single": | case "Single": | ||||
| Marshal.Copy(nd1.ToArray<float>(), 0, dotHandle, nd.size); | |||||
| Marshal.Copy(nd1.Data<float>(), 0, dotHandle, nd.size); | |||||
| break; | break; | ||||
| case "Double": | case "Double": | ||||
| Marshal.Copy(nd1.ToArray<double>(), 0, dotHandle, nd.size); | |||||
| Marshal.Copy(nd1.Data<double>(), 0, dotHandle, nd.size); | |||||
| break; | break; | ||||
| case "Byte": | case "Byte": | ||||
| Marshal.Copy(nd1.ToArray<byte>(), 0, dotHandle, nd.size); | |||||
| Marshal.Copy(nd1.Data<byte>(), 0, dotHandle, nd.size); | |||||
| break; | break; | ||||
| case "String": | case "String": | ||||
| throw new NotImplementedException($"Marshal.Copy failed for {nd.dtype.Name}."); | |||||
| //return new Tensor(UTF8Encoding.UTF8.GetBytes(nd.Data<string>(0)), TF_DataType.TF_STRING); | |||||
| return new Tensor(UTF8Encoding.UTF8.GetBytes(nd.Data<string>(0)), TF_DataType.TF_STRING); | |||||
| default: | default: | ||||
| throw new NotImplementedException($"Marshal.Copy failed for {nd.dtype.Name}."); | throw new NotImplementedException($"Marshal.Copy failed for {nd.dtype.Name}."); | ||||
| } | } | ||||
| @@ -196,7 +196,7 @@ namespace Tensorflow | |||||
| // [offset1, offset2,...,offsetn, s1size, s1bytes, s2size, s2bytes,...,snsize,snbytes] | // [offset1, offset2,...,offsetn, s1size, s1bytes, s2size, s2bytes,...,snsize,snbytes] | ||||
| // | // | ||||
| long size = 1; | long size = 1; | ||||
| foreach (var s in TensorShape.dims) | |||||
| foreach (var s in TensorShape.Dimensions) | |||||
| size *= s; | size *= s; | ||||
| var buffer = new byte[size][]; | var buffer = new byte[size][]; | ||||
| @@ -0,0 +1,74 @@ | |||||
| /***************************************************************************** | |||||
| 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.Collections.Generic; | |||||
| using System.Text; | |||||
| using Tensorflow; | |||||
| using TensorFlowDatasets; | |||||
| using static Tensorflow.Python; | |||||
| namespace TensorFlowNET.Examples | |||||
| { | |||||
| /// <summary> | |||||
| /// https://www.tensorflow.org/tutorials/images/deep_cnn | |||||
| /// </summary> | |||||
| public class CIFAR10_CNN : IExample | |||||
| { | |||||
| public bool Enabled { get; set; } = true; | |||||
| public bool IsImportingGraph { get; set; } = false; | |||||
| public string Name => "CIFAR-10 CNN"; | |||||
| public bool Run() | |||||
| { | |||||
| PrepareData(); | |||||
| return true; | |||||
| } | |||||
| public Graph BuildGraph() | |||||
| { | |||||
| throw new NotImplementedException(); | |||||
| } | |||||
| public Graph ImportGraph() | |||||
| { | |||||
| throw new NotImplementedException(); | |||||
| } | |||||
| public void Predict(Session sess) | |||||
| { | |||||
| throw new NotImplementedException(); | |||||
| } | |||||
| public void PrepareData() | |||||
| { | |||||
| var tfds = new DatasetBuilder(); | |||||
| tfds.download_and_prepare(); | |||||
| } | |||||
| public void Test(Session sess) | |||||
| { | |||||
| throw new NotImplementedException(); | |||||
| } | |||||
| public void Train(Session sess) | |||||
| { | |||||
| throw new NotImplementedException(); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -21,7 +21,7 @@ using Tensorflow; | |||||
| using Tensorflow.Hub; | using Tensorflow.Hub; | ||||
| using static Tensorflow.Python; | using static Tensorflow.Python; | ||||
| namespace TensorFlowNET.Examples.ImageProcess | |||||
| namespace TensorFlowNET.Examples | |||||
| { | { | ||||
| /// <summary> | /// <summary> | ||||
| /// Convolutional Neural Network classifier for Hand Written Digits | /// Convolutional Neural Network classifier for Hand Written Digits | ||||
| @@ -20,7 +20,7 @@ using Tensorflow; | |||||
| using Tensorflow.Hub; | using Tensorflow.Hub; | ||||
| using static Tensorflow.Python; | using static Tensorflow.Python; | ||||
| namespace TensorFlowNET.Examples.ImageProcess | |||||
| namespace TensorFlowNET.Examples | |||||
| { | { | ||||
| /// <summary> | /// <summary> | ||||
| /// Neural Network classifier for Hand Written Digits | /// Neural Network classifier for Hand Written Digits | ||||
| @@ -127,7 +127,7 @@ namespace TensorFlowNET.Examples.ImageProcess | |||||
| public void Train(Session sess) | public void Train(Session sess) | ||||
| { | { | ||||
| // Number of training iterations in each epoch | // Number of training iterations in each epoch | ||||
| var num_tr_iter = mnist.Train.Labels.shape[0] / batch_size; | |||||
| var num_tr_iter = mnist.Train.Labels.len / batch_size; | |||||
| var init = tf.global_variables_initializer(); | var init = tf.global_variables_initializer(); | ||||
| sess.run(init); | sess.run(init); | ||||
| @@ -20,7 +20,7 @@ using Tensorflow; | |||||
| using Tensorflow.Hub; | using Tensorflow.Hub; | ||||
| using static Tensorflow.Python; | using static Tensorflow.Python; | ||||
| namespace TensorFlowNET.Examples.ImageProcess | |||||
| namespace TensorFlowNET.Examples | |||||
| { | { | ||||
| /// <summary> | /// <summary> | ||||
| /// Recurrent Neural Network for handwritten digits MNIST. | /// Recurrent Neural Network for handwritten digits MNIST. | ||||
| @@ -4,7 +4,7 @@ using Tensorflow; | |||||
| using TensorFlowNET.Examples.Utility; | using TensorFlowNET.Examples.Utility; | ||||
| using static Tensorflow.Python; | using static Tensorflow.Python; | ||||
| namespace TensorFlowNET.Examples.ImageProcess | |||||
| namespace TensorFlowNET.Examples | |||||
| { | { | ||||
| /// <summary> | /// <summary> | ||||
| /// This example removes the background from an input image. | /// This example removes the background from an input image. | ||||
| @@ -25,7 +25,7 @@ using Tensorflow; | |||||
| using TensorFlowNET.Examples.Utility; | using TensorFlowNET.Examples.Utility; | ||||
| using static Tensorflow.Python; | using static Tensorflow.Python; | ||||
| namespace TensorFlowNET.Examples.ImageProcess | |||||
| namespace TensorFlowNET.Examples | |||||
| { | { | ||||
| /// <summary> | /// <summary> | ||||
| /// In this tutorial, we will reuse the feature extraction capabilities from powerful image classifiers trained on ImageNet | /// In this tutorial, we will reuse the feature extraction capabilities from powerful image classifiers trained on ImageNet | ||||
| @@ -0,0 +1,24 @@ | |||||
| <Project Sdk="Microsoft.NET.Sdk"> | |||||
| <PropertyGroup> | |||||
| <OutputType>Exe</OutputType> | |||||
| <TargetFramework>netcoreapp2.2</TargetFramework> | |||||
| <GeneratePackageOnBuild>false</GeneratePackageOnBuild> | |||||
| </PropertyGroup> | |||||
| <ItemGroup> | |||||
| <PackageReference Include="Colorful.Console" Version="1.2.9" /> | |||||
| <PackageReference Include="Newtonsoft.Json" Version="12.0.2" /> | |||||
| <PackageReference Include="SciSharp.TensorFlow.Redist-Windows-GPU" Version="1.14.0" /> | |||||
| <PackageReference Include="SharpZipLib" Version="1.1.0" /> | |||||
| <PackageReference Include="System.Drawing.Common" Version="4.5.1" /> | |||||
| </ItemGroup> | |||||
| <ItemGroup> | |||||
| <ProjectReference Include="..\..\src\KerasNET.Core\Keras.Core.csproj" /> | |||||
| <ProjectReference Include="..\..\src\TensorFlowDatasets\TensorFlowDatasets.csproj" /> | |||||
| <ProjectReference Include="..\..\src\TensorFlowNET.Core\TensorFlowNET.Core.csproj" /> | |||||
| <ProjectReference Include="..\..\src\TensorFlowText\TensorFlowText.csproj" /> | |||||
| <ProjectReference Include="..\..\src\TensorFlowHub\TensorFlowHub.csproj" /> | |||||
| </ItemGroup> | |||||
| </Project> | |||||
| @@ -16,6 +16,7 @@ | |||||
| <ItemGroup> | <ItemGroup> | ||||
| <ProjectReference Include="..\..\src\KerasNET.Core\Keras.Core.csproj" /> | <ProjectReference Include="..\..\src\KerasNET.Core\Keras.Core.csproj" /> | ||||
| <ProjectReference Include="..\..\src\TensorFlowDatasets\TensorFlowDatasets.csproj" /> | |||||
| <ProjectReference Include="..\..\src\TensorFlowNET.Core\TensorFlowNET.Core.csproj" /> | <ProjectReference Include="..\..\src\TensorFlowNET.Core\TensorFlowNET.Core.csproj" /> | ||||
| <ProjectReference Include="..\..\src\TensorFlowText\TensorFlowText.csproj" /> | <ProjectReference Include="..\..\src\TensorFlowText\TensorFlowText.csproj" /> | ||||
| <ProjectReference Include="..\..\src\TensorFlowHub\TensorFlowHub.csproj" /> | <ProjectReference Include="..\..\src\TensorFlowHub\TensorFlowHub.csproj" /> | ||||