OCRNeuralNetwork/src/com/conordevilly/ocr/trainer/AutoTrainer.java
public void run(){
		File dataDir = new File(dirPath);
		File[] imgList = dataDir.listFiles();
		
		//Go through the data an inputted number of times
		for(int i = 1; i <= noRuns; i++){
			numWrong = 0;
			//Go through each file in the data dir
			for(int j = 0; j < imgList.length; j++){
				File currImg = imgList[j];
				try {
					//Process the image
					BufferedImage in = ImageIO.read(currImg);
					char guess = nn.process(in);
					//Get the correct name
					char actual = currImg.getName().toUpperCase().charAt(0);
					
					//Correct the network if necessary
					if(guess != actual){
						//Convert from ASCII to place in alphabet
						System.out.println("Guessed: " + guess + "\tActual: " + actual);
						int actInd = actual - 65;
						numWrong++;
						nn.correct(actInd);
					}
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			System.out.println("Run: " + i + "\tNumber wrong: " + numWrong);
			
			//If no incorrect answers, write the network
			if(numWrong == 0){
				PersistanceManager.writeNN(nn, new File("Data/nn.data"));
				break;
			}
		}
	}
//Go through each entry, making a guess for each one
Go through each entry, making a guess for each one
Go through each entry making a guess for each one
public void run(){
		File dataDir = new File(dirPath);
		File[] imgList = dataDir.listFiles();
		for(int i = 1; i <= noRuns; i++){
			numWrong = 0;
			for(int j = 0; j < imgList.length; j++){
				File currImg = imgList[j];
				try {
					BufferedImage in = ImageIO.read(currImg);
					char guess = nn.process(in);
					char actual = currImg.getName().toUpperCase().charAt(0);
					if(guess != actual){
						System.out.println("Guessed: " + guess + "\tActual: " + actual);
						int actInd = actual - 65;
						numWrong++;
						nn.correct(actInd);
					}
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			System.out.println("Run: " + i + "\tNumber wrong: " + numWrong);
			if(numWrong == 0){
				PersistanceManager.writeNN(nn, new File("Data/nn.data"));
				break;
			}
		}
	}
public void run ( ) { File dataDir = new File ( dirPath ) ; File [ ] imgList = dataDir . listFiles ( ) ; for ( int i = 1 ; i <= noRuns ; i ++ ) { numWrong = 0 ; for ( int j = 0 ; j < imgList . length ; j ++ ) { File currImg = imgList [ j ] ; try { BufferedImage in = ImageIO . read ( currImg ) ; char guess = nn . process ( in ) ; char actual = currImg . getName ( ) . toUpperCase ( ) . charAt ( 0 ) ; if ( guess != actual ) { System . out . println ( "Guessed: " + guess + "\tActual: " + actual ) ; int actInd = actual - 65 ; numWrong ++ ; nn . correct ( actInd ) ; } } catch ( IOException e ) { e . printStackTrace ( ) ; } } System . out . println ( "Run: " + i + "\tNumber wrong: " + numWrong ) ; if ( numWrong == 0 ) { PersistanceManager . writeNN ( nn , new File ( "Data/nn.data" ) ) ; break ; } } }
Go through each entry, making a guess for each one
Go through each entry making a guess for each one
//Go through the data an inputted number of times //Go through each file in the data dir //Process the image //Get the correct name //Correct the network if necessary //Convert from ASCII to place in alphabet //If no incorrect answers, write the network