diff --git a/TensorFlow.NET.sln b/TensorFlow.NET.sln
index b8e7f043..689965c4 100644
--- a/TensorFlow.NET.sln
+++ b/TensorFlow.NET.sln
@@ -19,7 +19,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TensorFlowHub", "src\Tensor
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TensorFlowText", "src\TensorFlowText\TensorFlowText.csproj", "{B598E5D5-BD2D-4191-8532-F2FBAC31AB81}"
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
Global
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}.Release|Any CPU.ActiveCfg = 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
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/src/TensorFlowDatasets/DatasetBuilder.cs b/src/TensorFlowDatasets/DatasetBuilder.cs
new file mode 100644
index 00000000..bfb78d6e
--- /dev/null
+++ b/src/TensorFlowDatasets/DatasetBuilder.cs
@@ -0,0 +1,24 @@
+using System;
+
+namespace TensorFlowDatasets
+{
+ ///
+ /// Abstract base class for all datasets.
+ ///
+ public class DatasetBuilder
+ {
+ ///
+ /// Downloads and prepares dataset for reading.
+ ///
+ ///
+ /// directory where downloaded files are stored.
+ ///
+ ///
+ /// further configuration for downloading and preparing dataset.
+ ///
+ public void download_and_prepare(string download_dir = null, DownloadConfig download_config = null)
+ {
+
+ }
+ }
+}
diff --git a/src/TensorFlowDatasets/DownloadConfig.cs b/src/TensorFlowDatasets/DownloadConfig.cs
new file mode 100644
index 00000000..0488e273
--- /dev/null
+++ b/src/TensorFlowDatasets/DownloadConfig.cs
@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TensorFlowDatasets
+{
+ public class DownloadConfig
+ {
+ }
+}
diff --git a/src/TensorFlowDatasets/TensorFlowDatasets.csproj b/src/TensorFlowDatasets/TensorFlowDatasets.csproj
new file mode 100644
index 00000000..1b839c1f
--- /dev/null
+++ b/src/TensorFlowDatasets/TensorFlowDatasets.csproj
@@ -0,0 +1,19 @@
+
+
+
+ netcoreapp2.2
+ SciSharp.TensorFlowDatasets
+ 0.0.1
+ SciSharp Team
+ TensorFlow Datasets
+ true
+ https://avatars3.githubusercontent.com/u/44989469?s=200&v=4
+ http://scisharpstack.org
+ TensorFlow Datasets provides many public datasets as tf.data.Datasets.
+ https://github.com/SciSharp/TensorFlow.NET
+ git
+ SciSharp, Dataset, TensorFlow
+ Apache 2.0
+
+
+
diff --git a/src/TensorFlowNET.Core/Tensors/Tensor.Creation.cs b/src/TensorFlowNET.Core/Tensors/Tensor.Creation.cs
index aaff64d2..a104f066 100644
--- a/src/TensorFlowNET.Core/Tensors/Tensor.Creation.cs
+++ b/src/TensorFlowNET.Core/Tensors/Tensor.Creation.cs
@@ -486,7 +486,7 @@ namespace Tensorflow
{
if (tensorDType == TF_DataType.TF_STRING && nd.dtype.Name == "Byte")
{
- var buffer = nd.ToArray();
+ var buffer = nd.Data();
var size = c_api.TF_StringEncodedSize((UIntPtr)buffer.Length);
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)
{
case "Boolean":
- var boolVals = Array.ConvertAll(nd1.ToArray(), x => Convert.ToByte(x));
+ var boolVals = Array.ConvertAll(nd1.Data(), x => Convert.ToByte(x));
Marshal.Copy(boolVals, 0, dotHandle, nd.size);
break;
case "Int16":
- Marshal.Copy(nd1.ToArray(), 0, dotHandle, nd.size);
+ Marshal.Copy(nd1.Data(), 0, dotHandle, nd.size);
break;
case "Int32":
- Marshal.Copy(nd1.ToArray(), 0, dotHandle, nd.size);
+ Marshal.Copy(nd1.Data(), 0, dotHandle, nd.size);
break;
case "Int64":
- Marshal.Copy(nd1.ToArray(), 0, dotHandle, nd.size);
+ Marshal.Copy(nd1.Data(), 0, dotHandle, nd.size);
break;
case "Single":
- Marshal.Copy(nd1.ToArray(), 0, dotHandle, nd.size);
+ Marshal.Copy(nd1.Data(), 0, dotHandle, nd.size);
break;
case "Double":
- Marshal.Copy(nd1.ToArray(), 0, dotHandle, nd.size);
+ Marshal.Copy(nd1.Data(), 0, dotHandle, nd.size);
break;
case "Byte":
- Marshal.Copy(nd1.ToArray(), 0, dotHandle, nd.size);
+ Marshal.Copy(nd1.Data(), 0, dotHandle, nd.size);
break;
case "String":
- throw new NotImplementedException($"Marshal.Copy failed for {nd.dtype.Name}.");
- //return new Tensor(UTF8Encoding.UTF8.GetBytes(nd.Data(0)), TF_DataType.TF_STRING);
+ return new Tensor(UTF8Encoding.UTF8.GetBytes(nd.Data(0)), TF_DataType.TF_STRING);
default:
throw new NotImplementedException($"Marshal.Copy failed for {nd.dtype.Name}.");
}
diff --git a/src/TensorFlowNET.Core/Tensors/Tensor.cs b/src/TensorFlowNET.Core/Tensors/Tensor.cs
index 4e4157ab..606b8999 100644
--- a/src/TensorFlowNET.Core/Tensors/Tensor.cs
+++ b/src/TensorFlowNET.Core/Tensors/Tensor.cs
@@ -196,7 +196,7 @@ namespace Tensorflow
// [offset1, offset2,...,offsetn, s1size, s1bytes, s2size, s2bytes,...,snsize,snbytes]
//
long size = 1;
- foreach (var s in TensorShape.dims)
+ foreach (var s in TensorShape.Dimensions)
size *= s;
var buffer = new byte[size][];
diff --git a/test/TensorFlowNET.Examples/ImageProcessing/CIFAR10-CNN.cs b/test/TensorFlowNET.Examples/ImageProcessing/CIFAR10-CNN.cs
new file mode 100644
index 00000000..a77a5b00
--- /dev/null
+++ b/test/TensorFlowNET.Examples/ImageProcessing/CIFAR10-CNN.cs
@@ -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
+{
+ ///
+ /// https://www.tensorflow.org/tutorials/images/deep_cnn
+ ///
+ 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();
+ }
+ }
+}
diff --git a/test/TensorFlowNET.Examples/ImageProcessing/DigitRecognitionCNN.cs b/test/TensorFlowNET.Examples/ImageProcessing/DigitRecognitionCNN.cs
index 26dc9948..21239020 100644
--- a/test/TensorFlowNET.Examples/ImageProcessing/DigitRecognitionCNN.cs
+++ b/test/TensorFlowNET.Examples/ImageProcessing/DigitRecognitionCNN.cs
@@ -21,7 +21,7 @@ using Tensorflow;
using Tensorflow.Hub;
using static Tensorflow.Python;
-namespace TensorFlowNET.Examples.ImageProcess
+namespace TensorFlowNET.Examples
{
///
/// Convolutional Neural Network classifier for Hand Written Digits
diff --git a/test/TensorFlowNET.Examples/ImageProcessing/DigitRecognitionNN.cs b/test/TensorFlowNET.Examples/ImageProcessing/DigitRecognitionNN.cs
index 43c953bd..e604afff 100644
--- a/test/TensorFlowNET.Examples/ImageProcessing/DigitRecognitionNN.cs
+++ b/test/TensorFlowNET.Examples/ImageProcessing/DigitRecognitionNN.cs
@@ -20,7 +20,7 @@ using Tensorflow;
using Tensorflow.Hub;
using static Tensorflow.Python;
-namespace TensorFlowNET.Examples.ImageProcess
+namespace TensorFlowNET.Examples
{
///
/// Neural Network classifier for Hand Written Digits
@@ -127,7 +127,7 @@ namespace TensorFlowNET.Examples.ImageProcess
public void Train(Session sess)
{
// 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();
sess.run(init);
diff --git a/test/TensorFlowNET.Examples/ImageProcessing/DigitRecognitionRNN.cs b/test/TensorFlowNET.Examples/ImageProcessing/DigitRecognitionRNN.cs
index 1ee7d228..ca6d4332 100644
--- a/test/TensorFlowNET.Examples/ImageProcessing/DigitRecognitionRNN.cs
+++ b/test/TensorFlowNET.Examples/ImageProcessing/DigitRecognitionRNN.cs
@@ -20,7 +20,7 @@ using Tensorflow;
using Tensorflow.Hub;
using static Tensorflow.Python;
-namespace TensorFlowNET.Examples.ImageProcess
+namespace TensorFlowNET.Examples
{
///
/// Recurrent Neural Network for handwritten digits MNIST.
diff --git a/test/TensorFlowNET.Examples/ImageProcessing/ImageBackgroundRemoval.cs b/test/TensorFlowNET.Examples/ImageProcessing/ImageBackgroundRemoval.cs
index c43c853a..db148f14 100644
--- a/test/TensorFlowNET.Examples/ImageProcessing/ImageBackgroundRemoval.cs
+++ b/test/TensorFlowNET.Examples/ImageProcessing/ImageBackgroundRemoval.cs
@@ -4,7 +4,7 @@ using Tensorflow;
using TensorFlowNET.Examples.Utility;
using static Tensorflow.Python;
-namespace TensorFlowNET.Examples.ImageProcess
+namespace TensorFlowNET.Examples
{
///
/// This example removes the background from an input image.
diff --git a/test/TensorFlowNET.Examples/ImageProcessing/RetrainImageClassifier.cs b/test/TensorFlowNET.Examples/ImageProcessing/RetrainImageClassifier.cs
index 187c4cc5..8ea6e1d2 100644
--- a/test/TensorFlowNET.Examples/ImageProcessing/RetrainImageClassifier.cs
+++ b/test/TensorFlowNET.Examples/ImageProcessing/RetrainImageClassifier.cs
@@ -25,7 +25,7 @@ using Tensorflow;
using TensorFlowNET.Examples.Utility;
using static Tensorflow.Python;
-namespace TensorFlowNET.Examples.ImageProcess
+namespace TensorFlowNET.Examples
{
///
/// In this tutorial, we will reuse the feature extraction capabilities from powerful image classifiers trained on ImageNet
diff --git a/test/TensorFlowNET.Examples/TensorFlowNET.Examples.GPU.csproj b/test/TensorFlowNET.Examples/TensorFlowNET.Examples.GPU.csproj
new file mode 100644
index 00000000..1bd3d530
--- /dev/null
+++ b/test/TensorFlowNET.Examples/TensorFlowNET.Examples.GPU.csproj
@@ -0,0 +1,24 @@
+
+
+
+ Exe
+ netcoreapp2.2
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/TensorFlowNET.Examples/TensorFlowNET.Examples.csproj b/test/TensorFlowNET.Examples/TensorFlowNET.Examples.csproj
index 6184d4ad..f4e2340a 100644
--- a/test/TensorFlowNET.Examples/TensorFlowNET.Examples.csproj
+++ b/test/TensorFlowNET.Examples/TensorFlowNET.Examples.csproj
@@ -16,6 +16,7 @@
+