Skip to content

Commit 79eb262

Browse files
committed
Initial Word2Vec example.
1 parent e152782 commit 79eb262

7 files changed

Lines changed: 44 additions & 0 deletions

File tree

data/text8.zip

29.9 MB
Binary file not shown.

graph/word2vec.meta

71.6 KB
Binary file not shown.

test/TensorFlowNET.Examples/TextClassification/DataHelpers.cs renamed to test/TensorFlowNET.Examples/Text/DataHelpers.cs

File renamed without changes.

test/TensorFlowNET.Examples/TextClassification/TextClassificationTrain.cs renamed to test/TensorFlowNET.Examples/Text/TextClassificationTrain.cs

File renamed without changes.

test/TensorFlowNET.Examples/TextClassification/TextClassificationWithMovieReviews.cs renamed to test/TensorFlowNET.Examples/Text/TextClassificationWithMovieReviews.cs

File renamed without changes.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
using Tensorflow;
5+
6+
namespace TensorFlowNET.Examples
7+
{
8+
/// <summary>
9+
/// Implement Word2Vec algorithm to compute vector representations of words.
10+
/// https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/2_BasicModels/word2vec.py
11+
/// </summary>
12+
public class Word2Vec : Python, IExample
13+
{
14+
public int Priority => 12;
15+
public bool Enabled { get; set; } = true;
16+
public string Name => "Word2Vec";
17+
18+
// Training Parameters
19+
float learning_rate = 0.1f;
20+
int batch_size = 128;
21+
int num_steps = 3000000;
22+
int display_step = 10000;
23+
int eval_step = 200000;
24+
25+
// Evaluation Parameters
26+
string[] eval_words = new string[] { "five", "of", "going", "hardware", "american", "britain" };
27+
28+
public bool Run()
29+
{
30+
PrepareData();
31+
32+
var graph = tf.Graph().as_default();
33+
34+
tf.train.import_meta_graph("graph/word2vec.meta");
35+
36+
return false;
37+
}
38+
39+
public void PrepareData()
40+
{
41+
var url = "";
42+
}
43+
}
44+
}

test/TensorFlowNET.Examples/TextClassification/cnn_models/VdCnn.cs renamed to test/TensorFlowNET.Examples/Text/cnn_models/VdCnn.cs

File renamed without changes.

0 commit comments

Comments
 (0)