diff --git a/TensorFlow.NET.sln b/TensorFlow.NET.sln index f662c554..7f124824 100644 --- a/TensorFlow.NET.sln +++ b/TensorFlow.NET.sln @@ -11,9 +11,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TensorFlowNET.Core", "src\T EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TensorFlowNET.Utility", "src\TensorFlowNET.Utility\TensorFlowNET.Utility.csproj", "{00D9085C-0FC7-453C-A0CC-BAD98F44FEA0}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KerasNET.Core", "..\Keras.NET\src\KerasNET.Core\KerasNET.Core.csproj", "{07E37E81-3BCD-4BBB-AE5D-28527F1C7745}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TensorFlowNET.Visualization", "TensorFlowNET.Visualization\TensorFlowNET.Visualization.csproj", "{4BB2ABD1-635E-41E4-B534-CB5B6A2D754D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TensorFlowNET.Visualization", "TensorFlowNET.Visualization\TensorFlowNET.Visualization.csproj", "{4BB2ABD1-635E-41E4-B534-CB5B6A2D754D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KerasNET.Core", "..\Keras.NET\src\KerasNET.Core\KerasNET.Core.csproj", "{E2F0C39C-D706-4CF5-AE00-81FB447F949D}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -37,14 +37,14 @@ Global {00D9085C-0FC7-453C-A0CC-BAD98F44FEA0}.Debug|Any CPU.Build.0 = Debug|Any CPU {00D9085C-0FC7-453C-A0CC-BAD98F44FEA0}.Release|Any CPU.ActiveCfg = Release|Any CPU {00D9085C-0FC7-453C-A0CC-BAD98F44FEA0}.Release|Any CPU.Build.0 = Release|Any CPU - {07E37E81-3BCD-4BBB-AE5D-28527F1C7745}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {07E37E81-3BCD-4BBB-AE5D-28527F1C7745}.Debug|Any CPU.Build.0 = Debug|Any CPU - {07E37E81-3BCD-4BBB-AE5D-28527F1C7745}.Release|Any CPU.ActiveCfg = Release|Any CPU - {07E37E81-3BCD-4BBB-AE5D-28527F1C7745}.Release|Any CPU.Build.0 = Release|Any CPU {4BB2ABD1-635E-41E4-B534-CB5B6A2D754D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4BB2ABD1-635E-41E4-B534-CB5B6A2D754D}.Debug|Any CPU.Build.0 = Debug|Any CPU {4BB2ABD1-635E-41E4-B534-CB5B6A2D754D}.Release|Any CPU.ActiveCfg = Release|Any CPU {4BB2ABD1-635E-41E4-B534-CB5B6A2D754D}.Release|Any CPU.Build.0 = Release|Any CPU + {E2F0C39C-D706-4CF5-AE00-81FB447F949D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E2F0C39C-D706-4CF5-AE00-81FB447F949D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E2F0C39C-D706-4CF5-AE00-81FB447F949D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E2F0C39C-D706-4CF5-AE00-81FB447F949D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/test/TensorFlowNET.Examples/TensorFlowNET.Examples.csproj b/test/TensorFlowNET.Examples/TensorFlowNET.Examples.csproj index 826e0ae0..d5986423 100644 --- a/test/TensorFlowNET.Examples/TensorFlowNET.Examples.csproj +++ b/test/TensorFlowNET.Examples/TensorFlowNET.Examples.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp2.1 + netcoreapp2.2 diff --git a/test/TensorFlowNET.Examples/TextClassificationWithMovieReviews.cs b/test/TensorFlowNET.Examples/TextClassificationWithMovieReviews.cs index ace5ab31..3b17be10 100644 --- a/test/TensorFlowNET.Examples/TextClassificationWithMovieReviews.cs +++ b/test/TensorFlowNET.Examples/TextClassificationWithMovieReviews.cs @@ -7,6 +7,7 @@ using NumSharp.Core; using Newtonsoft.Json; using System.Linq; using Keras; +using System.Text.RegularExpressions; namespace TensorFlowNET.Examples { @@ -42,27 +43,45 @@ namespace TensorFlowNET.Examples Utility.Compress.UnZip(zipFile, dir); // prepare training dataset - NDArray x_train = File.ReadAllLines(Path.Join(dir, "x_train.txt")); - NDArray labels_train = File.ReadAllLines(Path.Join(dir, "y_train.txt")); - NDArray indices_train = File.ReadAllLines(Path.Join(dir, "indices_train.txt")); + var x_train = ReadData(Path.Join(dir, "x_train.txt")); + var labels_train = ReadData(Path.Join(dir, "y_train.txt")); + var indices_train = ReadData(Path.Join(dir, "indices_train.txt")); // x_train = x_train[indices_train]; // labels_train = labels_train[indices_train]; - NDArray x_test = File.ReadAllLines(Path.Join(dir, "x_test.txt")); - NDArray labels_test = File.ReadAllLines(Path.Join(dir, "y_test.txt")); - NDArray indices_test = File.ReadAllLines(Path.Join(dir, "indices_test.txt")); + var x_test = ReadData(Path.Join(dir, "x_test.txt")); + var labels_test = ReadData(Path.Join(dir, "y_test.txt")); + var indices_test = ReadData(Path.Join(dir, "indices_test.txt")); // x_test = x_test[indices_test]; // labels_test = labels_test[indices_test]; // not completed - var xs = x_train.hstack(x_test); + /*var xs = x_train.hstack(x_test); var labels = labels_train.hstack(labels_test); var idx = x_train.size; var y_train = labels_train; var y_test = labels_test; - return ((x_train, y_train), (x_test, y_test)); + return ((x_train, y_train), (x_test, y_test));*/ + + throw new NotImplementedException(); + } + + private int[][] ReadData(string file) + { + var lines = new List(); + + foreach(var line in File.ReadAllLines(file)) + { + var matches = Regex.Matches(line, @"\d+,*"); + var data = new int[matches.Count]; + for (int i = 0; i < data.Length; i++) + data[i] = Convert.ToInt32(matches[i].Value.Trim(',')); + lines.Add(data.ToArray()); + } + + return lines.ToArray(); } private Dictionary GetWordIndex()