Skip to content

Commit da48a2a

Browse files
committed
fix default graph issue for DigitRecognitionNN.
1 parent bf3d1e9 commit da48a2a

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

src/TensorFlowNET.Core/TensorFlowNET.Core.csproj

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<AssemblyName>TensorFlow.NET</AssemblyName>
66
<RootNamespace>Tensorflow</RootNamespace>
77
<TargetTensorFlow>1.14.0</TargetTensorFlow>
8-
<Version>0.8.3</Version>
8+
<Version>0.9.0</Version>
99
<Authors>Haiping Chen, Meinrad Recheis</Authors>
1010
<Company>SciSharp STACK</Company>
1111
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
@@ -17,16 +17,14 @@
1717
<PackageTags>TensorFlow, NumSharp, SciSharp, MachineLearning, TensorFlow.NET, C#</PackageTags>
1818
<Description>Google's TensorFlow full binding in .NET Standard.
1919
Docs: https://tensorflownet.readthedocs.io</Description>
20-
<AssemblyVersion>0.8.3.0</AssemblyVersion>
21-
<PackageReleaseNotes>Changes since v0.8:
20+
<AssemblyVersion>0.9.0.0</AssemblyVersion>
21+
<PackageReleaseNotes>Changes since v0.8.3:
2222

23-
1. Remove global static graph instance.
24-
2. Provide custom gradient function.
25-
3. Add gradient function for Conv2D.
26-
4. Fix bug for Transfer Learning example.
27-
5. Overload Graph.Import(byte[] bytes)</PackageReleaseNotes>
23+
1. Added full connected Neural Network example.
24+
2. Added word CNN Text Classification example.
25+
3. Fixed AdaOptimizer issue.</PackageReleaseNotes>
2826
<LangVersion>7.2</LangVersion>
29-
<FileVersion>0.8.3.0</FileVersion>
27+
<FileVersion>0.9.0.0</FileVersion>
3028
</PropertyGroup>
3129

3230
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

test/TensorFlowNET.Examples/ImageProcess/DigitRecognitionNN.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,19 @@ public class DigitRecognitionNN : IExample
4040

4141
public bool Run()
4242
{
43+
bool successful = false;
44+
4345
PrepareData();
4446
BuildGraph();
45-
Train();
47+
successful = Train();
4648

47-
return true;
49+
return successful;
4850
}
4951

5052
public Graph BuildGraph()
5153
{
54+
var graph = new Graph().as_default();
55+
5256
// Placeholders for inputs (x) and outputs(y)
5357
x = tf.placeholder(tf.float32, shape: (-1, img_size_flat), name: "X");
5458
y = tf.placeholder(tf.float32, shape: (-1, n_classes), name: "Y");
@@ -67,7 +71,7 @@ public Graph BuildGraph()
6771
// Network predictions
6872
var cls_prediction = tf.argmax(output_logits, axis: 1, name: "predictions");
6973

70-
return tf.get_default_graph();
74+
return graph;
7175
}
7276

7377
private Tensor fc_layer(Tensor x, int num_units, string name, bool use_relu = true)

test/TensorFlowNET.Examples/TextProcess/CnnTextClassification.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ private bool Train(Session sess, Graph graph)
298298
}
299299
}
300300

301-
return max_accuracy > 0.8;
301+
return max_accuracy > 0.9;
302302
}
303303

304304
public bool Train()

0 commit comments

Comments
 (0)