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 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.4.tar.gz
(2.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tf2crf-0.1.4.tar.gz.
File metadata
- Download URL: tf2crf-0.1.4.tar.gz
- Upload date:
- Size: 2.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.6.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b81fe4b1599198fea106256e18d028d560b15307bb9af3ccc59a418bad43d169
|
|
| MD5 |
b7f8b21bdefaea03b06d95a45697c280
|
|
| BLAKE2b-256 |
55bd6a321c86b1f564cbd11572559375ad09809a93401fcfcc7e273f8e324f56
|
File details
Details for the file tf2crf-0.1.4-py3-none-any.whl.
File metadata
- Download URL: tf2crf-0.1.4-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.6.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d6e7512dd15837586861f1f607d7c73f77bacd403b0299efb182e8bcf2c62c5e
|
|
| MD5 |
4bfa42392328bb60426c890c1b477506
|
|
| BLAKE2b-256 |
3b46f6e092c9102e3fdf9082a06a4bfafe0a9fc0d2fb90f8e421a691dbc1f8a4
|