Skip to content
Snippets Groups Projects

WIP: Throw exception if curvature is not implemented for RelaxedNewton

Closed Philipp Arras requested to merge exceptionInRelaxedNewton into nifty2go
1 file
+ 9
1
Compare changes
  • Side-by-side
  • Inline
@@ -18,6 +18,7 @@
@@ -18,6 +18,7 @@
from .descent_minimizer import DescentMinimizer
from .descent_minimizer import DescentMinimizer
from .line_search_strong_wolfe import LineSearchStrongWolfe
from .line_search_strong_wolfe import LineSearchStrongWolfe
 
import sys
class RelaxedNewton(DescentMinimizer):
class RelaxedNewton(DescentMinimizer):
@@ -47,4 +48,11 @@ class RelaxedNewton(DescentMinimizer):
@@ -47,4 +48,11 @@ class RelaxedNewton(DescentMinimizer):
Returns the descent direction with proposed step length. In a
Returns the descent direction with proposed step length. In a
quadratic potential this corresponds to the optimal step.
quadratic potential this corresponds to the optimal step.
"""
"""
return -energy.curvature.inverse_times(energy.gradient)
try:
 
curv = energy.curvature
 
except NotImplementedError:
 
print('Error in Relaxed Newton: Curvature is not implemented.')
 
print('Implement curvature or use minimization procedure which uses only the gradient for minimization.')
 
sys.exit()
 
 
return -curv.inverse_times(energy.gradient)
Loading