src/main/java/com/xceptance/neodymium/visual/ai/NetworkTrainer.java
/**
     * Entry point for running the network trainer.
     * 
     * @param args
     *            String array first two arguments are mandatory, third argument is optional.
     */
Entry point for running the network trainer.

@param args
String array first two arguments are mandatory, third argument is optional.
Entry point for running the network trainer . @param args String array first two arguments are mandatory third argument is optional .
public static void main(String[] args)
    {
        if (args.length < 4)
        {
            System.err.println("Call with NetworkTrainer <data-dir> <result-dir> <property-file> <network-name>");
            System.exit(-1);
        }
        try
        {
            Helper.readProperties(args[2]);
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        final File networkDirectoryPath = new File(args[1]);
        networkDirectoryPath.mkdirs();
        if (args.length == 0)
        {
            System.out.println("No directory path was given as Parameter 1");
            return;
        }
        String networkName = args[3] + ".network";
        final File networkFile = new File(networkDirectoryPath, networkName);
        an = new ActivationNetwork(new BipolarSigmoidFunction(), 1);
        ArrayList<PatternHelper> patternList = new ArrayList<>();
        im = new ImageTransformation(args[0]);
        im.computeAverageMetric();
        patternList = im.updateInternalPattern(im.getAverageMetric(), im.getCurator());
        PerceptronLearning pl = new PerceptronLearning(an);
        pl.setLearningRate(Constants.LEARNING_RATE);
        double resultVerification = 0.0;
        for (PatternHelper pattern : patternList)
        {
            pl.run(pattern.getPatternList());
        }
        for (PatternHelper pattern : patternList)
        {
            resultVerification += an.checkForRecognitionAsDouble(pattern.getPatternList());
            System.out.println("Recognized value of image " + pattern.getTagName() + " = " + an.checkForRecognitionAsString(pattern.getPatternList()) + " %");
        }
        System.out.println("Selftest value summed: " + (resultVerification / patternList.size()));
        an.setInternalParameter(im.getAverageMetric());
        an.Save(networkFile.toString());
    }
public static void main ( String [ ] args ) { if ( args . length < 4 ) { System . err . println ( "Call with NetworkTrainer <data-dir> <result-dir> <property-file> <network-name>" ) ; System . exit ( - 1 ) ; } try { Helper . readProperties ( args [ 2 ] ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } final File networkDirectoryPath = new File ( args [ 1 ] ) ; networkDirectoryPath . mkdirs ( ) ; if ( args . length == 0 ) { System . out . println ( "No directory path was given as Parameter 1" ) ; return ; } String networkName = args [ 3 ] + ".network" ; final File networkFile = new File ( networkDirectoryPath , networkName ) ; an = new ActivationNetwork ( new BipolarSigmoidFunction ( ) , 1 ) ; ArrayList < PatternHelper > patternList = new ArrayList < > ( ) ; im = new ImageTransformation ( args [ 0 ] ) ; im . computeAverageMetric ( ) ; patternList = im . updateInternalPattern ( im . getAverageMetric ( ) , im . getCurator ( ) ) ; PerceptronLearning pl = new PerceptronLearning ( an ) ; pl . setLearningRate ( Constants . LEARNING_RATE ) ; double resultVerification = 0.0 ; for ( PatternHelper pattern : patternList ) { pl . run ( pattern . getPatternList ( ) ) ; } for ( PatternHelper pattern : patternList ) { resultVerification += an . checkForRecognitionAsDouble ( pattern . getPatternList ( ) ) ; System . out . println ( "Recognized value of image " + pattern . getTagName ( ) + " = " + an . checkForRecognitionAsString ( pattern . getPatternList ( ) ) + " %" ) ; } System . out . println ( "Selftest value summed: " + ( resultVerification / patternList . size ( ) ) ) ; an . setInternalParameter ( im . getAverageMetric ( ) ) ; an . Save ( networkFile . toString ( ) ) ; }
Entry point for running the network trainer.
Entry point for running the network trainer .
// -------------------------------------------------------------------------------- // Get Properties and convert them from String if necessary // -------------------------------------------------------------------------------- // Path to working folder // initialization // updated list for self testing and image confirmation