| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 6d66092 commit c632c40
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,5 @@ | |||
| 1 | 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; | |
| 2 | + using NumSharp; | ||
| 2 | 3 | using System; | |
| 3 | 4 | using Tensorflow; | |
| 4 | 5 | using static Tensorflow.Binding; | |
@@ -45,5 +46,21 @@ public void WhileLoopGraphMode() | |||
| 45 | 46 | var r = tf.while_loop(c, b, i); | |
| 46 | 47 | Assert.AreEqual(10, (int)r); | |
| 47 | 48 | } | |
| 49 | + | ||
| 50 | + [TestMethod, Ignore] | ||
| 51 | + public void ScanFunctionGraphMode() | ||
| 52 | + { | ||
| 53 | + tf.compat.v1.disable_eager_execution(); | ||
| 54 | + Func<Tensor, Tensor, Tensor> fn = (prev, current) => tf.add(prev, current); | ||
| 55 | + var input = tf.placeholder(TF_DataType.TF_FLOAT, new TensorShape(6)); | ||
| 56 | + var scan = tf.scan(fn, input); | ||
| 57 | + | ||
| 58 | + using (var sess = tf.Session()) | ||
| 59 | + { | ||
| 60 | + sess.run(tf.global_variables_initializer()); | ||
| 61 | + var result = sess.run(scan, new FeedItem(input, np.array(1, 2, 3, 4, 5, 6))); | ||
| 62 | + Assert.AreEqual(new float[] { 1, 3, 6, 10, 15, 21 }, result.ToArray<float>()); | ||
| 63 | + } | ||
| 64 | + } | ||
| 48 | 65 | } | |
| 49 | 66 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments