@@ -95,46 +95,46 @@ To load and use a TensorFlow data graph in Unity:
9595
96962 . At the top off your C# script, add the line:
9797
98- ```csharp
99- using TensorFlow;
100- ```
98+ ``` csharp
99+ using TensorFlow ;
100+ ```
101101
1021023 . If you will be building for android, you must add this block at the start of your code :
103103
104- ```csharp
105- #if UNITY_ANDROID
106- TensorFlowSharp.Android.NativeBinding.Init();
107- #endif
108- ```
104+ ``` csharp
105+ #if UNITY_ANDROID
106+ TensorFlowSharp .Android .NativeBinding .Init ();
107+ #endif
108+ ```
109109
1101104 . Load your graph as a text asset into a variable, such as ` graphModel ` :
111111
112- ```csharp
113- TextAsset graphModel = Resources.Load (your_name_graph) as TextAsset;
114- ```
112+ ``` csharp
113+ TextAsset graphModel = Resources .Load (your_name_graph ) as TextAsset ;
114+ ```
115115
1161165 . You then must instantiate the graph in Unity by adding the code :
117117
118- ```csharp
119- graph = new TFGraph ();
120- graph.Import (graphModel.bytes);
121- session = new TFSession (graph);
122- ```
118+ ``` csharp
119+ graph = new TFGraph ();
120+ graph .Import (graphModel .bytes );
121+ session = new TFSession (graph );
122+ ```
123123
1241246 . Assign the input tensors for the graph. For example, the following code assigns a one dimensional input tensor of size 2:
125125
126- ```csharp
127- var runner = session.GetRunner ();
128- runner.AddInput (graph ["input_placeholder_name"] [0], new float[]{ placeholder_value1, placeholder_value2 });
129- ```
126+ ``` csharp
127+ var runner = session .GetRunner ();
128+ runner .AddInput (graph [" input_placeholder_name" ] [0 ], new float []{ placeholder_value1 , placeholder_value2 });
129+ ```
130130
131- You must provide all required inputs to the graph. Supply one input per TensorFlow placeholder.
131+ You must provide all required inputs to the graph. Supply one input per TensorFlow placeholder.
132132
1331337 . To calculate and access the output of your graph, run the following code.
134134
135- ```csharp
136- runner.Fetch (graph["output_placeholder_name"][0]);
137- float[,] recurrent_tensor = runner.Run () [0].GetValue () as float[,];
138- ```
135+ ``` csharp
136+ runner .Fetch (graph [" output_placeholder_name" ][0 ]);
137+ float [,] recurrent_tensor = runner .Run () [0 ].GetValue () as float [,];
138+ ```
139139
140- 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.
140+ 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.
0 commit comments