Skip to main content

Keras LR Multiplier

Travis Coverage

This repo is outdated and will no longer be maintained.

Learning rate multiplier wrapper for optimizers.

Install

pip install git+https://github.com/CyberZHG/keras-lr-multiplier.git

Usage

Basic

LRMultiplier is a wrapper for optimizers to assign different learning rates to specific layers (or weights). The first argument is the original optimizer which could be either an identifier (e.g. 'Adam') or an initialized object (e.g. Adam(lr=1e-2)). The second argument is a dict that maps prefixes to learning rate multipliers. The multiplier for a weight is the value mapped from the longest matched prefix in the given dict, and the default multiplier 1.0 will be used if there is no prefix matched.

from keras.models import Sequential
from keras.layers import Dense
from keras_lr_multiplier import LRMultiplier

model = Sequential()
model.add(Dense(
    units=5,
    input_shape=(5,),
    activation='tanh',
    name='Dense',
))
model.add(Dense(
    units=2,
    activation='softmax',
    name='Output',
))
model.compile(
    optimizer=LRMultiplier('adam', {'Dense': 0.5, 'Output': 1.5}),
    loss='sparse_categorical_crossentropy',
)

Lambda

The multiplier can be a callable object. The input argument is the number of steps starting from 0.

from keras import backend as K
from keras_lr_multiplier import LRMultiplier

LRMultiplier('adam', {'Dense': lambda t: 2.0 - K.minimum(1.9, t * 1e-4)})

Metadata

Release files for keras-lr-multiplier 0.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for keras-lr-multiplier 0.9.0
File Size Uploaded Provenance Actions
keras-lr-multiplier-0.9.0.tar.gz 4.5 kB Without provenance Details for keras-lr-multiplier-0.9.0.tar.gz

Release files / keras-lr-multiplier-0.9.0.tar.gz

Download URL keras-lr-multiplier-0.9.0.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
978f6a536f145b3edde41cec98be320529003ca6d539700dd5c8296df441e6bc
BLAKE2b-256 checksum
How to use checksums
3217dffbfbed11a6c068ff5cbdde09e838687cd1006801dea3a395f60ec3bdfd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.4

Security for keras-lr-multiplier 0.9.0

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.

Release history Release notifications | RSS feed

This release

0.9.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page