Browse Source

text classification train works!!!!

tags/v0.9
Meinrad Recheis 6 years ago
parent
commit
72e96b93a2
2 changed files with 4 additions and 2 deletions
  1. +2
    -2
      test/TensorFlowNET.Examples/TextProcess/DataHelpers.cs
  2. +2
    -0
      test/TensorFlowNET.Examples/TextProcess/TextClassificationTrain.cs

+ 2
- 2
test/TensorFlowNET.Examples/TextProcess/DataHelpers.cs View File

@@ -25,8 +25,8 @@ namespace TensorFlowNET.Examples
char_dict["<unk>"] = 1;
foreach (char c in alphabet)
char_dict[c.ToString()] = char_dict.Count;
var contents = File.ReadAllLines(TRAIN_PATH);
var random=new Random(42);
var contents = File.ReadAllLines(TRAIN_PATH).OrderBy(line=>random.NextDouble()).ToArray();
var size = limit == null ? contents.Length : limit.Value;

var x = new NDArray(np.int32, new Shape(size, document_max_len));


+ 2
- 0
test/TensorFlowNET.Examples/TextProcess/TextClassificationTrain.cs View File

@@ -91,6 +91,8 @@ namespace TensorFlowNET.Examples.CnnTextClassification
[model_y] = y_batch,
[is_training] = true,
};
//Console.WriteLine("x: " + x_batch.ToString() + "\n");
//Console.WriteLine("y: " + y_batch.ToString());
// original python:
//_, step, loss = sess.run([model.optimizer, model.global_step, model.loss], feed_dict = train_feed_dict)
var result = sess.run(new ITensorOrOperation[] { optimizer, global_step, loss }, train_feed_dict);


Loading…
Cancel
Save