Skip to content

Commit

Permalink
less-rigorous epsilon for tensoropt
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Jan 2, 2022
1 parent 2b2cfcb commit 3907ea3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions t/1.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ use PDL::Opt::NonLinear;
use Test::More;

sub approx_ok {
my($got,$expected,$label) = @_;
if (PDL::abs($got-$expected)->max < 0.0001) {
my($got,$expected,$eps,$label) = @_;
die "No eps" if !$eps or !$label;
if (PDL::abs($got-$expected)->max < $eps) {
pass $label;
} else {
fail $label;
Expand Down Expand Up @@ -41,7 +42,7 @@ tensoropt($fx, $gx, $hx, $x,
ones(5),0.5,$xtol,$gtol,2,6,
\&min_func, \&grad_func, \&hess_func);

approx_ok $x,$res,'tensoropt';
approx_ok $x,$res,0.001,'tensoropt';

$x = random(5);
$gx = rosen_grad($x);
Expand All @@ -67,6 +68,6 @@ sub fg_func{
}
lbfgs($fx, $gx, $x, $diag, $diagco, $m, $maxit, $maxfc, $eps, $xtol, $gtol,
$print,$info,\&fg_func,\&fdiag);
approx_ok $x,$res,'lbfgs';
approx_ok $x,$res,0.0001,'lbfgs';

done_testing;

0 comments on commit 3907ea3

Please sign in to comment.