Docstrings

DifferentiableFlatten.flatten — Function
flatten(x)

Returns a "flattened" representation of x as a vector of real numbers, and a function unflatten that takes a vector of reals of the same length and returns an object of the same type as x. unflatten is the inverse of flatten, so

julia> x = (randn(5), 5.0, (a=5.0, b=randn(2, 3)));
julia> v, unflatten = flatten(x);
julia> x == unflatten(v)
true
DifferentiableFlatten.Unflatten — Type
Unflatten(x, unflatten)

Callable returned by flatten that maps a flattened vector back to an object of the same type (and, for the second element of flatten(x), value) as the original x. It is a subtype of Function and participates in differentiation through its ChainRules rrule.

DifferentiableFlatten.@constructor — Macro
@constructor(T)
@constructor(T, C)

Generates efficient flatten and zygote_flatten methods for the type T, reconstructing objects of type C. Useful for custom structs whose reconstruction should use a different type (for example a parametric type with fixed type parameters), or whose construction requires a custom constructor call. See the usage guide for examples.