예제 #1
0
    logfile = os.path.join(resultspath, 'training.log')
    log = open(logfile, 'a')
    log.write('---- Training with no razor variables ---- \n')

    for e in epochs:
        for s in sigma:
            for l in lrate:
                for i in range(trials):
                    log.write(
                        'Epochs: {0:2d}, Sigma: ({1:4f}, {2:4f}), Lrate: ({3:4f}, {4:4f}) \n'
                        .format(e, s[0], s[1], l[0], l[1]))
                    Map = SOM(datafile, razor=False, shape=(10, 10, 10))
                    Map.set_params(epochs=e,
                                   lrate=l,
                                   sigma=s,
                                   threshold=threshold)
                    Map.train_theano(quiet=True)
                    Map.test_theano(quiet=True)
                    # Map.show_map()
                    _, zeros = Map.negloglikelihood([3])
                    exc = Map.exclusion((0, 5), n=1000, show=False)
                    dis = Map.discovery((0, 5), n=1000, show=False)
                    log.write('contains {0:2d} zeros \n'.format(zeros))
                    log.write('exclusion: {0:5f} \n'.format(exc))
                    log.write('discovery: {0:5f} \n \n'.format(dis))
                    print 'contains {0:2d} zeros'.format(zeros)
                    print 'exclusion: {0:5f} '.format(exc)
                    print 'discovery: {0:5f} '.format(dis)
                    # Map.save_map(resultspath)
    log.close()
예제 #2
0
파일: SOM_test.py 프로젝트: Irene-Li/susyML
			mappath = os.path.join(datapath, 'SOM', dataset[0:-5])
			datafile = os.path.join(datapath, dataset)

			logfile = os.path.join(mappath, 'results.log')
			log = open(logfile, 'w')

			exclusion = [] 
			discovery = []

			for mapfile in [os.path.join(mappath, f) for f in os.listdir(mappath) if f.endswith('hdf5')]:
				print mapfile
				Map = SOM(datafile, shape = (10, 10, 10), filename = mapfile)
				log.write('Epochs: {0:2d}, Sigma: ({1:4f}, {2:4f}), Lrate: ({3:4f}, {4:4f}) \n'.format(Map.epochs, Map.sigma_i, Map.sigma_f, Map.lrate_i, Map.lrate_f))
				Map.test_theano(quiet = True)
				Map.show_map()
				_, zeros = Map.negloglikelihood([3])
				log.write('contains {0:2d} zeros \n'.format(zeros))
				exc = Map.exclusion((0, 2), n = 1000, show = True)
				dis = Map.discovery((0, 3), n = 1000, show = True)
				log.write('exclusion: {0:5f} \n'.format(exc))
				log.write('discovery: {0:5f} \n'.format(dis))
				print 'contains {0:2d} zeros'.format(zeros)
				print exc, dis
				exclusion.append(exc)
				discovery.append(dis)

			mean_exc = np.mean(exclusion)
			std_exc = np.std(exclusion)
			mean_dis = np.mean(discovery)
			std_dis = np.std(discovery)