annotate toolboxes/FullBNT-1.0.7/netlab3.3/rbfsetbf.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 function net = rbfsetbf(net, options, x)
wolffd@0 2 %RBFSETBF Set basis functions of RBF from data.
wolffd@0 3 %
wolffd@0 4 % Description
wolffd@0 5 % NET = RBFSETBF(NET, OPTIONS, X) sets the basis functions of the RBF
wolffd@0 6 % network NET so that they model the unconditional density of the
wolffd@0 7 % dataset X. This is done by training a GMM with spherical covariances
wolffd@0 8 % using GMMEM. The OPTIONS vector is passed to GMMEM. The widths of
wolffd@0 9 % the functions are set by a call to RBFSETFW.
wolffd@0 10 %
wolffd@0 11 % See also
wolffd@0 12 % RBFTRAIN, RBFSETFW, GMMEM
wolffd@0 13 %
wolffd@0 14
wolffd@0 15 % Copyright (c) Ian T Nabney (1996-2001)
wolffd@0 16
wolffd@0 17 errstring = consist(net, 'rbf', x);
wolffd@0 18 if ~isempty(errstring)
wolffd@0 19 error(errstring);
wolffd@0 20 end
wolffd@0 21
wolffd@0 22 % Create a spherical Gaussian mixture model
wolffd@0 23 mix = gmm(net.nin, net.nhidden, 'spherical');
wolffd@0 24
wolffd@0 25 % Initialise the parameters from the input data
wolffd@0 26 % Just use a small number of k means iterations
wolffd@0 27 kmoptions = zeros(1, 18);
wolffd@0 28 kmoptions(1) = -1; % Turn off warnings
wolffd@0 29 kmoptions(14) = 5; % Just 5 iterations to get centres roughly right
wolffd@0 30 mix = gmminit(mix, x, kmoptions);
wolffd@0 31
wolffd@0 32 % Train mixture model using EM algorithm
wolffd@0 33 [mix, options] = gmmem(mix, x, options);
wolffd@0 34
wolffd@0 35 % Now set the centres of the RBF from the centres of the mixture model
wolffd@0 36 net.c = mix.centres;
wolffd@0 37
wolffd@0 38 % options(7) gives scale of function widths
wolffd@0 39 net = rbfsetfw(net, options(7));