JuliaDiff / JuliaDiff/ReverseDiff.jl

Define `typemin` for tracked reals.

Open
#225 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
393
Forks
60
Avg merge
18h 24m
Merged PRs (30d)
8

Description

In NNlib.maxpool we encounter typemin to initialize the prospective maximum value.
typemin is not implemented for ReverseDiff.TrackedReal
This definition seems to work (it allows for taking derivatives):

Base.typemin(tr::Type{<:T}) where{V, D, O, T<:ReverseDiff.TrackedReal{V, D, O}} = T(typemin(V))

but I do not really know if that is sensible.

MWE for failure:

import NNlib: maxpool
import ReverseDiff as RD
x = reshape(Float32[ 1 2; 3 4 ], (2,2,1,1))
RD.gradient(_x -> only(maxpool(_x,(2,2))), x)[:,:,1,1] # == [0 0; 0 1]

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the NNlib.maxpool MWE with ReverseDiff.TrackedReal, then inspect how Base.typemin is handled for tracked values. Done means maxpool differentiates successfully with a sensible typemin definition and the behavior is covered by an appropriate test.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
machine-learning
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.