Skip to content

Commit cb82daf

Browse files
committed
fix dictionary access when modified.
1 parent 43d7833 commit cb82daf

3 files changed

Lines changed: 17 additions & 0 deletions

File tree

src/TensorFlowNET.Core/Variables/_VariableScopeStore.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ public void open_variable_scope(string scope_name)
4141

4242
public void close_variable_subscopes(string scope_name)
4343
{
44+
var variable_scopes_count_tmp = new Dictionary<string, int>();
4445
foreach (var k in variable_scopes_count.Keys)
46+
variable_scopes_count_tmp.Add(k, variable_scopes_count[k]);
47+
48+
foreach (var k in variable_scopes_count_tmp.Keys)
4549
if (scope_name == null || k.StartsWith(scope_name + "/"))
4650
variable_scopes_count[k] = 0;
4751
}

test/TensorFlowNET.Examples/ImageProcess/DigitRecognitionCNN.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ public class DigitRecognitionCNN : IExample
7373
float accuracy_test = 0f;
7474
float loss_test = 1f;
7575

76+
NDArray x_train;
77+
7678
public bool Run()
7779
{
7880
PrepareData();
@@ -241,11 +243,19 @@ private Tensor fc_layer(Tensor x, int num_units, string name, bool use_relu = tr
241243
public void PrepareData()
242244
{
243245
mnist = MNIST.read_data_sets("mnist", one_hot: true);
246+
x_train = Reformat(mnist.train.data, mnist.train.labels);
244247
print("Size of:");
245248
print($"- Training-set:\t\t{len(mnist.train.data)}");
246249
print($"- Validation-set:\t{len(mnist.validation.data)}");
247250
}
248251

252+
private NDArray Reformat(NDArray x, NDArray y)
253+
{
254+
var (img_size, num_ch, num_class) = (np.sqrt(x.shape[1]), 1, np.unique<int>(np.argmax(y, 1)));
255+
256+
return x;
257+
}
258+
249259
public void Train(Session sess)
250260
{
251261
// Number of training iterations in each epoch

test/TensorFlowNET.UnitTest/ExamplesTests/ExamplesTest.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public void InceptionArchGoogLeNet()
3939
new InceptionArchGoogLeNet() { Enabled = true }.Run();
4040
}
4141

42+
[Ignore]
4243
[TestMethod]
4344
public void KMeansClustering()
4445
{
@@ -83,10 +84,12 @@ public void NearestNeighbor()
8384
new NearestNeighbor() { Enabled = true, TrainSize = 500, ValidationSize = 100, TestSize = 100 }.Run();
8485
}
8586

87+
[Ignore]
8688
[TestMethod]
8789
public void WordCnnTextClassification()
8890
=> new CnnTextClassification { Enabled = true, ModelName = "word_cnn", DataLimit =100 }.Run();
8991

92+
[Ignore]
9093
[TestMethod]
9194
public void CharCnnTextClassification()
9295
=> new CnnTextClassification { Enabled = true, ModelName = "char_cnn", DataLimit = 100 }.Run();

0 commit comments

Comments
 (0)