Skip to content

Commit ab24e8e

Browse files
add warning for map and broadcast
1 parent 890f6f6 commit ab24e8e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

docs/src/models/recurrence.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,20 @@ julia> [m(x[i]) for i = 1:3]
108108
[-0.34613007, -0.54565114]
109109
```
110110

111+
!!! warning "Use of map and broadcast"
112+
Mapping and broadcasting operations with stateful layers such as the one we are considering are discouraged,
113+
since the julia language doesn't guarantee a specific execution order.
114+
Therefore, avoid
115+
```julia
116+
y = m.(x)
117+
# or
118+
y = map(m, x)
119+
```
120+
and use explicit loops
121+
```julia
122+
y = [m(x) for x in x]
123+
```
124+
111125
If for some reason one wants to exclude the first step of the RNN chain for the computation of the loss, that can be handled with:
112126

113127
```julia

0 commit comments

Comments
 (0)