# Error: type Array has no field data

**URL:** <https://discourse.julialang.org/t/error-type-array-has-no-field-data/35389>\
**Category:** New to Julia\
**Created:** [March 2, 2020, 8:44am UTC](https://discourse.julialang.org/t/error-type-array-has-no-field-data/35389 "2020-03-02T08:44:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eldho.Ashna](https://avatars.discourse-cdn.com/v4/letter/e/bc8723/32.png) [@Eldho.Ashna](https://discourse.julialang.org/u/Eldho.Ashna)\
**Post date:** [March 2, 2020, 8:44am UTC](https://discourse.julialang.org/t/error-type-array-has-no-field-data/35389/1 "2020-03-02T08:44:43Z")

</div>

Hi everyone.

I was doing the course on Flux.jl by JuliaAcademy. When I run the following code,

```julia
using Plots
plot()

contour!(0:0.01:1, 0:0.01:1, (x,y)->model([x,y]).data[1], levels=[0.5, 0.51], color = cgrad([:blue, :blue]))
contour!(0:0.01:1, 0:0.01:1, (x,y)->model([x,y]).data[2], levels=[0.5,0.51], color = cgrad([:green, :green]))
contour!(0:0.01:1, 0:0.01:1, (x,y)->model([x,y]).data[3], levels=[0.5,0.51], color = cgrad([:red, :red]))

scatter!(first.(x_apples), last.(x_apples), m=:cross, label="apples", color = :blue)
scatter!(first.(x_bananas), last.(x_bananas), m=:circle, label="bananas", color = :green)
scatter!(first.(x_grapes), last.(x_grapes), m=:square, label="grapes", color = :red)

```

I’m getting the following error:

```julia
type Array has no field data

Stacktrace:
 [1] getproperty(::Array{Float32,1}, ::Symbol) at ./Base.jl:20
 [2] (::var"#23#24")(::Float64, ::Float64) at ./In[46]:4
 [3] Surface(::var"#23#24", ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}) at /home/g2-test/.julia/packages/Plots/CFRKM/src/components.jl:660
 [4] macro expansion at /home/g2-test/.julia/packages/Plots/CFRKM/src/series.jl:467 [inlined]
 [5] apply_recipe(::Dict{Symbol,Any}, ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::Function) at /home/g2-test/.julia/packages/RecipesBase/G4s6f/src/RecipesBase.jl:279
 [6] _process_userrecipes(::Plots.Plot{Plots.GRBackend}, ::Dict{Symbol,Any}, ::Tuple{StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},var"#23#24"}) at /home/g2-test/.julia/packages/Plots/CFRKM/src/pipeline.jl:85
 [7] _plot!(::Plots.Plot{Plots.GRBackend}, ::Dict{Symbol,Any}, ::Tuple{StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},var"#23#24"}) at /home/g2-test/.julia/packages/Plots/CFRKM/src/plot.jl:178
 [8] #plot!#143(::Base.Iterators.Pairs{Symbol,Any,Tuple{Symbol,Symbol,Symbol},NamedTuple{(:levels, :color, :seriestype),Tuple{Array{Float64,1},ColorGradient,Symbol}}}, ::typeof(plot!), ::Plots.Plot{Plots.GRBackend}, ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::Vararg{Any,N} where N) at /home/g2-test/.julia/packages/Plots/CFRKM/src/plot.jl:158
 [9] (::RecipesBase.var"#kw##plot!")(::NamedTuple{(:levels, :color, :seriestype),Tuple{Array{Float64,1},ColorGradient,Symbol}}, ::typeof(plot!), ::Plots.Plot{Plots.GRBackend}, ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::Vararg{Any,N} where N) at ./none:0
 [10] #plot!#142(::Base.Iterators.Pairs{Symbol,Any,Tuple{Symbol,Symbol,Symbol},NamedTuple{(:levels, :color, :seriestype),Tuple{Array{Float64,1},ColorGradient,Symbol}}}, ::typeof(plot!), ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::Vararg{Any,N} where N) at /home/g2-test/.julia/packages/Plots/CFRKM/src/plot.jl:150
 [11] (::RecipesBase.var"#kw##plot!")(::NamedTuple{(:levels, :color, :seriestype),Tuple{Array{Float64,1},ColorGradient,Symbol}}, ::typeof(plot!), ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::Vararg{Any,N} where N) at ./none:0
 [12] #contour!#438(::Base.Iterators.Pairs{Symbol,Any,Tuple{Symbol,Symbol},NamedTuple{(:levels, :color),Tuple{Array{Float64,1},ColorGradient}}}, ::typeof(contour!), ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::Vararg{Any,N} where N) at /home/g2-test/.julia/packages/RecipesBase/G4s6f/src/RecipesBase.jl:394
 [13] (::Plots.var"#kw##contour!")(::NamedTuple{(:levels, :color),Tuple{Array{Float64,1},ColorGradient}}, ::typeof(contour!), ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::Vararg{Any,N} where N) at ./none:0
 [14] top-level scope at In[46]:3

```

I’m using Flux v0.10.1. This error is because of the version change. I think that `contour!` is making the error.

Can someone help me to solve this.

---

<div class="post-metadata">

**Author:** ![DrChainsaw](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/drchainsaw/32/8497_2.png) [@DrChainsaw](https://discourse.julialang.org/u/DrChainsaw)\
**Post date:** [March 2, 2020, 9:35am UTC](https://discourse.julialang.org/t/error-type-array-has-no-field-data/35389/2 "2020-03-02T09:35:11Z")

</div>

Hi,

Tl;dr: Remove `.data` in the first set of plot calls.

In flux \< 0.10 all arrays are wrapped in a TrackedArray for automatic differentiation. TrackedArray adds some stuff needed to keep track of gradients and the actual array can be accessed by the property `sometrackedarray.data`.

As of 0.10 this has changed and your models output normal arrays and thus you dont need to do anything special to plot them (or access the data in general).

---

<div class="post-metadata">

**Author:** ![Eldho.Ashna](https://avatars.discourse-cdn.com/v4/letter/e/bc8723/32.png) [@Eldho.Ashna](https://discourse.julialang.org/u/Eldho.Ashna)\
**Post date:** [March 2, 2020, 10:03am UTC](https://discourse.julialang.org/t/error-type-array-has-no-field-data/35389/3 "2020-03-02T10:03:52Z")

</div>

When I remove `.data`, I’m getting this error:

```julia
MethodError: Cannot `convert` an object of type Array{Float32,1} to an object of type Float64
Closest candidates are:
  convert(::Type{Float64}, !Matched::LLVM.ConstantFP) at /home/g2-test/.julia/packages/LLVM/DAnFH/src/core/value/constant.jl:85
  convert(::Type{T}, !Matched::T) where T<:Number at number.jl:6
  convert(::Type{T}, !Matched::Number) where T<:Number at number.jl:7
  ...

Stacktrace:
 [1] setindex!(::Array{Float64,2}, ::Array{Float32,1}, ::Int64) at ./array.jl:782
 [2] Surface(::var"#25#26", ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}) at /home/g2-test/.julia/packages/Plots/CFRKM/src/components.jl:660
 [3] macro expansion at /home/g2-test/.julia/packages/Plots/CFRKM/src/series.jl:467 [inlined]
 [4] apply_recipe(::Dict{Symbol,Any}, ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::Function) at /home/g2-test/.julia/packages/RecipesBase/G4s6f/src/RecipesBase.jl:279
 [5] _process_userrecipes(::Plots.Plot{Plots.GRBackend}, ::Dict{Symbol,Any}, ::Tuple{StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},var"#25#26"}) at /home/g2-test/.julia/packages/Plots/CFRKM/src/pipeline.jl:85
 [6] _plot!(::Plots.Plot{Plots.GRBackend}, ::Dict{Symbol,Any}, ::Tuple{StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},var"#25#26"}) at /home/g2-test/.julia/packages/Plots/CFRKM/src/plot.jl:178
 [7] #plot!#143(::Base.Iterators.Pairs{Symbol,Any,Tuple{Symbol,Symbol,Symbol},NamedTuple{(:levels, :color, :seriestype),Tuple{Array{Float64,1},ColorGradient,Symbol}}}, ::typeof(plot!), ::Plots.Plot{Plots.GRBackend}, ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::Vararg{Any,N} where N) at /home/g2-test/.julia/packages/Plots/CFRKM/src/plot.jl:158
 [8] (::RecipesBase.var"#kw##plot!")(::NamedTuple{(:levels, :color, :seriestype),Tuple{Array{Float64,1},ColorGradient,Symbol}}, ::typeof(plot!), ::Plots.Plot{Plots.GRBackend}, ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::Vararg{Any,N} where N) at ./none:0
 [9] #plot!#142(::Base.Iterators.Pairs{Symbol,Any,Tuple{Symbol,Symbol,Symbol},NamedTuple{(:levels, :color, :seriestype),Tuple{Array{Float64,1},ColorGradient,Symbol}}}, ::typeof(plot!), ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::Vararg{Any,N} where N) at /home/g2-test/.julia/packages/Plots/CFRKM/src/plot.jl:150
 [10] (::RecipesBase.var"#kw##plot!")(::NamedTuple{(:levels, :color, :seriestype),Tuple{Array{Float64,1},ColorGradient,Symbol}}, ::typeof(plot!), ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::Vararg{Any,N} where N) at ./none:0
 [11] #contour!#438(::Base.Iterators.Pairs{Symbol,Any,Tuple{Symbol,Symbol},NamedTuple{(:levels, :color),Tuple{Array{Float64,1},ColorGradient}}}, ::typeof(contour!), ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::Vararg{Any,N} where N) at /home/g2-test/.julia/packages/RecipesBase/G4s6f/src/RecipesBase.jl:394
 [12] (::Plots.var"#kw##contour!")(::NamedTuple{(:levels, :color),Tuple{Array{Float64,1},ColorGradient}}, ::typeof(contour!), ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::Vararg{Any,N} where N) at ./none:0
 [13] top-level scope at In[47]:3

```

---

<div class="post-metadata">

**Author:** ![DrChainsaw](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/drchainsaw/32/8497_2.png) [@DrChainsaw](https://discourse.julialang.org/u/DrChainsaw)\
**Post date:** [March 2, 2020, 10:59am UTC](https://discourse.julialang.org/t/error-type-array-has-no-field-data/35389/4 "2020-03-02T10:59:21Z")

</div>

Did you by any chance also remove the brackets?
