Ejemplo n.º 1
0
func randomIntInRange(min, max int) int {
	if min == max {
		logg.Log("warn: min==max (%v == %v)", min, max)
		return min
	}
	return rand.Intn(max-min) + min
}
Ejemplo n.º 2
0
func uploadLauncher() {

	openOcrUrl := fmt.Sprintf("%s:%d", *ocrUrl, *ocrPort)
	openOcrClient := ocrclient.NewHttpClient(openOcrUrl)

	file, err := os.Open(*ocrFile)
	reader := bufio.NewReader(file)

	ocrRequest := ocrclient.OcrRequest{
		EngineType:    ocrclient.ENGINE_TESSERACT,
		InplaceDecode: false, // decode in place rather than using rabbitmq
	}

	ocrDecoded, err := openOcrClient.DecodeImageReader(reader, ocrRequest)
	logg.Log("results: %s", ocrDecoded)
	logg.Log("err: %v", err)

}
Ejemplo n.º 3
0
func RunStochasticHillClimber() {

	ng.SeedRandom()

	// training set -- todo: examples := ng.XnorTrainingSamples()
	examples := ng.XnorTrainingSamples()

	// create netwwork with topology capable of solving XNOR
	cortex := ng.XnorCortexUntrained()

	// verify it can not yet solve the training set (since training would be useless in that case)
	verified := cortex.Verify(examples)
	if verified {
		panic("neural net already trained, nothing to do")
	}

	shc := &nv.StochasticHillClimber{
		FitnessThreshold:           ng.FITNESS_THRESHOLD,
		MaxIterationsBeforeRestart: 2000,
		MaxAttempts:                2000,
		WeightSaturationRange:      []float64{-100 * math.Pi, 100 * math.Pi},
	}
	cortexTrained, _, succeeded := shc.TrainExamples(cortex, examples)
	if !succeeded {
		panic("could not train neural net")
	}

	// verify it can now solve the training set
	verified = cortexTrained.Verify(examples)
	if !verified {
		panic("could not verify neural net")
	}

	logg.LogTo("DEBUG", "trained cortex: %v", cortexTrained)

	logg.Log("done")

}