Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spectral_mixture_kernel constructor is not type-stable #490

Closed
theogf opened this issue Nov 29, 2022 · 1 comment · Fixed by #501
Closed

spectral_mixture_kernel constructor is not type-stable #490

theogf opened this issue Nov 29, 2022 · 1 comment · Fixed by #501

Comments

@theogf
Copy link
Member

theogf commented Nov 29, 2022

Here is a MWE:

julia> v = ones(2);
julia> rbf = rand(2);
julia> cos = rand(2);
julia> spectral_mixture_kernel(v, rbf', cos')
Sum of 2 kernels:
        Product of 2 kernels:
                        Squared Exponential Kernel (metric = Distances.Euclidean(0.0))
                                        - Linear transform (size(A) = (1, 1))
                                        - σ² = 1.0
                        Cosine Kernel (metric = Distances.Euclidean(0.0))
                                        - Linear transform (size(A) = (1, 1))
        Product of 2 kernels:
                        Squared Exponential Kernel (metric = Distances.Euclidean(0.0))
                                        - Linear transform (size(A) = (1, 1))
                                        - σ² = 1.0
                        Cosine Kernel (metric = Distances.Euclidean(0.0))
                                        - Linear transform (size(A) = (1, 1))

julia> @inferred spectral_mixture_kernel(v, rbf', cos')
ERROR: return type KernelSum{Tuple{KernelProduct{Tuple{ScaledKernel{TransformedKernel{SqExponentialKernel{Distances.Euclidean}, LinearTransform{LinearAlgebra.Adjoint{Float64, SubArray{Float64, 1, LinearAlgebra.Adjoint{Float64, Vector{Float64}}, Tuple{Base.Slice{Base.OneTo{Int64}}, Int64}, true}}}}, Float64}, TransformedKernel{CosineKernel{Distances.Euclidean}, LinearTransform{LinearAlgebra.Adjoint{Float64, SubArray{Float64, 1, LinearAlgebra.Adjoint{Float64, Vector{Float64}}, Tuple{Base.Slice{Base.OneTo{Int64}}, Int64}, true}}}}}}, KernelProduct{Tuple{ScaledKernel{TransformedKernel{SqExponentialKernel{Distances.Euclidean}, LinearTransform{LinearAlgebra.Adjoint{Float64, SubArray{Float64, 1, LinearAlgebra.Adjoint{Float64, Vector{Float64}}, Tuple{Base.Slice{Base.OneTo{Int64}}, Int64}, true}}}}, Float64}, TransformedKernel{CosineKernel{Distances.Euclidean}, LinearTransform{LinearAlgebra.Adjoint{Float64, SubArray{Float64, 1, LinearAlgebra.Adjoint{Float64, Vector{Float64}}, Tuple{Base.Slice{Base.OneTo{Int64}}, Int64}, true}}}}}}}} does not match inferred return type Any
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:35
 [2] top-level scope
   @ REPL[56]:1
@theogf
Copy link
Member Author

theogf commented Nov 29, 2022

Now that I think about it, it makes sense. There is no way the size of the mixture can be inferred unless we would pass some static vectors or tuples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant