Browse Source

fix dictionary access when modified.

tags/v0.10
Oceania2018 6 years ago
parent
commit
cb82dafcf7
3 changed files with 17 additions and 0 deletions
  1. +4
    -0
      src/TensorFlowNET.Core/Variables/_VariableScopeStore.cs
  2. +10
    -0
      test/TensorFlowNET.Examples/ImageProcess/DigitRecognitionCNN.cs
  3. +3
    -0
      test/TensorFlowNET.UnitTest/ExamplesTests/ExamplesTest.cs

+ 4
- 0
src/TensorFlowNET.Core/Variables/_VariableScopeStore.cs View File

@@ -41,7 +41,11 @@ namespace Tensorflow

public void close_variable_subscopes(string scope_name)
{
var variable_scopes_count_tmp = new Dictionary<string, int>();
foreach (var k in variable_scopes_count.Keys)
variable_scopes_count_tmp.Add(k, variable_scopes_count[k]);

foreach (var k in variable_scopes_count_tmp.Keys)
if (scope_name == null || k.StartsWith(scope_name + "/"))
variable_scopes_count[k] = 0;
}


+ 10
- 0
test/TensorFlowNET.Examples/ImageProcess/DigitRecognitionCNN.cs View File

@@ -73,6 +73,8 @@ namespace TensorFlowNET.Examples.ImageProcess
float accuracy_test = 0f;
float loss_test = 1f;

NDArray x_train;

public bool Run()
{
PrepareData();
@@ -241,11 +243,19 @@ namespace TensorFlowNET.Examples.ImageProcess
public void PrepareData()
{
mnist = MNIST.read_data_sets("mnist", one_hot: true);
x_train = Reformat(mnist.train.data, mnist.train.labels);
print("Size of:");
print($"- Training-set:\t\t{len(mnist.train.data)}");
print($"- Validation-set:\t{len(mnist.validation.data)}");
}

private NDArray Reformat(NDArray x, NDArray y)
{
var (img_size, num_ch, num_class) = (np.sqrt(x.shape[1]), 1, np.unique<int>(np.argmax(y, 1)));

return x;
}

public void Train(Session sess)
{
// Number of training iterations in each epoch


+ 3
- 0
test/TensorFlowNET.UnitTest/ExamplesTests/ExamplesTest.cs View File

@@ -39,6 +39,7 @@ namespace TensorFlowNET.ExamplesTests
new InceptionArchGoogLeNet() { Enabled = true }.Run();
}
[Ignore]
[TestMethod]
public void KMeansClustering()
{
@@ -83,10 +84,12 @@ namespace TensorFlowNET.ExamplesTests
new NearestNeighbor() { Enabled = true, TrainSize = 500, ValidationSize = 100, TestSize = 100 }.Run();
}
[Ignore]
[TestMethod]
public void WordCnnTextClassification()
=> new CnnTextClassification { Enabled = true, ModelName = "word_cnn", DataLimit =100 }.Run();
[Ignore]
[TestMethod]
public void CharCnnTextClassification()
=> new CnnTextClassification { Enabled = true, ModelName = "char_cnn", DataLimit = 100 }.Run();


Loading…
Cancel
Save