Attachment 'sheet11.m'

Download

   1 function sheet11
   2 clf;
   3 
   4 % Configuration
   5 iters = 200;
   6 sigmas = [ ... ];
   7 eta = 0.1;
   8 centers = 20;
   9 
  10 % Generate data 
  11 [X,Y] = gen_data(100);
  12 
  13 % Compute RBF network for different sigmas
  14 for s = 1:length(sigmas)
  15 
  16    % Init network
  17    C = init_rbfnet(sigmas(s), centers);
  18 
  19    % Train network in chunks of 10
  20    err = zeros(1, iters);
  21    for i = 1:iters
  22        idx = randperm(length(X));
  23        idx = idx(1:10);
  24 
  25        C = update_rbfnet(C, X(idx), Y(idx), eta);
  26        P = apply_rbfnet(C, X); 
  27 
  28        % Determine error
  29        err(i) = mean((Y - P).^2);
  30    end
  31 
  32    % Make nice plots
  33    subplot(2,3,s); hold on;
  34    plot(X,Y,'.'); plot(X,P,'r-');
  35    subplot(2,3,s+3);
  36    plot(err);
  37 end
  38 
  39 
  40 % Init RBF network
  41 % Input:
  42 %   m     Number of RBF centers
  43 %   w     Kernel width (sigma)
  44 % Output:
  45 %   C     Struct with alphas, mus and sigma
  46 %
  47 function C = init_rbfnet(w, m) 
  48    C.sigma = ...
  49    C.alphas = ...
  50    C.mus = ...
  51 
  52 % Apply RBF network
  53 % Input:   
  54 %    C    Struct with alphas, mus and sigma
  55 %    X    Testing data (1 x n)
  56 % Output:  
  57 %    Y    Predictions (1 x n)
  58 %
  59 function Y = apply_rbfnet(C, X)
  60    ...
  61 
  62 % Update RBF network
  63 % Input:
  64 %    C:    Struct with alphas, mus and sigma
  65 %    X:    Training data (1 x n)
  66 %    Y:    Training labels (1 x n)
  67 %    eta:  Learning rate
  68 % Output:
  69 %    C:    Struct with updated alphas, mus and sigma
  70 function C = update_rbfnet(C, X, Y, eta)
  71    ...
  72 
  73 
  74 % Generate data
  75 % Input: 
  76 %    n    Number of data points
  77 % Output:
  78 %    X    Data points (1 x n)
  79 %    Y    Labels (1 x n)
  80 function [X,Y] = gen_data(n)
  81    ...

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2010-12-03 11:00:13, 73.5 KB) [[attachment:FDA and LSR.pdf]]
  • [get | view] (2010-11-18 14:22:56, 1407.4 KB) [[attachment:clustering_slides.pdf]]
  • [get | view] (2011-01-25 08:30:15, 499.5 KB) [[attachment:efficient_backprop.pdf]]
  • [get | view] (2010-10-28 10:55:22, 123.9 KB) [[attachment:full_sheet01.pdf]]
  • [get | view] (2010-11-04 14:04:25, 118.5 KB) [[attachment:full_sheet02.pdf]]
  • [get | view] (2010-11-11 10:52:24, 60.2 KB) [[attachment:full_sheet03.pdf]]
  • [get | view] (2010-11-18 15:23:26, 97.5 KB) [[attachment:full_sheet04.pdf]]
  • [get | view] (2010-11-25 15:14:31, 92.0 KB) [[attachment:full_sheet05.pdf]]
  • [get | view] (2010-12-02 08:50:14, 108.9 KB) [[attachment:full_sheet06.pdf]]
  • [get | view] (2010-12-09 13:30:45, 161.5 KB) [[attachment:full_sheet07.pdf]]
  • [get | view] (2010-12-16 13:33:01, 84.4 KB) [[attachment:full_sheet08.pdf]]
  • [get | view] (2011-01-05 17:12:33, 127.5 KB) [[attachment:full_sheet09.pdf]]
  • [get | view] (2011-01-12 18:08:23, 136.1 KB) [[attachment:full_sheet10.pdf]]
  • [get | view] (2011-01-19 19:10:49, 143.6 KB) [[attachment:full_sheet11.pdf]]
  • [get | view] (2011-01-26 11:33:22, 136.7 KB) [[attachment:full_sheet12.pdf]]
  • [get | view] (2011-02-02 20:35:04, 134.9 KB) [[attachment:full_sheet13.pdf]]
  • [get | view] (2010-11-25 15:08:04, 1505.5 KB) [[attachment:ica_slides.pdf]]
  • [get | view] (2011-01-08 10:49:41, 504.7 KB) [[attachment:kernel_intro.pdf]]
  • [get | view] (2011-01-25 08:30:11, 1221.6 KB) [[attachment:lect_kernels.pdf]]
  • [get | view] (2011-02-13 09:07:55, 1391.7 KB) [[attachment:rde-tutorial.pdf]]
  • [get | view] (2010-11-18 15:23:34, 1.4 KB) [[attachment:sheet04.m]]
  • [get | view] (2010-11-25 15:14:53, 0.8 KB) [[attachment:sheet05.m]]
  • [get | view] (2010-11-30 21:18:03, 1.1 KB) [[attachment:sheet06.m]]
  • [get | view] (2010-12-09 13:31:05, 1.9 KB) [[attachment:sheet07.m]]
  • [get | view] (2010-12-16 13:33:09, 2.7 KB) [[attachment:sheet08.m]]
  • [get | view] (2011-01-12 17:38:01, 2.0 KB) [[attachment:sheet10.m]]
  • [get | view] (2011-01-12 17:38:14, 4.8 KB) [[attachment:sheet10_data.m]]
  • [get | view] (2011-01-19 19:11:02, 1.5 KB) [[attachment:sheet11.m]]
  • [get | view] (2011-01-26 11:33:28, 1.7 KB) [[attachment:sheet12.m]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.