Self-organizing maps in tensorflow
Project description
tf-som
Tensorflow self-organizing maps.
Locally competitive algorithms demonstrate superior convergence to their supervised counterparts over a suite of tasks. Try them yourself:
pip install tf-som
from .models import ConvNet
# build unsupervised base
unsupervised_base = ConvNet((H, W))
# train unsupervised
for x, _ in train_ds:
unsupervised_base(x, training=True)
...
# build supervised head
supervised_head = keras.Sequential([
tfkl.Input(unsupervised_base.output_shape),
tfkl.Conv2D(8, (3, 3), activation='relu'),
tfkl.Flatten(),
tfkl.Dense(N_classes, activation='softmax')
])
# assemble full classifier
unsupervised_base.trainable = False
classifier = keras.Sequential([
unsupervised_base,
supervised_head
])
classifier.compile('sgd', 'cross_entropy', 'accuracy')
# train supervised
classifier.fit(train_ds)
# compare model sizes
print(unsupervised_base.summary())
print(supervised_head.summary())
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
tf-som-0.0.1.tar.gz
(5.5 kB
view hashes)
Built Distribution
tf_som-0.0.1-py3-none-any.whl
(6.8 kB
view hashes)