|
|
|
|
|
|
|
|
|
|
2. At the top off your C# script, add the line: |
|
|
|
|
|
|
|
```csharp |
|
|
|
using TensorFlow; |
|
|
|
``` |
|
|
|
```csharp |
|
|
|
using TensorFlow; |
|
|
|
``` |
|
|
|
```csharp |
|
|
|
#if UNITY_ANDROID |
|
|
|
TensorFlowSharp.Android.NativeBinding.Init(); |
|
|
|
#endif |
|
|
|
``` |
|
|
|
```csharp |
|
|
|
#if UNITY_ANDROID |
|
|
|
TensorFlowSharp.Android.NativeBinding.Init(); |
|
|
|
#endif |
|
|
|
``` |
|
|
|
```csharp |
|
|
|
TextAsset graphModel = Resources.Load (your_name_graph) as TextAsset; |
|
|
|
``` |
|
|
|
```csharp |
|
|
|
TextAsset graphModel = Resources.Load (your_name_graph) as TextAsset; |
|
|
|
``` |
|
|
|
```csharp |
|
|
|
graph = new TFGraph (); |
|
|
|
graph.Import (graphModel.bytes); |
|
|
|
session = new TFSession (graph); |
|
|
|
``` |
|
|
|
```csharp |
|
|
|
graph = new TFGraph (); |
|
|
|
graph.Import (graphModel.bytes); |
|
|
|
session = new TFSession (graph); |
|
|
|
``` |
|
|
|
```csharp |
|
|
|
var runner = session.GetRunner (); |
|
|
|
runner.AddInput (graph ["input_placeholder_name"] [0], new float[]{ placeholder_value1, placeholder_value2 }); |
|
|
|
``` |
|
|
|
```csharp |
|
|
|
var runner = session.GetRunner (); |
|
|
|
runner.AddInput (graph ["input_placeholder_name"] [0], new float[]{ placeholder_value1, placeholder_value2 }); |
|
|
|
``` |
|
|
|
You must provide all required inputs to the graph. Supply one input per TensorFlow placeholder. |
|
|
|
You must provide all required inputs to the graph. Supply one input per TensorFlow placeholder. |
|
|
|
```csharp |
|
|
|
runner.Fetch (graph["output_placeholder_name"][0]); |
|
|
|
float[,] recurrent_tensor = runner.Run () [0].GetValue () as float[,]; |
|
|
|
``` |
|
|
|
```csharp |
|
|
|
runner.Fetch (graph["output_placeholder_name"][0]); |
|
|
|
float[,] recurrent_tensor = runner.Run () [0].GetValue () as float[,]; |
|
|
|
``` |
|
|
|
Note that this example assumes the output array is a two-dimensional tensor of floats. Cast to a long array if your outputs are integers. |
|
|
|
Note that this example assumes the output array is a two-dimensional tensor of floats. Cast to a long array if your outputs are integers. |