-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReadMe.ps1
More file actions
51 lines (38 loc) · 1.51 KB
/
ReadMe.ps1
File metadata and controls
51 lines (38 loc) · 1.51 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using namespace TensorFlow;
$schost = Get-SCHost;
$assemblyFileName = $schost.MapPath('~\bin\TensorFlowSharp.dll');
Add-Type -Path:$assemblyFileName | Out-Null;
$schost.Silent = $true;
Clear-Book;
Clear-Spreadsheet;
Invoke-SCScript '~\InitBookStyles.ps1';
Set-BookSectionHeader '<b>Spread Commander</b> - <i>Examples: TensorFlow</i>' -Html;
Set-BookSectionFooter 'Page {PAGE} of {NUMPAGES}' -ExpandFields;
Write-Text -ParagraphStyle:'Header1' 'TENSORFLOW';
Write-Html -ParagraphStyle:'Description' @'
<p align=justify><b>PowerShell</b> script allows to reference .Net (Core) assemblies.
This example shows how to use .Net Core <b>Tensorflow</b> engine.
After executing script look also tab <b>Spreadsheet</b>.</p>
'@;
Write-Html -ParagraphStyle:'Description' @'
Download last <b>TensorFlowSharp</b> libraries from <a href="https://www.nuget.org/packages/TensorFlowSharp/">Nuget,
https://www.nuget.org/packages/TensorFlowSharp//</a> and unpack in folder <b>bin</b> of then <b>SpreadCommander</p> project.
'@;
$session = [TFSession]::new();
try
{
$graph = $session.Graph;
$a = $graph.Const(2);
$b = $graph.Const(3);
Write-Host 'a = 2; b = 3';
$addingResults = $session.GetRunner().Run($graph.Add($a, $b));
$addingValue = $addingResults.GetValue();
Write-Host "a + b = $addingValue";
$multiplyResults = $session.GetRunner().Run($graph.Mul($a, $b));
$multiplyValue = $multiplyResults.GetValue();
Write-Host "a * b = $multiplyValue";
}
finally
{
$session.Dispose();
}