gaurav-arya / StochasticAD.jl

Research package for automatic differentiation of programs containing discrete randomness.
MIT License
198 stars 16 forks source link

Add `ifelse` #47

Open mschauer opened 1 year ago

mschauer commented 1 year ago

Essentially, ifelse(c, x, y) == [x, y][1 + !c]

RickDW commented 7 months ago

Hi, it's been a while since this was posted but I'm curious if there's any update on this. Is this going to be the way to implement stochastically differentiable if statements, or is there eventually going to be a way to use standard if ... end syntax?

gaurav-arya commented 7 months ago

Hey! Although I haven't gotten around to explicitly handling ifelse, there is a more powerful (experimental) StochasticAD.propagate function: see the branching example at https://gaurav-arya.github.io/StochasticAD.jl/stable/devdocs.html#via-StochasticAD.propagate