GradientTester

Class that compares the computed gradient with an empirical gradient based on finite differences. Essential for debugging dynamic programs.

trait Serializable
class Object
trait Matchable
class Any

Value members

Concrete methods

def test[K, T](f: DiffFunction[T], x: T, randFraction: Double, skipZeros: Boolean, epsilon: Double, tolerance: Double, toString: K => String)(implicit view2: T <:< NumericOps[T], view: T <:< Tensor[K, Double], copy: CanCopy[T], canNorm: Impl[T, Double], opSub: Impl2[T, T, T]): T

Tests a gradient by comparing the gradient to the empirically calculated gradient from finite differences, returning those that are bad, logging bad ones on WARN, ok ones on DEBUG, and overall statistics on INFO.

Tests a gradient by comparing the gradient to the empirically calculated gradient from finite differences, returning those that are bad, logging bad ones on WARN, ok ones on DEBUG, and overall statistics on INFO.

Value parameters:
epsilon

Difference to try

f

the function to test

randFraction

what percentage of x's domain to try.

skipZeros

should we skip components of x where the calculated gradient is 0. (Sometimes useful with sparse features. You might want to check that 0's are always 0's though!)

toString

toString function for converting elements of x's domain to a string.

tolerance

How big a relative difference before we start complaining.

x

point to test from

Returns:

differences in each component

def testIndices[T, K](f: DiffFunction[T], x: T, indices: Iterable[K], skipZeros: Boolean, toString: K => String, epsilon: Double, tolerance: Double)(implicit view2: T <:< NumericOps[T], view: T <:< Tensor[K, Double], copy: CanCopy[T], canNorm: Impl[T, Double], opSub: Impl2[T, T, T]): T

Inherited methods

protected def logger: LazyLogger
Inherited from:
SerializableLogging