Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • N NIFTy
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 19
    • Issues 19
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 12
    • Merge requests 12
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • ift
  • NIFTy
  • Issues
  • #126
Closed
Open
Issue created May 16, 2017 by Matevz, Sraml (sraml)@sraml

Trouble with SteepestDescent.

np.random.seed(0)
N_dim = 500

x_space = RGSpace(N_dim)

x = Field(x_space, val=np.random.rand(N_dim))
N = DiagonalOperator(x_space, diagonal = 1.)

class QuadraticPot(Energy):
    def __init__(self, position, N):
        super(QuadraticPot, self).__init__(position)
        self.N = N
        
    def at(self, position):
        return self.__class__(position, N = self.N)


    @property
    def value(self):
        H = 0.5 *self.position.dot(self.N.inverse_times(self.position))
        return H.real

    @property
    def gradient(self):
        g = self.N.inverse_times(self.position)
        return_g = g.copy_empty(dtype=np.float)
        return_g.val = g.val.real
        return return_g
            
    @property
    def curvature(self):
        return self.N



minimizer = SteepestDescent(iteration_limit=1000,convergence_tolerance=1E-4, convergence_level=3)

energy = QuadraticPot(position=x , N=N)
(energy, convergence) = minimizer(energy)

I'm feeding the SteepestDescent method a quadratic function with 0 mean. If you run it, it converges. It needs around 5 iterations to converge but after that it creates a loop and it is trapped inside it until it reaches the 'iteration_limit=1000' . The produced result is still correct.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking