📄 vqdesign.3
字号:
.fiThe value of .I initis ignored if .I vqdesign is called with\fIcbk\->current_size == \fR0. .TP.I split_critWhenever a codeword must be split, either to enlarge the codebook or to replace an empty cell, .I split_critdetermines which codeword is split. It has the following possiblevalues, which are defined in <esps/vq.h>: .nf.ta .25i 1.5i SPLIT_POP split cluster with largest population SPLIT_DIST split cluster with largest average distortion.fiIf more than one codeword is to be split the criterion is applied repeatedly. .TP.I get_chunkThis is a pointer to a function that updates .I datawith the next "chunk" of training data. Such functions must have the following synopsis:.nf.ft Blongget_chunk(data, len, dim, num_prev, error)float **data;long len;long dim;long num_prev;int *error;.ft.fiAs in .I vqdesign,.I datais interpreted as a pointer to a .IR len\- rowby.IR dim\- columnmatrix of floats. .I Get_chunkfills .I datawith up to .I len new feature vectors of dimension .I dim. .I Get_chunkmust return the number of new feature vectors that are in .I data, and it must return the value 0 when the training-sequence is exhausted. If .I get_chunkis called with \fInum_prev\fR == 0, it must start (perhaps again) from the beginning of the training sequence. When .I get_chunk is called from .I vqdesign, the parameter .I num_prev will always be set equal to the total number of vectors from the training sequence that have been supplied by previous calls to .I get_chunk ever since it was called with \fInum_prev\fR == 0. .I Get_chunk returns, in \fIerror\fP, a return status that should be set to values other than 0 whenever an error is detected. For normal returns, \fI*error\fR == 0. .I vqdesign sets \f*error\fR == 0 before calling .I get_chunk. .TP.I vec_to_cdwdThis is a pointer to a function that transforms a feature vector into a codeword. For many applications, no such transformation isneeded \- a feature vector (e.g., the centroid of a cluster of feature vectors) can be used as a codeword without transformation. In such cases, .I vec_to_cdwdis set to NULL and the transformation is bypassed. In otherapplications, a transformation is needed \- for example, in some applications of vector quantization to speech coding, the featurevector components are autocorrelations while the codeword components are filter coefficients, so a transformation is needed. If it is supplied, the function .I vec_to_cdwd must have the following synopsis:.nf.ft Bintvec_to_cdwd(fea_vector, vec_dim, codeword, cdwd_dim, error)float *fea_vector;long vec_dim;float *codeword;long cdwd_dim;int *error;.ft.fiThe feature vector to be transformed is passed to .I vec_to_cdwd via the parameter.I fea_vector,and the resulting codeword is passed back via.I codeword.The dimensions of .I fea_vectorand.I codewordare given respectivelyby .I vec_dimand.I cdwd_dim..I Vec_to_cdwdreturns, in \fIerror\fP, a return status that should be set tovalues other than 0 whenever an error is detected. For normal returns, \fIerror\fR == 0. .I vqdesign sets \f*error\fR == 0 before calling .I vec_to_cdwd. .IPIf \fIget_chunk \fP== NULL, then .I datais assumed to hold the entire training sequence. .TP.I distortThis is a pointer to a function that computes a distortion measurebetween a feature vector and a codeword. Such functions must have thefollowing synopsis: .nf.ft Bdoubledistort(fea_vector, vec_dim, codeword, cdwd_dim, error)float *fea_vector;long vec_dim;float *codeword;long cdwd_dim;int *error;.ft.fi.I Distortcomputes the distortion between the feature vector .I fea_vectorand the codeword.I codeword. The resulting distortion value is the function's return value.The dimensions of .I fea_vectorand.I codewordare given respectivelyby .I vec_dimand.I cdwd_dim. .I Distortalso returns, in \fIerror\fP, a return status that should be set tovalues other than 0 whenever an error is detected. For normal returns,\fIerror\fR == 0. .I vqdesign sets \f*error\fR == 0 before calling .I distort. .IPIf \fIdistort\fP == NULL, then a mean-square-error distortion function is used, but this requires that .I dimand.I cbk\->dimenbe the same. .TP.I splitThis is a pointer to a function that splits a codeword. Such functionsmust have the following synopsis: .nf.ft Bintsplit(cdwd_dest, cdwd_src, cdwd_size)float *cdwd_dest; float cdwd_src; long cdwd_size;.ft.fi.I Cdwd_srcpoints to .I cdwd_sizefloats containing a codeword that is to be split, and .I cdwd_destpoints to .I cdwd_sizefloats in which .I splitwrites the new codeword. .I Splitmay also modify the source codeword.I cdwd_src. .IPIf \fIsplit \fP==NULL, a generic split routine is used; this genericroutine modifies both.I cdwd_destand.I cdwd_src.For details about the generic split algorithm, see "GENERALDESCRIPTION"..TP.I checkpointThis is a pointer to a function that can be used to write the current codebook out to a checkpoint file or to calculate and output some intermediate information. (At least that's the motivation; in principle, .I checkpoint can do anything with or to the current codebook.) It must have thefollowing synopsis:.nf.ft Bintcheckpoint(cdbk, chk_type)struct vqcbk *cdbk;int chk_type;.ft.fi.I Cdbkis a pointer to the current codebook. Note that unpredictable things willhappen if .I checkpointmodifies the current codebook. .IP.I Chk_typeis set by .I vqdesignto indicate at which design stage the call to .I checkpoint is being made. If \fIchk_type\fP == CHK_ENCODE, then the call to .I checkpointoccured after the codewords were adjusted following a pass throughthe training sequence. If \fIchk_type\fP == SPLIT, the call to .I checkpointoccured after the codebook converged at a given size and before itis enlarged by means of a call to .I split. (There are many more calls with \fIchk_type\fP == CHK_ENCODE than with \fIchk_type\fP == CHK_SPLIT.) For an example, see the sourcefor .I vqdes(1\-ESPS), where a .I checkpointroutine does nothing when \fIchk_type\fP == CHK_ENCODE and writes out the current codebook to a checkpoint file when \fIchk_type\fP ==CHK_SPLIT. .IPIf \fIcheckpoint\fR == NULL, then no checkpoint-related action is taken. .TP.I max_iterThis parameter determines the maximum number of iterations allowedat any one clustering level. If the number is exceeded, a messageis written to the history output and .I vqdesignexist with return value VQ_NOCONVG. .SH DETAILED DESCRIPTION.PPIf .I vqdesignis called with \fIcbk\->current_size\fR !=0, it interprets the first \fIcbk\->current_size\fR rows of \fIcbk\->codebook\fR to be an initial codebook. Alternatively, if.I vqdesign is called with \fIcbk\->current_size\fR == 0, it designs a rate 0 initial codebook by finding the centroid of the entire trainingsequence. It does this by averaging each component of the feature vectors in the training sequence and then transforming the resultingvector to a codeword by means of .I vec_to_cdwd. .PPAs mentioned earlier, .I vqdesigninterprets .I dataas a pointer to a .IR len\- rowby.IR dim\- columnmatrix of floats, and each row of .I datais one feature vector from the training sequence. If \fIget_chunk\fR == NULL, .I vqdesignassumes that there are only .I len feature vectors in the training sequence, and that they are all stored in .I data. Otherwise, .I vqdesignuses the function.I get_chunk to step through the training sequence. In this case (\fIget_chunk\fR !=NULL), \fIvqdesign\fR does not assume that any of the training sequence is stored in .I datawhen .I vqdesignis called. (It does, however, assume that the space for \fIdata\fR was allocated properly in the calling program.).PPIf .I vqdesignis called with an initial codebook (\fIcbk\->current_size\fR != 0), and if \fIinit\fR == INIT_CLUSTER, .I vqdesign will "cluster" the initial codebook before proceeding. This works asfollows: The entire training sequence is encoded with respect to thecodebook; this determines a set of codeword clusters (a codeword clustercomprises all of the feature vectors that are closest to a particularcodeword), and it determines the average distortion of all cluster members with respect to the corresponding codeword. (The function .I distortis used to compute the distortion between a feature vector and a codeword.) Next, the centroid of each codeword cluster is computed by averaging the featurevectors in the cluster, and the function .I vec_to_cdwdis used to replace each codeword with the corresponding feature-vectorcentroid. This process is repeated iteratively until the fractionaldecrease in the overall average distortion between successive iterationsfalls below .I cbk\->conv_ratio(successful convergence \- see below), or until .I max_iteriterations have been tried, in which case.I vqdesignexits. .PPIf convergence was successful but an empty cluster remains, the empty cluster is discarded and then filled by splitting a codeword selected by the criteriondetermined by .I split_critand using the.I splitfunction on this codeword. Note that the new codeword will be createdwith a codeword index immediately following the codeword that is split. The codebook is then reclustered until convergence is reached again. This process continues until no empty cells remain. If the number distinct vectors in the training sequence is less than the desired number of codewords, this process could loop forever. However, it will terminate when the limit .I max_iteris reached. .PPIf convergence was successful and no empty cells remain,.I vqdesignenlarges the codebook by selecting codewords according to .I split_critand using the .I splitfunction on these codewords. .I vqdesigncontinues to select and split codewords like this untilthe codebook has been exhausted, in which case it has doubled in size, or the design size is reached. .PPThe enlarged codebook is then clustered as described above, and the the split-cluster process iteratesuntil the codebook size reaches .I cbk\->design_size. .PPIf any of the functions .I "get_chunk, distort, vec_to_cdwd,"or .I splitreport a non-zero error status, .I vqdesign writes a suitable message on .I histrm (provided \fIhistrm\fP != NULL) and returns with an appropriate status value (see the list, above). .PPIf the codebook does not converge during any of the clustering steps, .I vqdesignwrites appropriate information on .I histrmand returns with the value VQ_NOCONVG. .SH ASSUMPTIONS.PPIt is assumed that a cluster centroid can be obtained by applying .I vec_to_cdwdto the feature vector that results from averaging, component by component, all of the feature vectors in the cluster. This assumptionholds for a large class of distortion measures, including mean-squareerror, weighted mean-square error, and Itakura-Saito. It holds for the class of minimum relative-entropy distortion measuresdiscussed in [1], of which the Itakura-Saito is a special case. .SH FUTURE CHANGES.PP.SH BUGSNone known..SH SEE ALSO.PPvqencode(3\-ESPSsp), f_mat_alloc (3\-ESPSu), vqdes(1\-ESPS), vq(1\-ESPS).SH REFERENCES.LP[1] J. E. Shore and R. M. Gray, "Minimum cross-entropy patternclassification and cluster analysis," \fIIEEE Trans. Pattern Analysis and Machine Intelligence \fBPAMI-4\fR, January, 1982, pp. 11-17. .LP[2] Y. Linde, A. Buzo, and R. M. Gray, "An algorithm for vector quantizerdesign," \fIIEEE Trans. on Communications \fBCOM-28\fR, January, 1980, pp. 84-95..LP[3] R. M. Gray, "Vector quantization," \fIIEEE ASSP Magazine\fR, April, 1984, pp. 4-29..LP[4] J. Makhoul, S. Roucos, and H. Gish, "Vector quantization in speech coding," \fIProceedings IEEE \fB73\fR, November, 1985, pp. 1551-1588..SH AUTHORManual page and program by John Shore.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -