Building a vector quantizer
Vector Quantization is a quantization technique where the input data is represented by a fixed number of representative points. It is the N-dimensional equivalent of rounding off a number. This technique is commonly used in multiple fields such as image recognition, semantic analysis, and data science. Let's see how to use artificial neural networks to build a vector quantizer.
Create a new Python file and import the following packages:
import numpy as np import matplotlib.pyplot as plt import neurolab as nl
Load the input data from the file data_vector_quantization.txt
. Each line in this file contains six numbers. The first two numbers form the datapoint and the last four numbers form a one-hot encoded label. There are four classes overall.
# Load input data text = np.loadtxt('data_vector_quantization.txt')
Separate the text into data and labels:
# Separate it into data and labels data = text[:, 0:2] labels = text[:, 2:]
Define...