agd.AutomaticDifferentiation
This package implements automatic differentiation (AD) methods, in the following flavors:
- Dense, Sparse, and Reverse (experimental) modes
- First and second order differentiation
- CPU and GPU support, using numpy and cupy. The AD types implement numpy's overloading mechanisms, and one should be able to use them as drop in replacement for numpy arrays in many contexts.
Main submodules:
- Dense : first order, forward AD with dense storage.
- Dense2 : second order, forward AD with dense storage.
- Sparse : first order, forward AD with sparse storage.
- Sparse2 : second order, forward AD with sparse storage.
- Reverse, Reverse2 (experimental) : first and second order, reverse AD.
- Optimization : basic Newton method implemented using AD
Main functions:
- asarray, array: turn a list/tuple of arrays into a larger array.
- is_ad : test whether a variable embeds AD information.
- remove_ad : remove AD information
- simplify_ad : compress the AD information, of Sparse and Sparse2 types.
- apply : apply a function to some arguments, using specified AD tricks.
- isndarray : returns true for numpy, cupy, and AD types.
- cupy_friendly : helper function for CPU/GPU generic programming.
1# Copyright 2020 Jean-Marie Mirebeau, University Paris-Sud, CNRS, University Paris-Saclay 2# Distributed WITHOUT ANY WARRANTY. Licensed under the Apache License, Version 2.0, see http://www.apache.org/licenses/LICENSE-2.0 3 4""" 5This package implements automatic differentiation (AD) methods, in the following flavors: 6- Dense, Sparse, and Reverse (experimental) modes 7- First and second order differentiation 8- CPU and GPU support, using numpy and cupy. 9The AD types implement numpy's overloading mechanisms, and one should be able to use them 10as drop in replacement for numpy arrays in many contexts. 11 12Main submodules: 13- Dense : first order, forward AD with dense storage. 14- Dense2 : second order, forward AD with dense storage. 15- Sparse : first order, forward AD with sparse storage. 16- Sparse2 : second order, forward AD with sparse storage. 17- Reverse, Reverse2 (experimental) : first and second order, reverse AD. 18- Optimization : basic Newton method implemented using AD 19 20Main functions: 21- asarray, array: turn a list/tuple of arrays into a larger array. 22- is_ad : test whether a variable embeds AD information. 23- remove_ad : remove AD information 24- simplify_ad : compress the AD information, of Sparse and Sparse2 types. 25- apply : apply a function to some arguments, using specified AD tricks. 26- isndarray : returns true for numpy, cupy, and AD types. 27- cupy_friendly : helper function for CPU/GPU generic programming. 28""" 29 30 31from . import functional 32#from . import Base # No need to import, but this level in hierarchy 33from . import cupy_support 34from . import cupy_generic 35from . import ad_generic 36from . import misc 37from . import Dense 38from . import Sparse 39from . import Reverse 40from . import Dense2 41from . import Sparse2 42from . import Reverse2 43from . import Optimization 44from . import ad_specific 45 46from .ad_generic import array,asarray,is_ad,remove_ad,common_cast,min_argmin, \ 47 max_argmax,disassociate,associate,apply_linear_mapping,apply_linear_inverse,precision 48 49from .ad_specific import simplify_ad,apply,compose 50from .cupy_generic import isndarray,cupy_friendly 51 52class DeliberateNotebookError(Exception): 53 def __init__(self,message): 54 super(DeliberateNotebookError,self).__init__(message)
class
DeliberateNotebookError(builtins.Exception):
53class DeliberateNotebookError(Exception): 54 def __init__(self,message): 55 super(DeliberateNotebookError,self).__init__(message)
Common base class for all non-exit exceptions.
Inherited Members
- builtins.BaseException
- with_traceback
- add_note
- args