Skip to main content

Unofficial implementation of ON-LSTM

Project description

Keras Ordered Neurons LSTM

Travis Coverage Version Downloads 996.ICU

[中文|English]

Unofficial implementation of ON-LSTM.

Install

pip install keras-ordered-neurons

Usage

Basic

Same as LSTM except that an extra argument chunk_size should be given:

from keras.models import Sequential
from keras.layers import Embedding, Bidirectional, Dense
from keras_ordered_neurons import ONLSTM

model = Sequential()
model.add(Embedding(input_shape=(None,), input_dim=10, output_dim=100))
model.add(Bidirectional(ONLSTM(units=50, chunk_size=5)))
model.add(Dense(units=2, activation='softmax'))
model.compile(optimizer='adam', loss='sparse_categorical_crossentropy')
model.summary()

DropConnect

Set recurrent_dropconnect to a non-zero value to enable drop-connect for recurrent weights:

from keras_ordered_neurons import ONLSTM

ONLSTM(units=50, chunk_size=5, recurrent_dropconnect=0.2)

Expected Split Points

Set return_splits to True if you want to know the expected split points of master forget gate and master input gate.

from keras.models import Model
from keras.layers import Input, Embedding
from keras_ordered_neurons import ONLSTM

inputs = Input(shape=(None,))
embed = Embedding(input_dim=10, output_dim=100)(inputs)
outputs, splits = ONLSTM(units=50, chunk_size=5, return_sequences=True, return_splits=True)(embed)
model = Model(inputs=inputs, outputs=splits)
model.compile(optimizer='adam', loss='mse')
model.summary(line_length=120)

tf.keras

Add TF_KERAS=1 to environment variables if you are using tensorflow.python.keras.

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

keras-on-lstm-0.8.0.tar.gz (9.8 kB view details)

Uploaded Source

File details

Details for the file keras-on-lstm-0.8.0.tar.gz.

File metadata

  • Download URL: keras-on-lstm-0.8.0.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.7.1 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.4

File hashes

Hashes for keras-on-lstm-0.8.0.tar.gz
Algorithm Hash digest
SHA256 b42eac9836765e8a96c5e3f8a939fc7552ec4f6125efb438df273e0abe61eda5
MD5 2aec39346fe3c89a5f1587c42215e2db
BLAKE2b-256 8c26166451b98706b778d47146c46fe51ee5be3a3982663cb4bf44adeea95204

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