Flux.jl: Document how to get from TrackedFoo to Foo

Created on 14 Sep 2018  路  1Comment  路  Source: FluxML/Flux.jl

See each this conversation.

<@JonasIsensee>
Hey there,
I just started playing with Flux and ML in general for the first time.

How can I plot predictions?
scatter(y, predict.(x))
gives me the following
MethodError: no method matching Float64(::Flux.Tracker.TrackedReal{Float64}

<@JonasIsensee>
This seems to work
yhat = map(x -> x[1].data, predict.(x))

I can never remember how to do it.
And I always endup looking around the code base for:

https://github.com/FluxML/Flux.jl/blob/b93d4763cccb5736bb7b4fc5740bef2b19b46426/src/tracker/scalar.jl#L8

related:

Is data(xs::AbstractArray{<:TrackedReal}) = data.(xs) defined?

Possibly it should be, if not
so that
AbstractArray{<:TrackedReal} and TrackedArray act the same

Most helpful comment

We can mention this in the docs if we aren't already. Calling Tracker.data(x) seems like it's about as simple as this is going to get though.

The AbstractArray{<:TrackedReal} thing is tricky, especially because you don't want AbstractArray{Any} to behave differently. But I don't think it'd hurt to just always broadcast over any abstractarray.

>All comments

We can mention this in the docs if we aren't already. Calling Tracker.data(x) seems like it's about as simple as this is going to get though.

The AbstractArray{<:TrackedReal} thing is tricky, especially because you don't want AbstractArray{Any} to behave differently. But I don't think it'd hurt to just always broadcast over any abstractarray.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

davidljung picture davidljung  路  4Comments

ageron picture ageron  路  4Comments

tejank10 picture tejank10  路  6Comments

Sheemon7 picture Sheemon7  路  3Comments

MikeInnes picture MikeInnes  路  4Comments