forked from SciSharp/TensorFlow.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOperationsTest.cs
More file actions
55 lines (48 loc) · 1.26 KB
/
OperationsTest.cs
File metadata and controls
55 lines (48 loc) · 1.26 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
46
47
48
49
50
51
52
53
54
55
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Text;
using Tensorflow;
namespace TensorFlowNET.UnitTest
{
[TestClass]
public class OperationsTest
{
[TestMethod]
public void constant()
{
var x = tf.constant(4.0f);
}
[TestMethod]
public void placeholder()
{
var x = tf.placeholder(tf.float32);
}
[TestMethod]
public void addInPlaceholder()
{
var a = tf.placeholder(tf.float32);
var b = tf.placeholder(tf.float32);
var c = tf.add(a, b);
using(var sess = tf.Session())
{
var feed_dict = new Dictionary<Tensor, object>();
feed_dict.Add(a, 3.0f);
feed_dict.Add(b, 2.0f);
var o = sess.run(c, feed_dict);
}
}
[TestMethod]
public void addInConstant()
{
var a = tf.constant(4.0f);
var b = tf.constant(5.0f);
var c = tf.add(a, b);
using (var sess = tf.Session())
{
var o = sess.run(c);
Assert.AreEqual(o, 9.0f);
}
}
}
}