本文整理匯總了Python中minisom.MiniSom.load_map方法的典型用法代碼示例。如果您正苦於以下問題:Python MiniSom.load_map方法的具體用法?Python MiniSom.load_map怎麽用?Python MiniSom.load_map使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類minisom.MiniSom
的用法示例。
在下文中一共展示了MiniSom.load_map方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: init
# 需要導入模塊: from minisom import MiniSom [as 別名]
# 或者: from minisom.MiniSom import load_map [as 別名]
class Som:
def init(self):
self.core = MiniSom(50,50,6,sigma=.8,learning_rate=.5) # needs to match generating minisom command (specifically the load_map)
self.core.load_map()
self.callme = rospy.Service("mapping", Compute, self.callback)
print "SOM setup complete"
def callback(self, data):
vector = np.array([data.fx, data.fy, data.fz, data.tx, data.ty, data.tz]) # format as needed
print vector
w = self.core.winner(vector)
return w[0],w[1]
示例2: MiniSom
# 需要導入模塊: from minisom import MiniSom [as 別名]
# 或者: from minisom.MiniSom import load_map [as 別名]
data = tacitus.cv_21
num = tacitus.cv_21w
n_samples, n_features = data.shape
######################################
# Functional Code Below:
if mode == 1:
print "Using SOM"
drmap = MiniSom(50,50,6,sigma=.8,learning_rate=.5) # Replace 64 with the dimensions of desired target (6)
if fresh_data == 1:
print "Training..."
drmap.train_random(data,1500) # random training
print "\n...ready!"
elif fresh_data == 0:
print "Loading Data"
drmap.load_map()
# plotting the results
from pylab import text,show,cm,axis,figure,subplot,imshow,zeros
figure(1)
im = 0
result = np.array([])
for x,t in zip(data,num): # scatterplot
w = drmap.winner(x)
result.resize((im+1,3))
result[im][0]=w[0]
result[im][1]=w[1]
result[im][2]=num[im]
text(w[0]+.5, w[1]+.5, str(t), color=cm.Dark2(t / 8.), fontdict={'weight': 'bold', 'size': 11})
im = im + 1
axis([0,drmap.weights.shape[0],0,drmap.weights.shape[1]])