Skip to content

Incorrect gradient type.  #235

Closed
Closed
@YichengDWu

Description

@YichengDWu

In the following code, shouldn't grad be of the same type as x?

julia> using ComponentArrays, Zygote

julia> ps = ComponentArray(weight=rand(3,3))
ComponentVector{Float64}(weight = [0.8258011674811379 0.44981527211623784 0.5507199474580698; 0.28250960116858315 0.42697555461561054 0.22836834345488244; 0.9092739196971233 0.6566982028049392 0.14458718099508994])

julia> grad = Zygote.gradient(x->sum(x.weight), ps)[1]
ComponentVector{Float64, ComponentVector{Float64, Vector{Float64}, Tuple{Axis{(weight = ViewAxis(1:9, ShapedAxis((3, 3), NamedTuple())),)}}}, Tuple{Axis{(weight = ViewAxis(1:9, ShapedAxis((3, 3), NamedTuple())),)}}}(weight = [1.0 1.0 1.0; 1.0 1.0 1.0; 1.0 1.0 1.0])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions