steepest_descent.py 380 Bytes
Newer Older
1
2
3
4
5
6
# -*- coding: utf-8 -*-

from .quasi_newton_minimizer import QuasiNewtonMinimizer


class SteepestDescent(QuasiNewtonMinimizer):
theos's avatar
theos committed
7
    def _get_descend_direction(self, x, gradient):
8
9
10
11
12
13
        descend_direction = gradient
        norm = descend_direction.norm()
        if norm != 1:
            return descend_direction / -norm
        else:
            return descend_direction * -1