Browse Source

VocabularyProcessor is DEPRECATED, change to another example.

tags/v0.8.0
haiping008 6 years ago
parent
commit
c944f54b76
6 changed files with 39 additions and 5 deletions
  1. +6
    -0
      TensorFlow.NET.sln
  2. +19
    -0
      src/TensorFlowNET.Core/Contrib/Learn/Preprocessing/VocabularyProcessor.cs
  3. +4
    -0
      src/TensorFlowNET.Core/TensorFlowNET.Core.csproj
  4. +6
    -1
      test/TensorFlowNET.Examples/CnnTextClassification/CnnTextTrain.cs
  5. +3
    -4
      test/TensorFlowNET.Examples/CnnTextClassification/DataHelpers.cs
  6. +1
    -0
      test/TensorFlowNET.Examples/TensorFlowNET.Examples.csproj

+ 6
- 0
TensorFlow.NET.sln View File

@@ -13,6 +13,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TensorFlowNET.Utility", "sr
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TensorFlowNET.Visualization", "TensorFlowNET.Visualization\TensorFlowNET.Visualization.csproj", "{4BB2ABD1-635E-41E4-B534-CB5B6A2D754D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NumSharp.Core", "..\NumSharp\src\NumSharp.Core\NumSharp.Core.csproj", "{E8340C61-12C1-4BEE-A340-403E7C1ACD82}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -39,6 +41,10 @@ Global
{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
{E8340C61-12C1-4BEE-A340-403E7C1ACD82}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E8340C61-12C1-4BEE-A340-403E7C1ACD82}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E8340C61-12C1-4BEE-A340-403E7C1ACD82}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E8340C61-12C1-4BEE-A340-403E7C1ACD82}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE


+ 19
- 0
src/TensorFlowNET.Core/Contrib/Learn/Preprocessing/VocabularyProcessor.cs View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Tensorflow.Contrib.Learn.Preprocessing
{
public class VocabularyProcessor
{
private int _max_document_length;
private int _min_frequency;

public VocabularyProcessor(int max_document_length,
int min_frequency)
{
_max_document_length = max_document_length;
_min_frequency = min_frequency;
}
}
}

+ 4
- 0
src/TensorFlowNET.Core/TensorFlowNET.Core.csproj View File

@@ -51,4 +51,8 @@ Fixed import name scope issue.</PackageReleaseNotes>
<Content CopyToOutputDirectory="PreserveNewest" Include="./runtimes/win-x64/native/tensorflow.dll" Link="tensorflow.dll" Pack="true" PackagePath="runtimes/win-x64/native/tensorflow.dll" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\NumSharp\src\NumSharp.Core\NumSharp.Core.csproj" />
</ItemGroup>

</Project>

+ 6
- 1
test/TensorFlowNET.Examples/CnnTextClassification/CnnTextTrain.cs View File

@@ -1,6 +1,7 @@
using NumSharp.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tensorflow;

@@ -46,7 +47,11 @@ namespace TensorFlowNET.Examples.CnnTextClassification

public (NDArray, NDArray, NDArray, NDArray, NDArray) preprocess()
{
DataHelpers.load_data_and_labels(positive_data_file, negative_data_file);
var (x_text, y) = DataHelpers.load_data_and_labels(positive_data_file, negative_data_file);

// Build vocabulary
int max_document_length = x_text.Select(x => x.Split(' ').Length).Max();
var vocab_processor = learn.preprocessing.VocabularyProcessor(max_document_length)
throw new NotImplementedException("");
}
}


+ 3
- 4
test/TensorFlowNET.Examples/CnnTextClassification/DataHelpers.cs View File

@@ -17,7 +17,7 @@ namespace TensorFlowNET.Examples.CnnTextClassification
/// <param name="positive_data_file"></param>
/// <param name="negative_data_file"></param>
/// <returns></returns>
public static (NDArray, NDArray) load_data_and_labels(string positive_data_file, string negative_data_file)
public static (string[], NDArray) load_data_and_labels(string positive_data_file, string negative_data_file)
{
Directory.CreateDirectory("CnnTextClassification");
Utility.Web.Download(positive_data_file, "CnnTextClassification/rt-polarity.pos");
@@ -39,9 +39,8 @@ namespace TensorFlowNET.Examples.CnnTextClassification

var positive_labels = positive_examples.Select(x => new int[2] { 0, 1 }).ToArray();
var negative_labels = negative_examples.Select(x => new int[2] { 1, 0 }).ToArray();
// var y = np.
// return (x_text, y);
throw new NotImplementedException("load_data_and_labels");
var y = np.concatenate(new int[][][] { positive_labels, negative_labels });
return (x_text.ToArray(), y);
}

private static string clean_str(string str)


+ 1
- 0
test/TensorFlowNET.Examples/TensorFlowNET.Examples.csproj View File

@@ -11,6 +11,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\NumSharp\src\NumSharp.Core\NumSharp.Core.csproj" />
<ProjectReference Include="..\..\src\TensorFlowNET.Core\TensorFlowNET.Core.csproj" />
<ProjectReference Include="..\..\src\TensorFlowNET.Utility\TensorFlowNET.Utility.csproj" />
</ItemGroup>


Loading…
Cancel
Save