「TensorFlowSharp」の版間の差分

imported>Administrator
編集の要約なし
imported>Administrator
編集の要約なし
41行目: 41行目:


=== 足し算 ===
=== 足し算 ===
とりあえず「c = a + b」という式をTensorFlowに投げて実行してみる。
とりあえず「c = a + b」という式をTensorFlowに投げて実行してみる。<syntaxhighlight>
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>


=== 保存と読込 ===
=== 保存と読込 ===
<syntaxhighlight>
保存と読込ができるようになったぞ。<syntaxhighlight>
using System;
using System;
using System.Collections.Generic;
using System.Collections.Generic;