Skip to content

@non_differentiable rand #262

@nmheim

Description

@nmheim

Really happy that ChainRules now has a @non_differentiable macro! Unfortunately it includes all rand methods, which is a bit too restrictive... there was a similar discussion about this in FluxML/Zygote.jl#234 .

MWE:

using Random
using Zygote

struct Normal
    μ
    σ
end

Random.rand(d::Normal) = randn()*d.σ + d.μ
f(a,b) = rand(Normal(a,b))
gs = Zygote.gradient(f,2,2) # returns (nothing,nothing) with ChainRules > 0.7.15

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