# Training Neural SDEs with Mutating Arrays

**URL:** <https://discourse.julialang.org/t/training-neural-sdes-with-mutating-arrays/91877>\
**Category:** Machine Learning\
**Created:** [December 19, 2022, 11:57pm UTC](https://discourse.julialang.org/t/training-neural-sdes-with-mutating-arrays/91877 "2022-12-19T23:57:48Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![ToucheSir](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/touchesir/32/14411_2.png) [@ToucheSir](https://discourse.julialang.org/u/ToucheSir)\
**Post date:** [December 20, 2022, 12:16am UTC](https://discourse.julialang.org/t/training-neural-sdes-with-mutating-arrays/91877/2 "2022-12-20T00:16:51Z")

</div>

Unfortunately it’s difficult to help without a MWE, see [Please read: make it easier to help you](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757) for more.

One thing to test while you’re working on that MWE: instead of using a loop here and assigning to some array, just use `map` or an array comprehension over the range. It should be just as fast and much more AD-friendly to boot.

> [@ChrisVL1](#):
>
> ```julia
> for i = 1:length(K)
> NSDE_call[i] = exp(-r*tspan[2]).*mean(maximum([terminal_values .- K[i] zeros(size(terminal_values))], dims = 2))
> end 
> 
> ```

---

_[View the full topic](https://discourse.julialang.org/t/training-neural-sdes-with-mutating-arrays/91877)._
