# Using ForwardDiff with Custom Struct

**URL:** <https://discourse.julialang.org/t/using-forwarddiff-with-custom-struct/34894>\
**Category:** General Usage\
**Created:** [February 20, 2020, 9:19am UTC](https://discourse.julialang.org/t/using-forwarddiff-with-custom-struct/34894 "2020-02-20T09:19:37Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![bocc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bocc/32/7546_2.png) [@bocc](https://discourse.julialang.org/u/bocc)\
**Post date:** [February 20, 2020, 10:03am UTC](https://discourse.julialang.org/t/using-forwarddiff-with-custom-struct/34894/2 "2020-02-20T10:03:15Z")

</div>

Does the type assert occur in your code? This prevents ForwardDiff from using dual numbers. In Zygote’s case, it might be a missing gradient definition (see [this discussion](https://discourse.julialang.org/t/zygote-debugging/)) for some data structure. For example, you can’t diff through code using FieldVectors, maybe this is the case for one of your data structures too. You could try replacing your OrderedDicts with ordinary ones.

---

_[View the full topic](https://discourse.julialang.org/t/using-forwarddiff-with-custom-struct/34894)._
