forked from SciSharp/SciSharp-Stack-Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHelloWorld.cs
More file actions
36 lines (30 loc) · 1.08 KB
/
Copy pathHelloWorld.cs
File metadata and controls
36 lines (30 loc) · 1.08 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
using static Tensorflow.Binding;
namespace TensorFlowNET.Examples
{
/// <summary>
/// A very simple "hello world" using TensorFlow v2 tensors.
/// https://github.com/aymericdamien/TensorFlow-Examples/blob/master/tensorflow_v2/notebooks/1_Introduction/helloworld.ipynb
/// </summary>
public class HelloWorld : SciSharpExample, IExample
{
public ExampleConfig InitConfig()
=> Config = new ExampleConfig
{
Name = "Hello World",
Priority = 1
};
public bool Run()
{
/* Create a Constant op
The op is added as a node to the default graph.
The value returned by the constructor represents the output
of the Constant op. */
var str = "Hello, TensorFlow.NET!";
var hello = tf.constant(str);
// tf.Tensor: shape=(), dtype=string, numpy=b'Hello, TensorFlow.NET!'
print(hello);
var tensor = (string)hello.numpy();
return str == tensor;
}
}
}