Skip to main content

Python package for wrapping gradient optimizers for models in Theano

Project description

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:

self.params = []
self.indexed_params = set()

self._l2_regularization = True / False

# 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

Make sure the following parameters are not tampered with:

self._additional_params

self._num_updates

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gradient-optimizers-0.0.1.tar.gz (8.6 kB view details)

Uploaded Source

File details

Details for the file gradient-optimizers-0.0.1.tar.gz.

File metadata

File hashes

Hashes for gradient-optimizers-0.0.1.tar.gz
Algorithm Hash digest
SHA256 4357aeacb7c7a067c83764161697058eae598bb77bf1189dc48dd6e1afc22e6d
MD5 a26fb25aa269cd67d366849a18c726da
BLAKE2b-256 3ef6204264dba9f61f13e9f5412cafef1f2f05539af476b3ec13b9c43aeb807e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page