forked from SciSharp/TensorFlow.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNameScopeTest.cs
More file actions
45 lines (38 loc) · 1.35 KB
/
NameScopeTest.cs
File metadata and controls
45 lines (38 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Text;
using Tensorflow;
namespace TensorFlowNET.UnitTest
{
[TestClass]
public class NameScopeTest : Python
{
Graph g = ops.get_default_graph();
string name = "";
[TestMethod]
public void NestedNameScope()
{
with<ops.name_scope>(new ops.name_scope("scope1"), scope1 =>
{
name = scope1;
Assert.AreEqual("scope1", g._name_stack);
Assert.AreEqual("scope1/", name);
var const1 = tf.constant(1.0);
Assert.AreEqual("scope1/Const:0", const1.name);
with<ops.name_scope>(new ops.name_scope("scope2"), scope2 =>
{
name = scope2;
Assert.AreEqual("scope1/scope2", g._name_stack);
Assert.AreEqual("scope1/scope2/", name);
var const2 = tf.constant(2.0);
Assert.AreEqual("scope1/scope2/Const:0", const2.name);
});
Assert.AreEqual("scope1", g._name_stack);
var const3 = tf.constant(2.0);
Assert.AreEqual("scope1/Const_1:0", const3.name);
});
Assert.AreEqual("", g._name_stack);
}
}
}