|
12345678910111213141516171819202122232425262728293031 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using Tensorflow;
-
- namespace TensorFlowNET.Examples
- {
- /// <summary>
- /// Basic Operations example using TensorFlow library.
- /// https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/1_Introduction/basic_operations.py
- /// </summary>
- public class BasicOperations : IExample
- {
- public void Run()
- {
- // Basic constant operations
- // The value returned by the constructor represents the output
- // of the Constant op.
- var a = tf.constant(2);
- var b = tf.constant(3);
- var c = a * b;
- // Launch the default graph.
- using (var sess = tf.Session())
- {
- Console.WriteLine("a=2, b=3");
- Console.WriteLine($"Addition with constants: {sess.run(a + b)}");
- Console.WriteLine($"Multiplication with constants: {sess.run(a * b)}");
- }
- }
- }
- }
|