Skip to content

Commit

Permalink
Doing some name change stuff to QuasiNewton.
Browse files Browse the repository at this point in the history
  • Loading branch information
RS-Coop committed Jul 19, 2024
1 parent e6e36a8 commit 0453596
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 25 deletions.
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ authors:
- family-names: "Simpson"
given-names: "Cooper"
orcid: "https://orcid.org/0000-0003-3922-2797"
title: "RandNLA.jl"
title: "QuasiNewton.jl"
version: 0.0.0
doi: 10.1/2
date-released: 2022
url: "https://github.com/rs-coop/SFN.jl"
note: "Julia implementation of Saddle-Free Newton type methods"
note: "Julia implementation of Newton-type optimization methods"
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name = "SFN"
name = "QuasiNewton"
uuid = "0c568c97-1dfb-438d-a4b2-d21d63173d9f"
authors = ["Cooper Simpson"]
version = "0.1.0"
Expand Down
22 changes: 7 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
# SFN.jl
# QuasiNewton

## Saddle-Free Newton
A collection of Newton-type optimization algorithms.

### Authors: [Cooper Simpson](https://rs-coop.github.io/)

A Julia implementation of the R-SFN algorithm: a second-order method for unconstrained non-convex optimization. To that end, we consider a problem of the following form
$$\min_{\mathbf{x}\in \mathbb{R}^n}f(\mathbf{x})$$
where $f:\mathbb{R}^n\to\mathbb{R}$ is a twice continuously differentiable function. Each iteration applies an update of the following form:
$$\mathbf{x}^{(k+1)} = \mathbf{x}^{(k)}-\Big(\big(\nabla^2f(\mathbf{x}^{(k)})\big)^2+\lambda^{(k)}\mathbf{I}\Big)^{-1/2} \nabla f(\mathbf{x}^{(k)})$$
where the regularization term is $\lambda^{(k)}\propto||\nabla^2f(\mathbf{x}^{(k)})||$. The matrix inverse square root is computed via a quadrature approximation of the following integral:
$$\mathbf{A}^{-1/2}=\frac{2}{\pi}\int_{0}^{\infty}\big(t^2\mathbf{I}+\mathbf{A}\big)^{-1}\ dt$$
where $\mathbf{A}\in\mathbb{R}^{n\times n}$ has strictly positive spectrum, i.e $\sigma(\mathbf{A})\subset\mathbb{R}_{+ +}$.

## License & Citation
All source code is made available under an MIT license. You can freely use and modify the code, without warranty, so long as you provide attribution to the authors. See `LICENSE` for the full text.

Expand All @@ -20,10 +12,10 @@ This repository can be cited using the GitHub action in the sidebar, or using th
## Installation
This package can be installed just like any other Julia package. From the terminal, after starting the Julia REPL, run the following:
```julia
julia> ]
pkg> add RSFN
using Pkg
Pkg.add("QuasiNewton")
```
This will install R-SFN and its direct dependencies, but in order to use the package you must install one of the following sets of packages for automatic differentiation (AD):
This will install the package and its direct dependencies, but in order to use the package you must install one of the following sets of packages for automatic differentiation (AD):
- `Enzyme.jl`
- `ReverseDiff.jl` and `ForwardDiff.jl`
- `Zygote.jl` and `ForwardDiff.jl`
Expand All @@ -32,13 +24,13 @@ This will install R-SFN and its direct dependencies, but in order to use the pac
To test the package, run the following command in the REPL:
```julia
using Pkg
Pkg.test(test_args=[<specific tests>])
Pkg.test(test_args=["optional specific tests"])
```

## Usage
Load the package as usual:
```julia
using RSFN
using QuasiNewton
```
which will export the struct `RSFNOptimizer` and the `minimize!` function. Then load your AD packages, which will export a subtype of `HvpOperator`. Say you load Enzyme:
```julia
Expand Down
2 changes: 1 addition & 1 deletion src/SFN.jl → src/QuasiNewton.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Author: Cooper Simpson
CubicNewton optimization package.
=#
module SFN
module QuasiNewton

#=
Setup
Expand Down
2 changes: 1 addition & 1 deletion src/hvp/EnzymeHvpExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Author: Cooper Simpson
Enzyme AD.
=#

using SFN: HvpOperator
using QuasiNewton: HvpOperator
using Enzyme

export ehvp, ehvp!, EHvpOperator
Expand Down
2 changes: 1 addition & 1 deletion src/hvp/LinopHvpExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Author: Cooper Simpson
Wrapper around LinearOperator.jl based Hessian-vector product, no AD.
=#

using SFN: HvpOperator
using QuasiNewton: HvpOperator
using LinearOperators: LinearOperator

export LHvpOperator
Expand Down
2 changes: 1 addition & 1 deletion src/hvp/RdiffHvpExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Author: Cooper Simpson
ForwardDiff over ReverseDiff AD.
=#

using SFN: HvpOperator
using QuasiNewton: HvpOperator
using ReverseDiff: AbstractTape, GradientTape, compile, gradient!, gradient
using ForwardDiff: Partials, partials, Dual, Tag

Expand Down
2 changes: 1 addition & 1 deletion src/hvp/ZygoteHvpExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Author: Cooper Simpson
ForwardDiff over Zygote AD, compatible with Flux.
=#

using SFN: HvpOperator
using QuasiNewton: HvpOperator
using Zygote: pullback
using ForwardDiff: partials, Dual

Expand Down
2 changes: 1 addition & 1 deletion test/hvp_bench.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Author: Cooper Simpson
Autodiff Hvp benchmarks.
=#

using SFN
using QuasiNewton
using BenchmarkTools
using Enzyme: hvp!

Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Author: Cooper Simpson
SFN tests, specific tests runnable with Pkg.test(test_args=["target"])
=#
using Test
using SFN
using QuasiNewton

if isempty(ARGS) || "all" in ARGS
run_all = true
Expand Down

0 comments on commit 0453596

Please sign in to comment.