forked from SciSharp/TensorFlow.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMetaGraph.cs
More file actions
40 lines (36 loc) · 1.2 KB
/
MetaGraph.cs
File metadata and controls
40 lines (36 loc) · 1.2 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
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using Tensorflow;
namespace TensorFlowNET.Examples
{
public class MetaGraph : Python, IExample
{
public int Priority => 100;
public bool Enabled => false;
public string Name => "Meta Graph";
public bool Run()
{
ImportMetaGraph("my-save-dir/");
return false;
}
private void ImportMetaGraph(string dir)
{
with(tf.Session(), sess =>
{
var new_saver = tf.train.import_meta_graph(dir + "my-model-10000.meta");
new_saver.restore(sess, dir + "my-model-10000");
var labels = tf.constant(0, dtype: tf.int32, shape: new int[] { 100 }, name: "labels");
var batch_size = tf.size(labels);
var logits = (tf.get_collection("logits") as List<ITensorOrOperation>)[0] as Tensor;
var loss = tf.losses.sparse_softmax_cross_entropy(labels: labels,
logits: logits);
});
}
public void PrepareData()
{
}
}
}