コード例 #1
0
#!/usr/bin/python

# shows the coordinates of the winner neurons for the som_cube example

from snns import krui, util

krui.loadNet('som_cube.net')
krui.loadNewPatterns('som_cube.pat')
patnum = krui.getNoOfPatterns()
units = krui.getNoOfUnits()
	
for pat in range(1,patnum+1) :
	krui.setPatternNo(pat)
	krui.showPattern(krui.OUTPUT_NOTHING)
	krui.updateNet(())
	results = []
	for unit in range(1,units+1) :
		if krui.getUnitTType(unit) == krui.HIDDEN :
			results.append((krui.getUnitActivation(unit),unit))
	bestact, bestunit = min(results)
	rawpos = krui.getUnitPosition(bestunit)[:2]
	print "Pattern", pat, "Act", bestact, "Unit", bestunit, 
	print "Grid Position", (rawpos[0]-4, rawpos[1]) 
コード例 #2
0
	headline("sites")
	print krui.getSiteTable()

	if krui.setFirstSite() :
		print "Selected site", krui.getSiteName()
	else :
		print "No site for current unit found"

	headline("unit functions")
	print "Unit 1 has the name", krui.getUnitName(1)
	print "Setting the name to foo"
	krui.setUnitName(1,"foo")
	print "Unit with name 'u35' has number", krui.searchUnitName("u35")

	for i in range(1,4) :
		print "Position of unit %d:" % i, krui.getUnitPosition(i)
	print "Swapping units 1 and 3"
	pos = krui.getUnitPosition(3)
	krui.setUnitPosition(3,krui.getUnitPosition(1))
	krui.setUnitPosition(1,pos)
	for i in range(1,4) :
		print "Position of unit %d:" % i, krui.getUnitPosition(i)
	pos = (2,1,0)
	print "Unit at position", pos, "has number", krui.getUnitNoAtPosition(pos,0)
	print "Next unit to the origin is unit",
	print krui.getUnitNoNearPosition((0,0,0),0,10,10)
	print "Setting unit center for unit 1, center 0"
	krui.setUnitCenters(1,0,(1.2,1.3,1.4,1.5))
	print "Unit centers for unit 1 and center 0:", str(krui.getUnitCenters(1,0))
	print "Input type of unit 10:", util.unit_input_types[krui.getUnitInputType(10)]
	print "Unit defaults:", krui.getUnitDefaults()
コード例 #3
0
ファイル: general.py プロジェクト: danysan2000/snns-1
    headline("sites")
    print krui.getSiteTable()

    if krui.setFirstSite():
        print "Selected site", krui.getSiteName()
    else:
        print "No site for current unit found"

    headline("unit functions")
    print "Unit 1 has the name", krui.getUnitName(1)
    print "Setting the name to foo"
    krui.setUnitName(1, "foo")
    print "Unit with name 'u35' has number", krui.searchUnitName("u35")

    for i in range(1, 4):
        print "Position of unit %d:" % i, krui.getUnitPosition(i)
    print "Swapping units 1 and 3"
    pos = krui.getUnitPosition(3)
    krui.setUnitPosition(3, krui.getUnitPosition(1))
    krui.setUnitPosition(1, pos)
    for i in range(1, 4):
        print "Position of unit %d:" % i, krui.getUnitPosition(i)
    pos = (2, 1, 0)
    print "Unit at position", pos, "has number", krui.getUnitNoAtPosition(
        pos, 0)
    print "Next unit to the origin is unit",
    print krui.getUnitNoNearPosition((0, 0, 0), 0, 10, 10)
    print "Setting unit center for unit 1, center 0"
    krui.setUnitCenters(1, 0, (1.2, 1.3, 1.4, 1.5))
    print "Unit centers for unit 1 and center 0:", str(
        krui.getUnitCenters(1, 0))