Skip to content

Commit

Permalink
Clarify numerical gradient signature (mratsim#581)
Browse files Browse the repository at this point in the history
* clarify the signature of `numerical_gradient` for scalars

* update changelog

* push version v0.7.19
  • Loading branch information
Vindaar authored Dec 10, 2022
1 parent 35faf35 commit d4adbbd
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion arraymancer.nimble
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
### Package
version = "0.7.18"
version = "0.7.19"
author = "Mamy André-Ratsimbazafy"
description = "A n-dimensional tensor (ndarray) library"
license = "Apache License 2.0"
Expand Down
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Arraymancer v0.7.x
=====================================================

Arraymancer v0.7.19 Dec. 10 2022
=====================================================

- change the signature of `numerical_gradient` for scalars to
explicitly reject `Tensor` arguments. See discussion in PR #580.

Arraymancer v0.7.18 Dec. 10 2022
=====================================================

Expand Down
2 changes: 1 addition & 1 deletion src/arraymancer/nn_primitives/nnp_numerical_gradient.nim
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import ../tensor

proc numerical_gradient*[T](input: T, f: (proc(x: T): T), h = T(1e-5)): T {.inline.} =
proc numerical_gradient*[T: not Tensor](input: T, f: (proc(x: T): T), h = T(1e-5)): T {.inline.} =
## Compute numerical gradient for any function w.r.t. to an input value,
## useful for gradient checking, recommend using float64 types to assure
## numerical precision. The gradient is calculated as:
Expand Down
2 changes: 1 addition & 1 deletion tests/nn_primitives/test_nnp_convolution.nim
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


import ../../src/arraymancer
import unittest, sugar, math
import unittest, sugar

proc main() =
suite "Convolution 2D":
Expand Down

0 comments on commit d4adbbd

Please sign in to comment.