Optimize you Theano Models with [Adagrad](http://www.magicbroom.info/Papers/DuchiHaSi10.pdf), Hessian Free optimization, or linear updates.
pip3 install gradient-optimizers
See example notebook (TBD) for tutorial.
Two classes **GradientModel**, and **GradientHFModel**, for optimizing gradient
based models (specifically built with indexed parameters in mind (e.g.
for language models))
## GradientModel
A gradient model for updating your model with
hessian free, adagrad, or linear decay updates.
You will need to define the following attributes,
and fill them as appropriate:
# a forward method for getting errors:
projection = self.projection_function(ivector <indices/>)
# a cost function (that takes the result of projection function and labels as input)
# and returns a symbolic differentiable theano variable
self.cost_function(projection, ivector <label/>).sum()
self.params = []
self.indexed_params = set()
self._l2_regularization = True / False
self.store_max_updates = True / False
# set this theano setting
self.theano_mode = "FAST_RUN"
# set this theano setting
self.disconnected_inputs = 'ignore' / None
# if L2 is true store this parameter:
self._l2_regularization_parameter = theano.shared(np.float64(l2_regularization).astype(REAL), name='l2_regularization_parameter')
Upon initialization you must run:
self._select_update_mechanism(update_method_name)
# then to compile this mechanism:
self.create_update_fun()
The update methods expect the input to be of the form:
ivector <indices/>, ivector <labels/>
If this is not the case you can modify them as appropriate.
## GradientHFModel
Implements an symbolic one step of hessian-free [1]
optimization that approximates the curvature,
requires a _compute_cost method that takes an example
as input or a _compute_cost_gradients that returns
gradients for each example provided.
Model should have a params property containing symbolic
theano variables.
[[1] James Martens, ``Deep learning via Hessian-free optimization", ICML 2010](http://www.icml2010.org/papers/458.pdf)
Make sure the following parameters are not tampered with:
self._additional_params
self._num_updates
Metadata
Release files for gradient-optimizers 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gradient-optimizers-0.0.4.tar.gz | 9.2 kB | Without provenance | Details for gradient-optimizers-0.0.4.tar.gz |
Release files / gradient-optimizers-0.0.4.tar.gz
| Download URL | gradient-optimizers-0.0.4.tar.gz |
|---|---|
| Size | 9.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9ccfeb3b13297ade4506c1cdb1574d1f09f63018df7046fb5c0f9450a3bf9d4f
|
|
BLAKE2b-256 checksum How to use checksums |
04722a6824a6af69c4fa8eb2aa2c3348625490bb58d5b18f149b28aa7a719643
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for gradient-optimizers 0.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.