Skip to content

Commit 2afbc18

Browse files
author
Marwan Mattar
authored
Merge pull request #475 from Unity-Technologies/docs/csharp-reference-fix
Fixed C# Markdown
2 parents 5104366 + c6f55e1 commit 2afbc18

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

docs/Using-TensorFlow-Sharp-in-Unity.md

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -95,46 +95,46 @@ To load and use a TensorFlow data graph in Unity:
9595

9696
2. At the top off your C# script, add the line:
9797

98-
```csharp
99-
using TensorFlow;
100-
```
98+
```csharp
99+
using TensorFlow;
100+
```
101101

102102
3. 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

110110
4. 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

116116
5. 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

124124
6. 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

133133
7. 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

Comments
 (0)