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() print "Number of patterns: ", setinfo.number_of_pattern print "Input Dimensions:", len(patinfo.input_dim_sizes) print "Output Dimensions:", len(patinfo.output_dim_sizes) print "Number of subpatterns for each pattern:", krui.DefTrainSubPat((),(),(),()) print "Total number of subpatterns:", krui.getTotalNoOfSubPatterns() krui.setRemapFunc("None",()) print "Learning all patterns, result:" print krui.learnAllPatterns((1.2,0)) print "Learning pattern 3, result:"
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() print "Number of patterns: ", setinfo.number_of_pattern print "Input Dimensions:", len(patinfo.input_dim_sizes) print "Output Dimensions:", len(patinfo.output_dim_sizes) print "Number of subpatterns for each pattern:", krui.DefTrainSubPat( (), (), (), ()) print "Total number of subpatterns:", krui.getTotalNoOfSubPatterns() krui.setRemapFunc("None", ()) print "Learning all patterns, result:" print krui.learnAllPatterns((1.2, 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])
i = i + 1 # druhá fáze (jemnìj¹í) i=0 while i < pruch_2: res = krui.learnAllPatterns(0.03, 0.1) if not i % 100 : print "Fáze 2, chyba v cyklu %d:" % i, res[0] i = i + 1 print "Rekonstruuji pùvodní obrázek" im.blank() for p in xrange(krui.getNoOfPatterns()): krui.setPatternNo(p + 1) krui.showPattern(1); krui.updateNet() block = [] for u in xrange(64 + 16 + 1, 64 * 2 + 16 + 1): block.append(real2pix(krui.getUnitActivation(u))) im.setBlock(p, block) print "Zapisuji výsledný obrázek na disk" im.store("compressed.rgb") print "Vytváøím soubor vzorkù pro SNNS" krui.saveNewPatterns('image.pat', patset) print "Vytváøím soubor sítì pro SNNS" krui.saveNet('image.net','image')