예제 #1
0
			num = krui.getNextSuccUnit()[0]
		print "Deleting a few links"
		krui.getFirstSuccUnit(9)
		krui.deleteLink()
		krui.getFirstSuccUnit(1)
		krui.getNextSuccUnit()
		krui.deleteAllInputLinks()
		krui.getNextSuccUnit()
		krui.deleteAllOutputLinks()
	
	krui.saveNet('foo.net','Testnet')
	print krui.getLearnFunc()
	#krui.setLearnFunc('RBF-DDA')
	print krui.getInitialisationFunc()
	print krui.getUpdateFunc()
	patset = krui.loadNewPatterns('encoder.pat')
	print "Patternset", patset, "loaded."
	print "Old pattern number:", krui.getPatternNo()
	# fiddle around with some patterns
	krui.setPatternNo(8)
	krui.deletePattern()
	krui.setPatternNo(5)
	krui.modifyPattern()
	krui.setPatternNo(7)
	krui.showPattern(krui.OUTPUT_OUT)
	krui.newPattern()
	krui.shufflePatterns(1)
	krui.shuffleSubPatterns(1)
	krui.saveNewPatterns('foo.pat',patset)
	krui.setPatternNo(1)
	(setinfo, patinfo) = krui.GetPatInfo()
예제 #2
0
util.registerFunction(outtestfunc, "outtestfunc", krui.OUT_FUNC, 0, 0)
util.registerFunction(outtestfunc2, "outtestfunc2", krui.OUT_FUNC, 0, 0)
util.registerFunction(acttest, "acttest", krui.ACT_FUNC, 0, 0)
util.registerFunction(actderivtest, "acttest", krui.ACT_DERIV_FUNC, 0, 0)
util.registerFunction(actderiv2test, "acttest", krui.ACT_2_DERIV_FUNC, 0, 0)
newnum = krui.getNoOfFunctions()
print "After adding:", newnum

for num in range(oldnum - 2, newnum + 1):
    print "Function number", num, "Info:", krui.getFuncInfo(num)

print krui.loadNet('encoder.net')
for num in [1, 10, 19]:
    krui.setUnitOutFunc(num, "outtestfunc")
for num in [2, 11, 18]:
    krui.setUnitOutFunc(num, "outtestfunc2")
for num in [3, 9, 17]:
    krui.setUnitActFunc(num, "acttest")

krui.loadNewPatterns('encoder.pat')
krui.DefTrainSubPat()
print "Learning one pattern"
krui.learnSinglePattern(1, (0.2, 0))
krui.setUnitDefaults(1.0, 0, krui.INPUT, 0, 1, "acttest", "outtestfunc")
newunit = krui.createDefaultUnit()
print "New unit:", newunit
print "Act func name:", krui.getUnitActFuncName(newunit)
krui.deleteUnitList(newunit)
krui.saveNet("tmp.net", "testnet")
print "finished"
예제 #3
0
            num = krui.getNextSuccUnit()[0]
        print "Deleting a few links"
        krui.getFirstSuccUnit(9)
        krui.deleteLink()
        krui.getFirstSuccUnit(1)
        krui.getNextSuccUnit()
        krui.deleteAllInputLinks()
        krui.getNextSuccUnit()
        krui.deleteAllOutputLinks()

    krui.saveNet('foo.net', 'Testnet')
    print krui.getLearnFunc()
    #krui.setLearnFunc('RBF-DDA')
    print krui.getInitialisationFunc()
    print krui.getUpdateFunc()
    patset = krui.loadNewPatterns('encoder.pat')
    print "Patternset", patset, "loaded."
    print "Old pattern number:", krui.getPatternNo()
    # fiddle around with some patterns
    krui.setPatternNo(8)
    krui.deletePattern()
    krui.setPatternNo(5)
    krui.modifyPattern()
    krui.setPatternNo(7)
    krui.showPattern(krui.OUTPUT_OUT)
    krui.newPattern()
    krui.shufflePatterns(1)
    krui.shuffleSubPatterns(1)
    krui.saveNewPatterns('foo.pat', patset)
    krui.setPatternNo(1)
    (setinfo, patinfo) = krui.GetPatInfo()
예제 #4
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]) 
예제 #5
0
파일: customtest.py 프로젝트: mwri/snns
util.registerFunction(outtestfunc2,"outtestfunc2",krui.OUT_FUNC,0,0)
util.registerFunction(acttest,"acttest",krui.ACT_FUNC,0,0)
util.registerFunction(actderivtest,"acttest",krui.ACT_DERIV_FUNC,0,0)
util.registerFunction(actderiv2test,"acttest",krui.ACT_2_DERIV_FUNC,0,0)
newnum = krui.getNoOfFunctions()
print "After adding:", newnum

for num in range(oldnum - 2, newnum + 1) :
	print "Function number", num, "Info:",krui.getFuncInfo(num)

print krui.loadNet('encoder.net')
for num in [1,10,19] :
	krui.setUnitOutFunc(num,"outtestfunc")
for num in [2,11,18] :
	krui.setUnitOutFunc(num,"outtestfunc2")
for num in [3,9,17] :
	krui.setUnitActFunc(num,"acttest")

krui.loadNewPatterns('encoder.pat')
krui.DefTrainSubPat()
print "Learning one pattern"
krui.learnSinglePattern(1,(0.2,0))
krui.setUnitDefaults(1.0,0,krui.INPUT,0,1,"acttest","outtestfunc")
newunit = krui.createDefaultUnit()
print "New unit:", newunit
print "Act func name:", krui.getUnitActFuncName(newunit)
krui.deleteUnitList(newunit)
krui.saveNet("tmp.net","testnet")
print "finished"