最新版 |
編集中の文章 |
41行目: |
41行目: |
| | | |
| === 足し算 === | | === 足し算 === |
− | とりあえず「c = a + b」という式をTensorFlowに投げて実行してみる。<syntaxhighlight> | + | とりあえず「c = a + b」という式をTensorFlowに投げて実行してみる。 |
− | using System;
| |
− | using System.Collections.Generic;
| |
− | using System.Linq;
| |
− | using TensorFlow;
| |
− | | |
− | namespace sample
| |
− | {
| |
− | class MainClass
| |
− | {
| |
− | public static void Main(string[] args)
| |
− | {
| |
− | var graph = new TFGraph();
| |
− | var a = graph.Const( 1, "a"); // a = 1
| |
− | var b = graph.Const( 2, "b"); // b = 2
| |
− | var c = graph.Add( a, b, "c"); // c = a + b
| |
− | | |
− | // 実行
| |
− | var session = new TFSession(graph, new TFSessionOptions());
| |
− | var runner = session.GetRunner();
| |
− | var result = runner.Run(c);
| |
− | | |
− | // c = 3
| |
− | Console.WriteLine(result.FirstOrDefault());
| |
− | }
| |
− | }
| |
− | }
| |
− | </syntaxhighlight>
| |
| | | |
| === 保存と読込 === | | === 保存と読込 === |
− | 1年前はできなかった保存と読込ができるようになったぞ。トレーニングも捗るな。<syntaxhighlight>
| + | <syntaxhighlight> |
| using System; | | using System; |
| using System.Collections.Generic; | | using System.Collections.Generic; |