https://github.com/deshanadesai/acorns
https://arxiv.org/pdf/2007.05094.pdf An Easy-To-Use Code Generator for Gradients and Hessians
https://github.com/deshanadesai/acorns
Last synced: 6 months ago
JSON representation
https://arxiv.org/pdf/2007.05094.pdf An Easy-To-Use Code Generator for Gradients and Hessians
- Host: GitHub
- URL: https://github.com/deshanadesai/acorns
- Owner: deshanadesai
- License: mit
- Created: 2020-03-19T22:32:50.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-09-22T16:27:07.000Z (over 3 years ago)
- Last Synced: 2023-09-07T08:09:21.883Z (almost 2 years ago)
- Language: Python
- Homepage:
- Size: 191 MB
- Stars: 30
- Watchers: 5
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.txt
Awesome Lists containing this project
README
### Readme
### About acorns
Home: https://github.com/deshanadesai/acorns
Package license: MIT
Feedstock license: BSD 3-Clause
Current Version: 3.0 - Fixes bugs and supports features described in the [user guide](https://github.com/deshanadesai/acorns/blob/master/doc/ACORNS_user_guide.pdf)
Summary: An easy-to-use Code Generator for Gradients and Hessians
ACORNS is an algorithm for automatic differention of algorithms written in a subset of C99 code and its efficient implementation as a Python script.
### Installation
Installing acorns from the conda-forge channel can be achieved by adding conda-forge to your channels with:
`conda config --add channels conda-forge`
Once the conda-forge channel has been enabled, acorns can be installed with:
`conda install acorns`
### Usage
Please refer to the `examples/` directory and the `basic_example.ipynb` for more examples. Here is a basic usage of the package:
```
import acorns
c_function = "int function_test(double a, double p){ \
double energy = a*a*a*a*p+1/(p*p) - 1/p * p/a; \
return 0; \
}"acorns.autodiff(c_function, 'energy', ['a','p'], func = 'function_test', output_filename = 'test_grad_forward',
output_func = 'compute_grad_forward')
```### Examples directory:
1. `c_code_basic.py` - basic examples of forward and reverse, single and double autodifferentiation
2. `c_code_basic_parallel.py` - example of including parallel for loops
3. `c_code_basic_split.py` - example script for splitting derivatives into multiple files
4. `run_sample_c_functions.py` - runs sample functions from the `examples/sample_functions/` directory, includes single and double dimensional array examples
5. For unrolling - example input `examples/unrolled_example.c` and output code `examples/unrolled_example_output.c` along with differentiation of the output code `examples/unrolled_example_fd_output.c` are provided.
### Known problems
- Support for nested loops is limited to two.
- Does not currently support complicated data structures.Please refer to the user guide for further reading: [user guide](https://github.com/deshanadesai/acorns/blob/master/doc/ACORNS_user_guide.pdf)
### Package Contents:***README.rst:***
This README file.
***LICENSE:***
MIT
***setup.py:***
Installation script
***examples/:***
A directory with some examples of using Acorns
***acorns/:***
The acorns module source code.