Skip to main content

Sparse Look-Up-Table

Project description

稀疏查找表的用处及其优势请参见SparseLUT在Github上的README.md

使用方法

通过以下命令即可安装稀疏查找表的Python包:

pip install sparse_lut

下面介绍使用稀疏查找表的方法。

首先,通过如下代码初始化稀疏查找表

from sparse_lut import SparseLUT

# initialization
lut = SparseLUT((3, 3, 3, 3, 3))

其次,通过add方法,向稀疏查找表中加入多条特征序列,例如

# adding feature-lists
lut.add([[0,1,2], [0,1,2], [0,1,2], [0,1,2], [0,1,2]], "A")
lut.add([[1,2], [0], [0,1,2], [0,1,2], [0,1,2]], "B")
lut.add([[1,2], [1], [0,1,2], [0,1,2], [0,1,2]], "C")

第三,构建稀疏查找表。如果要进一步进行可视化,则需要传入参数 False,否则,程序构建好后会将相关的中间变量清空,以至于无法进行进一步的可视化。

# building the sparse-lut
lut.build(False) # set True is visualization is not required 

第四,如果需要可视化,则通过draw方法进行。 图8

第五,通过下标访问。例如

# accessing the value
result = lut[0,1,0,0,0]
print(result)

程序会打印“OrderedSet(['A'])”,即成功访问到了对应的值。

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

sparse_lut-1.0.0.tar.gz (413.1 kB view details)

Uploaded Source

File details

Details for the file sparse_lut-1.0.0.tar.gz.

File metadata

  • Download URL: sparse_lut-1.0.0.tar.gz
  • Upload date:
  • Size: 413.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.7.10

File hashes

Hashes for sparse_lut-1.0.0.tar.gz
Algorithm Hash digest
SHA256 ee52ab0177f04a3e22afc62114674ed047360ce31b3d3da17c546cf133b0540c
MD5 e4af68ea18e339030272d16152e3c009
BLAKE2b-256 3e97c9f59ad1b12782ad1a2bbb6550fcbb6a2f92fb6e442a3d7b80fe54646859

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