Browse Source

move dataset to core.

tags/v0.20
Oceania2018 5 years ago
parent
commit
e61a9074db
18 changed files with 30 additions and 84 deletions
  1. +5
    -5
      README.md
  2. +1
    -1
      src/TensorFlowNET.Core/Data/DataSetBase.cs
  3. +0
    -6
      src/TensorFlowNET.Core/Data/DatasetV1.cs
  4. +0
    -9
      src/TensorFlowNET.Core/Data/DatasetV1Adapter.cs
  5. +0
    -21
      src/TensorFlowNET.Core/Data/DatasetV2.cs
  6. +1
    -1
      src/TensorFlowNET.Core/Data/Datasets.cs
  7. +1
    -1
      src/TensorFlowNET.Core/Data/IDataSet.cs
  8. +1
    -1
      src/TensorFlowNET.Core/Data/IModelLoader.cs
  9. +1
    -2
      src/TensorFlowNET.Core/Data/MnistDataSet.cs
  10. +1
    -1
      src/TensorFlowNET.Core/Data/MnistModelLoader.cs
  11. +1
    -1
      src/TensorFlowNET.Core/Data/ModelLoadSetting.cs
  12. +1
    -1
      src/TensorFlowNET.Core/Data/Utils.cs
  13. +4
    -4
      src/TensorFlowNET.Core/TensorFlow.Binding.csproj
  14. +0
    -11
      src/TensorFlowNET.Keras/Engine/BasePreprocessingLayer.cs
  15. +2
    -2
      src/TensorFlowNet.Benchmarks/Tensorflow.Benchmark.csproj
  16. +8
    -14
      tensorflowlib/README.md
  17. +1
    -1
      test/TensorFlowNET.UnitTest/Hub/MnistModelLoaderTest.cs
  18. +2
    -2
      test/TensorFlowNET.UnitTest/Tensorflow.UnitTest.csproj

+ 5
- 5
README.md View File

@@ -4,12 +4,13 @@


[![Join the chat at https://gitter.im/publiclab/publiclab](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/sci-sharp/community) [![Join the chat at https://gitter.im/publiclab/publiclab](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/sci-sharp/community)
[![Tensorflow.NET](https://ci.appveyor.com/api/projects/status/wx4td43v2d3f2xj6?svg=true)](https://ci.appveyor.com/project/Haiping-Chen/tensorflow-net) [![Tensorflow.NET](https://ci.appveyor.com/api/projects/status/wx4td43v2d3f2xj6?svg=true)](https://ci.appveyor.com/project/Haiping-Chen/tensorflow-net)
[![codecov](https://codecov.io/gh/SciSharp/NumSharp/branch/master/graph/badge.svg)](https://codecov.io/gh/SciSharp/NumSharp)
[![NuGet](https://img.shields.io/nuget/dt/TensorFlow.NET.svg)](https://www.nuget.org/packages/TensorFlow.NET) [![NuGet](https://img.shields.io/nuget/dt/TensorFlow.NET.svg)](https://www.nuget.org/packages/TensorFlow.NET)
[![Documentation Status](https://readthedocs.org/projects/tensorflownet/badge/?version=latest)](https://tensorflownet.readthedocs.io/en/latest/?badge=latest) [![Documentation Status](https://readthedocs.org/projects/tensorflownet/badge/?version=latest)](https://tensorflownet.readthedocs.io/en/latest/?badge=latest)
[![Badge](https://img.shields.io/badge/link-996.icu-red.svg)](https://996.icu/#/en_US) [![Badge](https://img.shields.io/badge/link-996.icu-red.svg)](https://996.icu/#/en_US)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/javiercp/BinderTF.NET/master?urlpath=lab) [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/javiercp/BinderTF.NET/master?urlpath=lab)


*master branch is based on tensorflow 2.1 now, v0.15-tensorflow1.15 is from tensorflow1.15.*

TF.NET is a member project of [SciSharp STACK](https://github.com/SciSharp). TF.NET is a member project of [SciSharp STACK](https://github.com/SciSharp).




@@ -29,10 +30,9 @@ In comparison to other projects, like for instance TensorFlowSharp which only pr


| TensorFlow | tf 1.13 | tf 1.14 | tf 1.15 | tf 2.0 | | TensorFlow | tf 1.13 | tf 1.14 | tf 1.15 | tf 2.0 |
| ----------- | ------- | ------- | ------- | ------ | | ----------- | ------- | ------- | ------- | ------ |
| tf.net 0.14 | | x | x | |
| tf.net 0.13 | | x | x | |
| tf.net 0.12 | x | x | | |
| tf.net 0.11 | x | x | | |
| tf.net 0.20 | | | x | x |
| tf.net 0.15 | | x | x | |
| tf.net 0.14 | x | x | | |


Install TF.NET and TensorFlow binary through NuGet. Install TF.NET and TensorFlow binary through NuGet.
```sh ```sh


src/TensorFlowNET.Hub/DataSetBase.cs → src/TensorFlowNET.Core/Data/DataSetBase.cs View File

@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Text; using System.Text;
using NumSharp; using NumSharp;


namespace Tensorflow.Hub
namespace Tensorflow
{ {
public abstract class DataSetBase : IDataSet public abstract class DataSetBase : IDataSet
{ {

+ 0
- 6
src/TensorFlowNET.Core/Data/DatasetV1.cs View File

@@ -1,6 +0,0 @@
namespace Tensorflow.Data
{
public class DatasetV1 : DatasetV2
{
}
}

+ 0
- 9
src/TensorFlowNET.Core/Data/DatasetV1Adapter.cs View File

@@ -1,9 +0,0 @@
namespace Tensorflow.Data
{
/// <summary>
/// Wraps a V2 `Dataset` object in the `tf.compat.v1.data.Dataset` API.
/// </summary>
public class DatasetV1Adapter : DatasetV1
{
}
}

+ 0
- 21
src/TensorFlowNET.Core/Data/DatasetV2.cs View File

@@ -1,21 +0,0 @@
using System;

namespace Tensorflow.Data
{
/// <summary>
/// Represents a potentially large set of elements.
///
/// A `Dataset` can be used to represent an input pipeline as a
/// collection of elements (nested structures of tensors) and a "logical
/// plan" of transformations that act on those elements.
///
/// tensorflow\python\data\ops\dataset_ops.py
/// </summary>
public class DatasetV2
{
public static DatasetV2 from_generator()
{
throw new NotImplementedException("");
}
}
}

src/TensorFlowNET.Hub/Datasets.cs → src/TensorFlowNET.Core/Data/Datasets.cs View File

@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Text; using System.Text;
using NumSharp; using NumSharp;


namespace Tensorflow.Hub
namespace Tensorflow
{ {
public class Datasets<TDataSet> where TDataSet : IDataSet public class Datasets<TDataSet> where TDataSet : IDataSet
{ {

src/TensorFlowNET.Hub/IDataSet.cs → src/TensorFlowNET.Core/Data/IDataSet.cs View File

@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Text; using System.Text;
using NumSharp; using NumSharp;


namespace Tensorflow.Hub
namespace Tensorflow
{ {
public interface IDataSet public interface IDataSet
{ {

src/TensorFlowNET.Hub/IModelLoader.cs → src/TensorFlowNET.Core/Data/IModelLoader.cs View File

@@ -4,7 +4,7 @@ using System.Collections.Generic;
using System.Text; using System.Text;
using NumSharp; using NumSharp;


namespace Tensorflow.Hub
namespace Tensorflow
{ {
public interface IModelLoader<TDataSet> public interface IModelLoader<TDataSet>
where TDataSet : IDataSet where TDataSet : IDataSet

src/TensorFlowNET.Hub/MnistDataSet.cs → src/TensorFlowNET.Core/Data/MnistDataSet.cs View File

@@ -3,9 +3,8 @@ using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Text; using System.Text;
using NumSharp; using NumSharp;
using Tensorflow;


namespace Tensorflow.Hub
namespace Tensorflow
{ {
public class MnistDataSet : DataSetBase public class MnistDataSet : DataSetBase
{ {

src/TensorFlowNET.Hub/MnistModelLoader.cs → src/TensorFlowNET.Core/Data/MnistModelLoader.cs View File

@@ -5,7 +5,7 @@ using System.Text;
using System.IO; using System.IO;
using NumSharp; using NumSharp;


namespace Tensorflow.Hub
namespace Tensorflow
{ {
public class MnistModelLoader : IModelLoader<MnistDataSet> public class MnistModelLoader : IModelLoader<MnistDataSet>
{ {

src/TensorFlowNET.Hub/ModelLoadSetting.cs → src/TensorFlowNET.Core/Data/ModelLoadSetting.cs View File

@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Text; using System.Text;
using NumSharp; using NumSharp;


namespace Tensorflow.Hub
namespace Tensorflow
{ {
public class ModelLoadSetting public class ModelLoadSetting
{ {

src/TensorFlowNET.Hub/Utils.cs → src/TensorFlowNET.Core/Data/Utils.cs View File

@@ -7,7 +7,7 @@ using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;


namespace Tensorflow.Hub
namespace Tensorflow
{ {
public static class Utils public static class Utils
{ {

+ 4
- 4
src/TensorFlowNET.Core/TensorFlow.Binding.csproj View File

@@ -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.15.0</Version>
<Version>0.20.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,15 @@
<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.15.0.0</AssemblyVersion>
<PackageReleaseNotes>Changes since v0.14.0:
<AssemblyVersion>0.20.0.0</AssemblyVersion>
<PackageReleaseNotes>Changes since v0.15.0:
1: Add TransformGraphWithStringInputs. 1: Add TransformGraphWithStringInputs.
2: tf.trainer.load_graph, tf.trainer.freeze_graph 2: tf.trainer.load_graph, tf.trainer.freeze_graph
3: Import Protobuf.Text 3: Import Protobuf.Text
4: Support YOLOv3 object detection 4: Support YOLOv3 object detection
5: Add implicitation for Operation to RefVariable</PackageReleaseNotes> 5: Add implicitation for Operation to RefVariable</PackageReleaseNotes>
<LangVersion>7.3</LangVersion> <LangVersion>7.3</LangVersion>
<FileVersion>0.15.0.0</FileVersion>
<FileVersion>0.20.0.0</FileVersion>
<PackageLicenseFile>LICENSE</PackageLicenseFile> <PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance> <PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<SignAssembly>true</SignAssembly> <SignAssembly>true</SignAssembly>


+ 0
- 11
src/TensorFlowNET.Keras/Engine/BasePreprocessingLayer.cs View File

@@ -3,14 +3,12 @@ using NumSharp;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using Tensorflow.Data;
using Tensorflow.Keras.Initializers; using Tensorflow.Keras.Initializers;


namespace Tensorflow.Keras.Engine namespace Tensorflow.Keras.Engine
{ {
public abstract class PreprocessingLayer : Layer public abstract class PreprocessingLayer : Layer
{ {
public abstract void adapt(Data.DatasetV1 data, bool reset_state = true);
} }


public abstract class Combiner public abstract class Combiner
@@ -44,15 +42,6 @@ namespace Tensorflow.Keras.Engine


private Dictionary<string, NDArray> _restore_updates() => throw new NotImplementedException(); private Dictionary<string, NDArray> _restore_updates() => throw new NotImplementedException();


private bool _dataset_is_infinite(DatasetV1 dataset) => throw new NotImplementedException();

private dynamic _get_dataset_iterator(DatasetV1 dataset) => throw new NotImplementedException();

private void _set_state_variables(Dictionary<string, Tensor> updates) => throw new NotImplementedException(); private void _set_state_variables(Dictionary<string, Tensor> updates) => throw new NotImplementedException();

public override void adapt(DatasetV1 data, bool reset_state = true)
{
throw new NotImplementedException();
}
} }
} }

+ 2
- 2
src/TensorFlowNet.Benchmarks/Tensorflow.Benchmark.csproj View File

@@ -2,7 +2,7 @@


<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup> </PropertyGroup>


<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
@@ -20,7 +20,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.12.0" /> <PackageReference Include="BenchmarkDotNet" Version="0.12.0" />
<PackageReference Include="SciSharp.TensorFlow.Redist" Version="1.15.1" /> <PackageReference Include="SciSharp.TensorFlow.Redist" Version="1.15.1" />
<PackageReference Include="TensorFlow.NET" Version="0.14.2" />
<PackageReference Include="TensorFlow.NET" Version="0.15.0" />
</ItemGroup> </ItemGroup>


</Project> </Project>

+ 8
- 14
tensorflowlib/README.md View File

@@ -18,40 +18,34 @@ sudo apt install libgdiplus


More information about [System.Drawing on Linux](<https://www.hanselman.com/blog/HowDoYouUseSystemDrawingInNETCore.aspx>). More information about [System.Drawing on Linux](<https://www.hanselman.com/blog/HowDoYouUseSystemDrawingInNETCore.aspx>).


### Run TensorFlow in GPU
### Run TensorFlow with GPU
Before running verify you installed CUDA and cuDNN (TensorFlow v1.15 is compatible with CUDA v10.0 and cuDNN v7.4 , TensorFlow v2.x is compatible with CUDA v10.2 and cuDNN v7.65), and make sure the corresponding cuda version is compatible. Before running verify you installed CUDA and cuDNN (TensorFlow v1.15 is compatible with CUDA v10.0 and cuDNN v7.4 , TensorFlow v2.x is compatible with CUDA v10.2 and cuDNN v7.65), and make sure the corresponding cuda version is compatible.


#### Run in Mac OS
#### Mac OS
There is no GPU support for macOS. There is no GPU support for macOS.


#### Tensorflow GPU for Windows
#### GPU for Windows


```powershell ```powershell
PM> Install-Package SciSharp.TensorFlow.Redist-Windows-GPU PM> Install-Package SciSharp.TensorFlow.Redist-Windows-GPU
``` ```


#### Tensorflow GPU for Linux
#### GPU for Linux
```powershell ```powershell
PM> Install-Package SciSharp.TensorFlow.Redist-Linux-GPU PM> Install-Package SciSharp.TensorFlow.Redist-Linux-GPU
``` ```


### Download prebuild binary manually ### Download prebuild binary manually


Here are some pre-built TensorFlow binaries you can use for each platform:

- Linux
- CPU-only: https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-linux-x86_64-1.15.0.tar.gz
- GPU-enabled: https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-gpu-linux-x86_64-1.15.0.tar.gz
- Mac: https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-darwin-x86_64-1.15.0.tar.gz
- Windows
- CPU-only: https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-windows-x86_64-1.15.0.zip
- GPU-enabled: https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-gpu-windows-x86_64-1.15.0.zip
We can't found official prebuild binaries for each platform since tensorflow 2.0. If you know where we can download, please PR here.




### Build from source for Windows ### Build from source for Windows


https://www.tensorflow.org/install/source_windows https://www.tensorflow.org/install/source_windows


Download [Bazel 0.29.1](https://github.com/bazelbuild/bazel/releases/tag/0.29.1) to build tensorflow2.x. We build customized binary to export c_api from this [fork](https://github.com/SciSharp/tensorflow).

`pacman -S git patch unzip` `pacman -S git patch unzip`


1. Build static library 1. Build static library
@@ -81,4 +75,4 @@ TF_CAPI_EXPORT extern void RemoveAllControlInputs(TF_Graph* graph, TF_Operation*
``` ```


For Linux version, these APIs symbols should also be put into `tensorflow/c/version_script.lds` to be exported. For Linux version, these APIs symbols should also be put into `tensorflow/c/version_script.lds` to be exported.
Please refer to commit `https://github.com/SciSharp/tensorflow/commit/58122da06be3e7707500ad889dfd5c760a3e0424`
Please refer to commit `https://github.com/SciSharp/tensorflow/commit/58122da06be3e7707500ad889dfd5c760a3e0424`

+ 1
- 1
test/TensorFlowNET.UnitTest/Hub/MnistModelLoaderTest.cs View File

@@ -1,6 +1,6 @@
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Threading.Tasks; using System.Threading.Tasks;
using Tensorflow.Hub;
using Tensorflow;


namespace TensorFlowNET.UnitTest namespace TensorFlowNET.UnitTest
{ {


+ 2
- 2
test/TensorFlowNET.UnitTest/Tensorflow.UnitTest.csproj View File

@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">


<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>


<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>


<SignAssembly>true</SignAssembly>
<SignAssembly>false</SignAssembly>


<DelaySign>false</DelaySign> <DelaySign>false</DelaySign>




Loading…
Cancel
Save