Skip to content

Nested ProductManifolds #79

@lukas-weber

Description

@lukas-weber

The current implementation of the riemannian_gradient does not seem to handle nested ProductManifolds.

using Manifolds
using ManifoldDiff
using Zygote
using ADTypes

M = ProductManifold(ProductManifold(Euclidean(1), Euclidean(1)), Euclidean(1))
f(x) = sum(x)^2

ManifoldDiff.gradient(M, f, rand(M), RiemannianProjectionBackend(AutoZygote()))
The function `submanifold_components` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  submanifold_components(::ArrayPartition)
   @ ManifoldsBaseRecursiveArrayToolsExt /home/lweber/.julia/packages/ManifoldsBase/nqeOA/ext/ManifoldsBaseRecursiveArrayToolsExt/ProductManifoldRecursiveArrayToolsExt.jl:330
  submanifold_components(::ProductGroup, ::Identity{ProductOperation})
   @ Manifolds /home/lweber/.julia/packages/Manifolds/mH6Su/src/groups/product_group.jl:124
  submanifold_components(::GroupManifold{𝔽, MT, O}, ::Identity{O}) where {MT<:ProductManifold, 𝔽, O<:AbstractGroupOperation}
   @ Manifolds /home/lweber/.julia/packages/Manifolds/mH6Su/src/groups/product_group.jl:116
  ...

Stacktrace:
  [1] submanifold_components
    @ /home/lweber/.julia/packages/ManifoldsBase/nqeOA/src/ProductManifold.jl:1291 [inlined]
  [2] project!(M::ProductManifold{ℝ, Tuple{Euclidean{ManifoldsBase.TypeParameter{Tuple{1}}, ℝ}, Euclidean{ManifoldsBase.TypeParameter{Tuple{1}}, ℝ}}}, Y::ArrayPartition{Float64, Tuple{Vector{Float64}, Vector{Float64}}}, p::ArrayPartition{Float64, Tuple{Vector{Float64}, Vector{Float64}}}, X::Vector{Float64})
    @ ManifoldsBase /home/lweber/.julia/packages/ManifoldsBase/nqeOA/src/ProductManifold.jl:815
  [3] riemannian_gradient!(M::ProductManifold{ℝ, Tuple{Euclidean{ManifoldsBase.TypeParameter{Tuple{1}}, ℝ}, Euclidean{ManifoldsBase.TypeParameter{Tuple{1}}, ℝ}}}, X::ArrayPartition{Float64, Tuple{Vector{Float64}, Vector{Float64}}}, p::ArrayPartition{Float64, Tuple{Vector{Float64}, Vector{Float64}}}, Y::Vector{Float64}; embedding_metric::EuclideanMetric)
    @ ManifoldDiff /home/lweber/.julia/packages/ManifoldDiff/vWWFF/src/riemannian_diff.jl:325
  [4] riemannian_gradient(M::ProductManifold{ℝ, Tuple{Euclidean{ManifoldsBase.TypeParameter{Tuple{1}}, ℝ}, Euclidean{ManifoldsBase.TypeParameter{Tuple{1}}, ℝ}}}, p::ArrayPartition{Float64, Tuple{Vector{Float64}, Vector{Float64}}}, Y::Vector{Float64}; embedding_metric::EuclideanMetric)
    @ ManifoldDiff /home/lweber/.julia/packages/ManifoldDiff/vWWFF/src/riemannian_diff.jl:314
  [5] riemannian_gradient(M::ProductManifold{ℝ, Tuple{Euclidean{ManifoldsBase.TypeParameter{Tuple{1}}, ℝ}, Euclidean{ManifoldsBase.TypeParameter{Tuple{1}}, ℝ}}}, p::ArrayPartition{Float64, Tuple{Vector{Float64}, Vector{Float64}}}, Y::Vector{Float64})
    @ ManifoldDiff /home/lweber/.julia/packages/ManifoldDiff/vWWFF/src/riemannian_diff.jl:307
  [6] map
    @ ./tuple.jl:406 [inlined]
  [7] riemannian_gradient(M::ProductManifold{ℝ, Tuple{ProductManifold{ℝ, Tuple{Euclidean{ManifoldsBase.TypeParameter{Tuple{1}}, ℝ}, Euclidean{ManifoldsBase.TypeParameter{Tuple{1}}, ℝ}}}, Euclidean{ManifoldsBase.TypeParameter{Tuple{1}}, ℝ}}}, p::ArrayPartition{Float64, Tuple{ArrayPartition{Float64, Tuple{Vector{Float64}, Vector{Float64}}}, Vector{Float64}}}, X::ArrayPartition{Float64, Tuple{Vector{Float64}, Vector{Float64}}})
    @ ManifoldsRecursiveArrayToolsExt /home/lweber/.julia/packages/Manifolds/mH6Su/ext/ManifoldsRecursiveArrayToolsExt/ProductManifoldRAT.jl:45
  [8] gradient(M::ProductManifold{ℝ, Tuple{ProductManifold{ℝ, Tuple{Euclidean{ManifoldsBase.TypeParameter{Tuple{1}}, ℝ}, Euclidean{ManifoldsBase.TypeParameter{Tuple{1}}, ℝ}}}, Euclidean{ManifoldsBase.TypeParameter{Tuple{1}}, ℝ}}}, f::Function, p::ArrayPartition{Float64, Tuple{ArrayPartition{Float64, Tuple{Vector{Float64}, Vector{Float64}}}, Vector{Float64}}}, backend::RiemannianProjectionBackend{AutoZygote}; kwargs::@Kwargs{})
    @ ManifoldDiff /home/lweber/.julia/packages/ManifoldDiff/vWWFF/src/riemannian_diff.jl:207
  [9] gradient(M::ProductManifold{ℝ, Tuple{ProductManifold{ℝ, Tuple{Euclidean{ManifoldsBase.TypeParameter{Tuple{1}}, ℝ}, Euclidean{ManifoldsBase.TypeParameter{Tuple{1}}, ℝ}}}, Euclidean{ManifoldsBase.TypeParameter{Tuple{1}}, ℝ}}}, f::Function, p::ArrayPartition{Float64, Tuple{ArrayPartition{Float64, Tuple{Vector{Float64}, Vector{Float64}}}, Vector{Float64}}}, backend::RiemannianProjectionBackend{AutoZygote})
    @ ManifoldDiff /home/lweber/.julia/packages/ManifoldDiff/vWWFF/src/riemannian_diff.jl:199
 [10] top-level scope
    @ REPL[117]:1

In particular, in ext/ManifoldsRecursiveArrayToolsExt/ProductManifoldRAT.jl:45, riemann_diff maps over M.manifolds, submanifold_components(p) and submanifold_components(X), but only the latter two are recursive.

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