Skip to content

Commit 53987a7

Browse files
authored
Document that set_backend requires re-importing keras. (#21764)
Both in the example and the documentation.
1 parent a4c9850 commit 53987a7

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

keras/src/utils/backend_utils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,12 @@ def set_backend(backend):
125125
Example:
126126
127127
```python
128+
import keras
129+
128130
keras.config.set_backend("jax")
131+
132+
del keras
133+
import keras
129134
```
130135
131136
⚠️ WARNING ⚠️: Using this function is dangerous and should be done
@@ -138,7 +143,7 @@ def set_backend(backend):
138143
139144
This includes any function or class instance that uses any Keras
140145
functionality. All such code needs to be re-executed after calling
141-
`set_backend()`.
146+
`set_backend()` and re-importing the `keras` module.
142147
"""
143148
os.environ["KERAS_BACKEND"] = backend
144149
# Clear module cache.

0 commit comments

Comments
 (0)