[Scipy-svn] r2175 - trunk/Lib/sandbox/ann

scipy-svn at scipy.org scipy-svn at scipy.org
Tue Aug 22 09:46:40 EDT 2006


Author: fred.mailhot
Date: 2006-08-22 08:46:37 -0500 (Tue, 22 Aug 2006)
New Revision: 2175

Modified:
   trunk/Lib/sandbox/ann/rbf.py
Log:
Easier way to select random sample of data for RBF centers.


Modified: trunk/Lib/sandbox/ann/rbf.py
===================================================================
--- trunk/Lib/sandbox/ann/rbf.py	2006-08-21 16:32:19 UTC (rev 2174)
+++ trunk/Lib/sandbox/ann/rbf.py	2006-08-22 13:46:37 UTC (rev 2175)
@@ -3,6 +3,7 @@
 # 2006/08/20
 
 import numpy as N
+import random
 from scipy.optimize import leastsq
 
 class rbf:
@@ -80,12 +81,8 @@
             (ii) set fixed variance from max dist between centers
             (iii) learn output weights using scipy's leastsq optimizer
         """
-        # set centers
-        self.centers = N.zeros((len(X)/10,X.shape[1]))
-        for i in range(len(X)):
-            if i%10 == 0:
-                self.centers[i/10] = X[i]
-        # set variance
+        # set centers & variance
+        self.centers = N.array(random.sample(X,len(X)/10))
         d_max = 0.0
         for i in self.centers:
             for j in self.centers:




More information about the Scipy-svn mailing list