Skip to content

@non_differentiable rand #262

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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