| @@ -8,7 +8,7 @@ | |||||
| </PropertyGroup> | </PropertyGroup> | ||||
| <ItemGroup> | <ItemGroup> | ||||
| <PackageReference Include="SciSharp.TensorFlow.Redist" Version="2.2.0.1" /> | |||||
| <PackageReference Include="SciSharp.TensorFlow.Redist" Version="2.2.0.2" /> | |||||
| </ItemGroup> | </ItemGroup> | ||||
| <ItemGroup> | <ItemGroup> | ||||
| @@ -43,7 +43,7 @@ namespace Tensorflow | |||||
| /// </summary> | /// </summary> | ||||
| public partial class c_api | public partial class c_api | ||||
| { | { | ||||
| public const string TensorFlowLibName = @"D:\SciSharp\tensorflow-google\bazel-bin\tensorflow\tensorflow.dll"; | |||||
| public const string TensorFlowLibName = "tensorflow"; | |||||
| public static string StringPiece(IntPtr handle) | public static string StringPiece(IntPtr handle) | ||||
| { | { | ||||
| @@ -0,0 +1,30 @@ | |||||
| /***************************************************************************** | |||||
| Copyright 2020 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 NumSharp; | |||||
| namespace Tensorflow | |||||
| { | |||||
| public partial class tensorflow | |||||
| { | |||||
| public DataOps data { get; } = new DataOps(); | |||||
| public class DataOps | |||||
| { | |||||
| public TensorSliceDataset Dataset { get; } = new TensorSliceDataset(); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,25 @@ | |||||
| /***************************************************************************** | |||||
| Copyright 2020 Haiping Chen. 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 NumSharp; | |||||
| namespace Tensorflow | |||||
| { | |||||
| public partial class tensorflow | |||||
| { | |||||
| public KerasApi keras { get; } = new KerasApi(); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,10 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| namespace Tensorflow | |||||
| { | |||||
| public class DatasetOps | |||||
| { | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,20 @@ | |||||
| using NumSharp; | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| namespace Tensorflow | |||||
| { | |||||
| public class TensorSliceDataset | |||||
| { | |||||
| public TensorSliceDataset(params NDArray[] elements) | |||||
| { | |||||
| } | |||||
| public TensorSliceDataset from_tensor_slices(params NDArray[] elements) | |||||
| { | |||||
| throw new NotImplementedException(""); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,27 @@ | |||||
| using NumSharp; | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| namespace Tensorflow.Keras.Datasets | |||||
| { | |||||
| public class DatasetPass | |||||
| { | |||||
| public (NDArray, NDArray) Train { get; set; } | |||||
| public (NDArray, NDArray) Test { get; set; } | |||||
| public void Deconstruct(out NDArray x_train, out NDArray y_train, out NDArray x_test, out NDArray y_test) | |||||
| { | |||||
| x_train = Train.Item1; | |||||
| y_train = Train.Item2; | |||||
| x_test = Test.Item1; | |||||
| y_test = Test.Item2; | |||||
| } | |||||
| public void Deconstruct(out (NDArray, NDArray) train, out (NDArray, NDArray) test) | |||||
| { | |||||
| train = Train; | |||||
| test = Test; | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,27 @@ | |||||
| /***************************************************************************** | |||||
| Copyright 2020 Haiping Chen. 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; | |||||
| namespace Tensorflow.Keras.Datasets | |||||
| { | |||||
| public class KerasDataset | |||||
| { | |||||
| public Mnist mnist { get; } = new Mnist(); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,76 @@ | |||||
| /***************************************************************************** | |||||
| Copyright 2020 Haiping Chen. 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 NumSharp; | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.IO; | |||||
| using System.Net; | |||||
| using System.Text; | |||||
| namespace Tensorflow.Keras.Datasets | |||||
| { | |||||
| public class Mnist | |||||
| { | |||||
| string origin_folder = "https://storage.googleapis.com/tensorflow/tf-keras-datasets/"; | |||||
| string file_name = "mnist.npz"; | |||||
| /// <summary> | |||||
| /// Loads the [MNIST dataset](http://yann.lecun.com/exdb/mnist/). | |||||
| /// </summary> | |||||
| /// <returns></returns> | |||||
| public DatasetPass load_data() | |||||
| { | |||||
| var file = Download(); | |||||
| var bytes = File.ReadAllBytes(file); | |||||
| var datax = LoadX(bytes); | |||||
| var datay = LoadY(bytes); | |||||
| return new DatasetPass | |||||
| { | |||||
| Train = (datax.Item1, datay.Item1), | |||||
| Test = (datax.Item2, datay.Item2) | |||||
| }; | |||||
| } | |||||
| (NDArray, NDArray) LoadX(byte[] bytes) | |||||
| { | |||||
| var y = np.Load_Npz<byte[,,]>(bytes); | |||||
| return (y["x_train.npy"], y["x_test.npy"]); | |||||
| } | |||||
| (NDArray, NDArray) LoadY(byte[] bytes) | |||||
| { | |||||
| var y = np.Load_Npz<byte[]>(bytes); | |||||
| return (y["y_train.npy"], y["y_test.npy"]); | |||||
| } | |||||
| string Download() | |||||
| { | |||||
| var fileSaveTo = Path.Combine(Path.GetTempPath(), file_name); | |||||
| if (File.Exists(fileSaveTo)) | |||||
| { | |||||
| Console.WriteLine($"The file {fileSaveTo} already exists"); | |||||
| return fileSaveTo; | |||||
| } | |||||
| using var wc = new WebClient(); | |||||
| wc.DownloadFileTaskAsync(origin_folder + file_name, fileSaveTo).Wait(); | |||||
| return fileSaveTo; | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,12 @@ | |||||
| using System.Data; | |||||
| using Tensorflow.Keras; | |||||
| using Tensorflow.Keras.Datasets; | |||||
| namespace Tensorflow | |||||
| { | |||||
| public class KerasApi | |||||
| { | |||||
| public KerasDataset datasets { get; } = new KerasDataset(); | |||||
| public Initializers initializers { get; } = new Initializers(); | |||||
| } | |||||
| } | |||||
| @@ -1,12 +0,0 @@ | |||||
| using Tensorflow.Keras; | |||||
| namespace Tensorflow | |||||
| { | |||||
| public partial class tensorflow | |||||
| { | |||||
| public class keras | |||||
| { | |||||
| public static Initializers initializers => new Initializers(); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -5,7 +5,7 @@ | |||||
| <AssemblyName>TensorFlow.NET</AssemblyName> | <AssemblyName>TensorFlow.NET</AssemblyName> | ||||
| <RootNamespace>Tensorflow</RootNamespace> | <RootNamespace>Tensorflow</RootNamespace> | ||||
| <TargetTensorFlow>2.2.0</TargetTensorFlow> | <TargetTensorFlow>2.2.0</TargetTensorFlow> | ||||
| <Version>0.20.0-alpha2</Version> | |||||
| <Version>0.20.0-preview1</Version> | |||||
| <LangVersion>8.0</LangVersion> | <LangVersion>8.0</LangVersion> | ||||
| <Authors>Haiping Chen, Meinrad Recheis, Eli Belash</Authors> | <Authors>Haiping Chen, Meinrad Recheis, Eli Belash</Authors> | ||||
| <Company>SciSharp STACK</Company> | <Company>SciSharp STACK</Company> | ||||
| @@ -44,10 +44,10 @@ | |||||
| <ItemGroup> | <ItemGroup> | ||||
| <PackageReference Include="FluentAssertions" Version="5.10.3" /> | <PackageReference Include="FluentAssertions" Version="5.10.3" /> | ||||
| <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" /> | <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" /> | ||||
| <PackageReference Include="MSTest.TestAdapter" Version="2.1.1" /> | |||||
| <PackageReference Include="MSTest.TestFramework" Version="2.1.1" /> | |||||
| <PackageReference Include="MSTest.TestAdapter" Version="2.1.2" /> | |||||
| <PackageReference Include="MSTest.TestFramework" Version="2.1.2" /> | |||||
| <PackageReference Include="NumSharp.Lite" Version="0.1.7" /> | <PackageReference Include="NumSharp.Lite" Version="0.1.7" /> | ||||
| <PackageReference Include="SciSharp.TensorFlow.Redist" Version="2.2.0.1" /> | |||||
| <PackageReference Include="SciSharp.TensorFlow.Redist" Version="2.2.0.2" /> | |||||
| </ItemGroup> | </ItemGroup> | ||||
| <ItemGroup> | <ItemGroup> | ||||