forked from kerryjiang/TensorFlow.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBasicEagerApi.cs
More file actions
73 lines (60 loc) · 1.88 KB
/
BasicEagerApi.cs
File metadata and controls
73 lines (60 loc) · 1.88 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
using System;
using Tensorflow;
using static Tensorflow.Binding;
namespace TensorFlowNET.Examples
{
/// <summary>
/// Basic introduction to TensorFlow's Eager API.
/// https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/1_Introduction/basic_eager_api.py
/// </summary>
public class BasicEagerApi : IExample
{
public bool Enabled { get; set; } = false;
public string Name => "Basic Eager";
public bool IsImportingGraph { get; set; } = false;
private Tensor a, b, c, d;
public bool Run()
{
// Set Eager API
Console.WriteLine("Setting Eager mode...");
tf.enable_eager_execution();
// Define constant tensors
Console.WriteLine("Define constant tensors");
a = tf.constant(2);
Console.WriteLine($"a = {a}");
b = tf.constant(3);
Console.WriteLine($"b = {b}");
// Run the operation without the need for tf.Session
Console.WriteLine("Running operations, without tf.Session");
c = a + b;
Console.WriteLine($"a + b = {c}");
d = a * b;
Console.WriteLine($"a * b = {d}");
// Full compatibility with Numpy
return true;
}
public void PrepareData()
{
}
public Graph ImportGraph()
{
throw new NotImplementedException();
}
public Graph BuildGraph()
{
throw new NotImplementedException();
}
public void Predict(Session sess)
{
throw new NotImplementedException();
}
public void Train(Session sess)
{
throw new NotImplementedException();
}
public void Test(Session sess)
{
throw new NotImplementedException();
}
}
}