{"id":29,"date":"2007-10-26T03:26:55","date_gmt":"2007-10-26T01:26:55","guid":{"rendered":"http:\/\/robin.meier.free.fr\/site\/?p=29"},"modified":"2026-03-21T22:50:52","modified_gmt":"2026-03-21T21:50:52","slug":"self-organizing-map-xmlrpc-server","status":"publish","type":"post","link":"https:\/\/robinmeier.net\/?p=29","title":{"rendered":"Self-organizing Map XMLRPC-Server"},"content":{"rendered":"<pre lang=\"PYTHON\"># This program requires Python 2.3 or above\n# robin meier 17-02-06 paris http:\/\/robin.meier.free.fr http:\/\/www.neuromuse.org\n#\n# provides the methods necessary to run a SOM on a distant server using xmlrpc\n\nfrom DocXMLRPCServer import DocXMLRPCServer, DocXMLRPCRequestHandler\nfrom SocketServer import ThreadingMixIn\n\nimport sys\nfrom psyco import *\nfrom numarray import *\nfrom numarray.random_array import *\nfrom math import *\nfrom socket import *\nfrom cPickle import *\n\ndef test(lolo):\n\tlolo = lolo + 1\n\treturn lolo\n\nclass Som:\n\tdef __init__(self):\n\t\tself.somsize = 100\n\t\tself.weights = random((3,3))\n\t\tself.inputvector = (0.1, 0.1, 0.1)\n\t\tself.activation = random((3))\n\t\tself.winner = 0\n\t\tself.distances = random((5,5))\n\t\tself.winx = 1\n\t\tself.winy = 1\n\tdef initializeSom(self, somsize=100, vectorsize=3, verbose=0):\n\t\t\"\"\"create a som\n\n\t\tspecify somsize and vectorsize\"\"\"\n\t\tself.somsize = somsize\n\t\tself.weights = random((somsize,vectorsize))\n\t\tif verbose:\n\t\t\treturn \"som created\"\n\t\telse:\n\t\t\treturn \"ok\"\n\tdef randomizeWeights(self, inputvector, verbose=0):\n\t\t\"\"\"randomizes weights of the som\n\n\t\tgives back pickled weights\"\"\"\n\t\tself.weights = random((self.somsize,len(inputvector)))\n\t\tif verbose:\n\t\t\treturn dumps(self.weights)\n\t\telse:\n\t\t\treturn dumps(\"ok\")\n\tdef computeActivation(self, inputvector, verbose=0):\n\t\t\"\"\"euclidean distance without sqrt between input and each neuron\n\n\t\tgives back pickled activation\"\"\"\n\t\tself.inputvector = list(inputvector)\n#\t\treturn dumps(self.inputvector)\n\t\tself.activation = sum(((self.weights-self.inputvector)*(self.weights-self.inputvector)),1)\n\t\tif verbose:\n\t\t\treturn dumps(self.activation)\n\t\telse:\n\t\t\treturn dumps(\"ok\")\n\tdef computeWinner(self, verbose=0):\n\t\t\"\"\"who's the winner?\n\n\t\tgives back winner-no and winner-weights as list\"\"\"\n\t\tself.winner = int((argsort(self.activation))[0])\n\t\tif verbose:\n\t\t\treturn self.winner, list(self.weights[self.winner,:])\n\t\telse:\n\t\t\treturn \"ok\"\n\tdef updateWeights(self, inputvector, learningrate=0.1, radius=3, verbose=0):\n\t\t\"\"\"update weights\n\n\t\tgives back pickled distances array\"\"\"\n\t\t#conversion index->coord\n\t\tseite = int(sqrt(self.somsize))\n\t\tself.winy = int(self.winner\/seite)\n\t\tself.winx = int(self.winner%seite)\n\t\t#calculate distances\n\t\tdist = lambda x,y: (x-self.winx)**2+(y-self.winy)**2\n\t\tself.distances = fromfunction(dist, (seite, seite))\n\t\t#print self.distances\n\t\tfor i in range(self.somsize):\n\t\t\tiy=int(i\/seite)\n\t\t\tix = int(i%seite)\n\t\t\tn = float(self.distances[iy,ix])\n\t\t\tif n < radius:\n\t\t\t\tdelta = learningrate*(inputvector-(take(self.weights,i)))*(exp(-1*((n*n)\/(2*radius*radius))))\n\t\t\t\tput(self.weights,i,((take(self.weights,i)+delta)))\n\t\tif verbose:\n\t\t\treturn dumps(self.distances)\n\t\telse:\n\t\t\treturn dumps(\"ok\")\n\n\nclass ThreadingServer(ThreadingMixIn, DocXMLRPCServer):\n\tpass\n\nserveraddr = ('', 8765)\nsrvr = ThreadingServer(serveraddr, DocXMLRPCRequestHandler)\nsrvr.set_server_title(\"self-organizing map as xmlrpc python-server\")\nsrvr.set_server_name(\"self-organizing map server\")\nsrvr.set_server_documentation(\"\"\"welcome to this self-organizing map running as a python xmlrpc\n\tserver!\"\"\")\nsrvr.register_instance(Som())\nsrvr.register_introspection_functions()\nsrvr.register_function(test)\nsrvr.serve_forever()<\/pre>\n","protected":false},"excerpt":{"rendered":"<p># This program requires Python 2.3 or above # robin meier 17-02-06 paris http:\/\/robin.meier.free.fr http:\/\/www.neuromuse.org # # provides the methods necessary to run a SOM on a distant server using xmlrpc from DocXMLRPCServer import DocXMLRPCServer, DocXMLRPCRequestHandler from SocketServer import ThreadingMixIn import sys from psyco import * from numarray import * from numarray.random_array import * from [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[28,81],"class_list":["post-29","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-ai","tag-code"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Self-organizing Map XMLRPC-Server - robin meier wiratunga<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/robinmeier.net\/?p=29\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Self-organizing Map XMLRPC-Server - robin meier wiratunga\" \/>\n<meta property=\"og:description\" content=\"# This program requires Python 2.3 or above # robin meier 17-02-06 paris http:\/\/robin.meier.free.fr http:\/\/www.neuromuse.org # # provides the methods necessary to run a SOM on a distant server using xmlrpc from DocXMLRPCServer import DocXMLRPCServer, DocXMLRPCRequestHandler from SocketServer import ThreadingMixIn import sys from psyco import * from numarray import * from numarray.random_array import * from [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/robinmeier.net\/?p=29\" \/>\n<meta property=\"og:site_name\" content=\"robin meier wiratunga\" \/>\n<meta property=\"article:published_time\" content=\"2007-10-26T01:26:55+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-03-21T21:50:52+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/robinmeier.net\/wp-content\/uploads\/2026\/03\/IMG_1638.jpeg\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"1080\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/robinmeier.net\\\/?p=29#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/robinmeier.net\\\/?p=29\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\\\/\\\/robinmeier.net\\\/#\\\/schema\\\/person\\\/4bb244780550926b09928d8d11a13fd0\"},\"headline\":\"Self-organizing Map XMLRPC-Server\",\"datePublished\":\"2007-10-26T01:26:55+00:00\",\"dateModified\":\"2026-03-21T21:50:52+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/robinmeier.net\\\/?p=29\"},\"wordCount\":3,\"keywords\":[\"ai\",\"code\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/robinmeier.net\\\/?p=29\",\"url\":\"https:\\\/\\\/robinmeier.net\\\/?p=29\",\"name\":\"Self-organizing Map XMLRPC-Server - robin meier wiratunga\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/robinmeier.net\\\/#website\"},\"datePublished\":\"2007-10-26T01:26:55+00:00\",\"dateModified\":\"2026-03-21T21:50:52+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/robinmeier.net\\\/#\\\/schema\\\/person\\\/4bb244780550926b09928d8d11a13fd0\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/robinmeier.net\\\/?p=29#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/robinmeier.net\\\/?p=29\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/robinmeier.net\\\/?p=29#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/robinmeier.net\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Self-organizing Map XMLRPC-Server\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/robinmeier.net\\\/#website\",\"url\":\"https:\\\/\\\/robinmeier.net\\\/\",\"name\":\"robin meier wiratunga\",\"description\":\"artist website and portfolio\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/robinmeier.net\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/robinmeier.net\\\/#\\\/schema\\\/person\\\/4bb244780550926b09928d8d11a13fd0\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4300ef5db4c1119caab717a4f56d23ec6e575d5e9adcb709f19302aa42fdfdd1?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4300ef5db4c1119caab717a4f56d23ec6e575d5e9adcb709f19302aa42fdfdd1?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4300ef5db4c1119caab717a4f56d23ec6e575d5e9adcb709f19302aa42fdfdd1?s=96&d=mm&r=g\",\"caption\":\"admin\"},\"url\":\"https:\\\/\\\/robinmeier.net\\\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Self-organizing Map XMLRPC-Server - robin meier wiratunga","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/robinmeier.net\/?p=29","og_locale":"en_US","og_type":"article","og_title":"Self-organizing Map XMLRPC-Server - robin meier wiratunga","og_description":"# This program requires Python 2.3 or above # robin meier 17-02-06 paris http:\/\/robin.meier.free.fr http:\/\/www.neuromuse.org # # provides the methods necessary to run a SOM on a distant server using xmlrpc from DocXMLRPCServer import DocXMLRPCServer, DocXMLRPCRequestHandler from SocketServer import ThreadingMixIn import sys from psyco import * from numarray import * from numarray.random_array import * from [&hellip;]","og_url":"https:\/\/robinmeier.net\/?p=29","og_site_name":"robin meier wiratunga","article_published_time":"2007-10-26T01:26:55+00:00","article_modified_time":"2026-03-21T21:50:52+00:00","og_image":[{"width":1920,"height":1080,"url":"https:\/\/robinmeier.net\/wp-content\/uploads\/2026\/03\/IMG_1638.jpeg","type":"image\/jpeg"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/robinmeier.net\/?p=29#article","isPartOf":{"@id":"https:\/\/robinmeier.net\/?p=29"},"author":{"name":"admin","@id":"https:\/\/robinmeier.net\/#\/schema\/person\/4bb244780550926b09928d8d11a13fd0"},"headline":"Self-organizing Map XMLRPC-Server","datePublished":"2007-10-26T01:26:55+00:00","dateModified":"2026-03-21T21:50:52+00:00","mainEntityOfPage":{"@id":"https:\/\/robinmeier.net\/?p=29"},"wordCount":3,"keywords":["ai","code"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/robinmeier.net\/?p=29","url":"https:\/\/robinmeier.net\/?p=29","name":"Self-organizing Map XMLRPC-Server - robin meier wiratunga","isPartOf":{"@id":"https:\/\/robinmeier.net\/#website"},"datePublished":"2007-10-26T01:26:55+00:00","dateModified":"2026-03-21T21:50:52+00:00","author":{"@id":"https:\/\/robinmeier.net\/#\/schema\/person\/4bb244780550926b09928d8d11a13fd0"},"breadcrumb":{"@id":"https:\/\/robinmeier.net\/?p=29#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/robinmeier.net\/?p=29"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/robinmeier.net\/?p=29#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/robinmeier.net\/"},{"@type":"ListItem","position":2,"name":"Self-organizing Map XMLRPC-Server"}]},{"@type":"WebSite","@id":"https:\/\/robinmeier.net\/#website","url":"https:\/\/robinmeier.net\/","name":"robin meier wiratunga","description":"artist website and portfolio","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/robinmeier.net\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/robinmeier.net\/#\/schema\/person\/4bb244780550926b09928d8d11a13fd0","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4300ef5db4c1119caab717a4f56d23ec6e575d5e9adcb709f19302aa42fdfdd1?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4300ef5db4c1119caab717a4f56d23ec6e575d5e9adcb709f19302aa42fdfdd1?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4300ef5db4c1119caab717a4f56d23ec6e575d5e9adcb709f19302aa42fdfdd1?s=96&d=mm&r=g","caption":"admin"},"url":"https:\/\/robinmeier.net\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/robinmeier.net\/index.php?rest_route=\/wp\/v2\/posts\/29","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/robinmeier.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/robinmeier.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/robinmeier.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/robinmeier.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=29"}],"version-history":[{"count":1,"href":"https:\/\/robinmeier.net\/index.php?rest_route=\/wp\/v2\/posts\/29\/revisions"}],"predecessor-version":[{"id":32154,"href":"https:\/\/robinmeier.net\/index.php?rest_route=\/wp\/v2\/posts\/29\/revisions\/32154"}],"wp:attachment":[{"href":"https:\/\/robinmeier.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=29"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/robinmeier.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=29"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/robinmeier.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=29"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}