https://github.com/joshdk/pygradesc
  
  
    A simple to use gradient descent library written in python 
    https://github.com/joshdk/pygradesc
  
        Last synced: 8 months ago 
        JSON representation
    
A simple to use gradient descent library written in python
- Host: GitHub
- URL: https://github.com/joshdk/pygradesc
- Owner: joshdk
- License: other
- Created: 2012-10-13T18:05:29.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2012-10-13T22:59:04.000Z (about 13 years ago)
- Last Synced: 2025-01-16T13:17:33.731Z (10 months ago)
- Language: Python
- Size: 383 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
- 
            Metadata Files:
            - Readme: README.md
- License: LICENSE.md
 
Awesome Lists containing this project
README
          pygradesc
=========
An n-dimensional gradient descent algorithm
Example
-------

Usage
-----
### Importing
```python
import pygradesc as gd
````
### Creating functions
```python
# Functions (or lambdas) take the form f(a1, a2, ..., an) -> an+1
# Constructor a 2D function f(x) -> y
fx = lambda x: x*x
# Constructor a 3D function f(x,y) -> z
fxy = lambda x, y: (x-1)**2+(y-2)**2
# Constructor a 4D function f(x,y,z) -> d
fxyz = lambda x, y, z: x**2+5*y+z
```
### Running
```python
# Starting point
start = [-2, -6]
# Delta size (how far should we move towards our goal)
delta = 0.25
# Number of steps
steps = 1000
# Get a list of points for each step in the algorithm
points = gd.minimize(fxy, start, delta, steps)
```
### Printing
```python
print(points)
# points[0]   -> [-2.0,    -6.0,     73.0      ]
# points[1]   -> [-1.83.., -5.82..,  69.21..   ]
# ..
# points[999] -> [ 0.99..,  1.99..,  2.47..e-31]
```
### Plotting
=(x-1)^2+(y-2)^2")
Dependencies
------------
*   [Python2](http://www.python.org/download/releases/2.7.3/)
*   [NumPy](http://numpy.scipy.org/)