-
Notifications
You must be signed in to change notification settings - Fork 103
/
HelloWorld.fs
30 lines (22 loc) · 1005 Bytes
/
HelloWorld.fs
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
namespace TensorFlowNET.Examples.FSharp
open NumSharp
open type Tensorflow.Binding
/// A very simple "hello world" using TensorFlow v2 tensors.
/// https://github.com/aymericdamien/TensorFlow-Examples/blob/master/tensorflow_v2/notebooks/1_Introduction/helloworld.ipynb
module HelloWorld =
let private run () =
// Eager model is enabled by default.
tf.enable_eager_execution()
(* 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. *)
let str = "Hello, TensorFlow.NET!"
let hello = tf.constant(str)
// tf.Tensor: shape=(), dtype=string, numpy=b'Hello, TensorFlow.NET!'
print(hello);
let tensor = NDArray.AsStringArray(hello.numpy()).[0]
str = tensor
let Example =
{ Config = ExampleConfig.Create("Hello World", priority = 1)
Run = run }