Skip to content
This repository has been archived by the owner on Mar 30, 2022. It is now read-only.

Map isn't differentiable but compiler diagnosis is gone #554

Open
porterchild opened this issue Nov 4, 2020 · 1 comment
Open

Map isn't differentiable but compiler diagnosis is gone #554

porterchild opened this issue Nov 4, 2020 · 1 comment
Assignees

Comments

@porterchild
Copy link
Contributor

porterchild commented Nov 4, 2020

I though Dan had talked about .map becoming differentiable recently in an open design meeting, but there is still an issue as of the 9/16 Xcode snapshot. The compiler lets this through, but it produces an incorrect derivative:

func mappy(a: [Double]) -> Double{
    let twice = a.map{$0 * 2}                   //compiles, but resulting gradient is incorrect (empty list)
//    let twice = a.differentiableMap{$0 * 2}   //works, gradient is [2.0, 2.0, 2.0]
    
    return twice.differentiableReduce(0, +)
}

print(valueWithGradient(at: [1,2,3], in: mappy))
@porterchild
Copy link
Contributor Author

Also reproducible with Xcode release v0.12-rc2

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants