You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/guide/export.rst
+22-49Lines changed: 22 additions & 49 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,8 +37,7 @@ If you are using PyTorch 2.0+ and ONNX Opset 14+, you can easily export SB3 poli
37
37
38
38
.. warning::
39
39
40
-
The following returns normalized actions and doesn't include the `post-processing <https://github.com/DLR-RM/stable-baselines3/blob/a9273f968eaf8c6e04302a07d803eebfca6e7e86/stable_baselines3/common/policies.py#L370-L377>`_ step that is done with continuous actions
41
-
(clip or unscale the action to the correct space).
40
+
The following returns normalized actions and doesn't include the `post-processing <https://github.com/DLR-RM/stable-baselines3/blob/a9273f968eaf8c6e04302a07d803eebfca6e7e86/stable_baselines3/common/policies.py#L370-L377>`_ step that is done with continuous actions (clip or unscale the action to the correct space).
42
41
43
42
44
43
.. code-block:: python
@@ -195,19 +194,22 @@ There is a draft PR in the RL Zoo about C++ export: https://github.com/DLR-RM/rl
195
194
Export to ONNX-JS / ONNX Runtime Web
196
195
------------------------------------
197
196
198
-
The official documentation is located at: https://onnxruntime.ai/docs/tutorials/web/build-web-app.html
197
+
Official documentation: https://onnxruntime.ai/docs/tutorials/web/build-web-app.html
199
198
200
-
Full example code: https://github.com/JonathanColetti/CarDodgingGym and demo: https://jonathancoletti.github.io/CarDodgingGym/
199
+
Full example code: https://github.com/JonathanColetti/CarDodgingGym
201
200
202
-
The code linked above is a complete example (using car dodging) that:
#NOTE: You may have to postprocess (unnormalize or renormalize)
224
+
#NOTE: You may have to postprocess (unnormalize or renormalize)
223
225
returnself.actor(observation, deterministic=True)
224
226
225
227
@@ -239,7 +241,7 @@ Below is a simple example with converting to ONNX then inferencing without postp
239
241
)
240
242
241
243
.. code-block:: javascript
242
-
244
+
243
245
// Install using `npm install onnxruntime-web` (tested with version 1.19) or using cdn
244
246
import*asortfrom'onnxruntime-web';
245
247
@@ -262,55 +264,26 @@ Below is a simple example with converting to ONNX then inferencing without postp
262
264
runInference();
263
265
264
266
265
-
Export to tensorflowjs
266
-
----------------------
267
+
Export to TensorFlow.js
268
+
-----------------------
267
269
268
270
.. warning::
269
271
270
-
As of writing this (November 2025), (https://github.com/PINTO0309/onnx2tf) does not support tensorflow js. Thus, (https://github.com/tensorflow/tfjs-converter) is used. This is not currently maintained and requires old opsets/tf versions.
271
-
272
+
As of November 2025, `onnx2tf <https://github.com/PINTO0309/onnx2tf>`_ does not support TensorFlow.js. Therefore, `tfjs-converter <https://github.com/tensorflow/tfjs-converter>`_ is used instead. However, tfjs-converter is not currently maintained and requires older opsets and TensorFlow versions.
272
273
273
-
In order for this to work, you must convert (SB3 => ONNX => Tensorflow => Tensorflowjs)
274
274
275
-
The opset version needs to be changed for the conversion. Please refer to the code above for more stable usage with a higer opset.
275
+
In order for this to work, you have to do multiple conversions: SB3 => ONNX => TensorFlow => TensorFlow.js.
276
276
277
-
The following is a simple example that showcases the full conversion + inference
277
+
The opset version needs to be changed for the conversion (``opset_version=14`` is currently required). Please refer to the code above for more stable usage with a higher opset.
278
278
279
-
.. code-block:: python
280
-
281
-
import torch as th
282
-
from stable_baselines3 importSAC
279
+
The following is a simple example that showcases the full conversion + inference.
0 commit comments