a crf layer for tensorflow 2 keras
Project description
tf2crf
- a simple CRF layer for tensorflow 2 keras
- support keras masking
Install
$ pip install tf2crf
Tips
It has been tested under tensorflow 2.1.0 and tensorflow-nightly.
Example
from tf2CRF import CRF
from tensorflow.keras.layers import Input, Embedding, Bidirectional, GRU, Dense
from tensorflow.keras.models import Model
inputs = Input(shape=(None,), dtype='int32')
output = Embedding(len(vocab), dim, trainable=True, mask_zero=True)(inputs)
output = Bidirectional(GRU(64, return_sequences=True))(output)
output = Dense(len(class_num), activation=None)(output)
crf = CRF()
output = crf(output)
model = Model(inputs, output)
model.compile(loss=crf.loss, optimizer='adam', metrics=[crf.accuracy])
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
tf2crf-0.1.8.tar.gz
(3.0 kB
view hashes)
Built Distribution
Close
Hashes for tf2crf-0.1.8-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0437d67c6ce3fc07b2cf9c439077a12af3cbbd36b8d71f6b2f1a4c48bc0db087 |
|
MD5 | c0f8c30427fa1870cab4aa9724093ffa |
|
BLAKE2b-256 | 6e9957b971352ce1cfa56945e9da02f9266eae8fe63181f2adde7e4a1e91b9c1 |