/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mycompany.mapawarenesstest;

import java.awt.Image;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.JFileChooser;
import javax.swing.SwingWorker;
import org.encog.engine.network.activation.ActivationSigmoid;
import org.encog.ml.data.MLData;
import org.encog.ml.data.basic.BasicMLData;
import org.encog.ml.train.strategy.ResetStrategy;
import org.encog.neural.networks.BasicNetwork;
import org.encog.neural.networks.training.pnn.TrainBasicPNN;
import org.encog.neural.networks.training.propagation.resilient.RPROPType;
import org.encog.neural.networks.training.propagation.resilient.ResilientPropagation;
import org.encog.neural.pattern.FeedForwardPattern;
import org.encog.neural.pnn.BasicPNN;
import org.encog.persist.EncogDirectoryPersistence;
import org.encog.platformspecific.j2se.TrainingDialog;
import org.encog.platformspecific.j2se.data.image.ImageMLData;
import org.encog.platformspecific.j2se.data.image.ImageMLDataSet;
import org.encog.util.EngineArray;
import org.encog.util.Format;
import org.encog.util.downsample.Downsample;
import org.encog.util.downsample.RGBDownsample;
import org.encog.util.simple.EncogUtility;

/**
 *
 * @author Michal
 */
public class TestFrameE3 extends javax.swing.JFrame {

    /**
     * Creates new form TestFrameE3
     */
    public TestFrameE3() {
        initComponents();  
        prepareIdentities10();  
        processCreateTraining(100, 100, "RGB");//"RGB"    
    }

    protected void prepareIdentities10() {
        assignIdentity("0");
        assignIdentity("1");
        assignIdentity("2");
        assignIdentity("3");
        assignIdentity("4");
        assignIdentity("5");
        assignIdentity("6");
        assignIdentity("7");
        assignIdentity("8");
        assignIdentity("9");
    }
    private void setNetwork(BasicNetwork network) {
        this.network = network;
        if(null==network){
            checkButton.setEnabled(false);
            trainButton.setEnabled(false);
            stopButton.setEnabled(false);
            saveButton.setEnabled(false);
            testButton.setEnabled(false);
        } else {
            checkButton.setEnabled(true);
            trainButton.setEnabled(true);
            stopButton.setEnabled(true);
            saveButton.setEnabled(true);
            testButton.setEnabled(true);
        }
    }
    
class ImagePair {
		private final File file;
		private final int identity;

		public ImagePair(final File file, final int identity) {
			super();
			this.file = file;
			this.identity = identity;
		}

		public File getFile() {
			return this.file;
		}

		public int getIdentity() {
			return this.identity;
		}
	}

	private final List<ImagePair> imageList = new ArrayList<ImagePair>();
	private final Map<String, Integer> identity2neuron = new HashMap<String, Integer>();
	private final Map<Integer, String> neuron2identity = new HashMap<Integer, String>();
	private ImageMLDataSet training;
	private int outputCount;
	private int downsampleWidth;
	private int downsampleHeight;
        private BasicNetwork network;
        private SwingWorker trainingWorker;

	private Downsample downsample;

	private int assignIdentity(final String identity) {

		if (this.identity2neuron.containsKey(identity.toLowerCase())) {
			return this.identity2neuron.get(identity.toLowerCase());
		}

		final int result = this.outputCount;
		this.identity2neuron.put(identity.toLowerCase(), result);
		this.neuron2identity.put(result, identity.toLowerCase());
		this.outputCount++;
                System.out.println(identity+":"+result);
		return result;
	}

        
	private void processCreateTraining(int downsampleHeight,int downsampleWidth, String type) {

		this.downsampleHeight = downsampleHeight;
		this.downsampleWidth = downsampleWidth;

		if (type.equals("RB")) {
			this.downsample = new RBDownsample();
		} else {
			this.downsample = new RGBDownsample();
		}

		this.training = new ImageMLDataSet(this.downsample, false, 1, 0);
//		System.out.println("Training set created");
	}

	private void processInput(File file,final String identity) {

		final int idx = assignIdentity(identity);

		this.imageList.add(new ImagePair(file, idx));

		System.out.println("Added input image:" + file.getName());
	}

	private void processNetwork(final int hidden1, final int hidden2) throws IOException {
		

		this.training.downsample(this.downsampleHeight, this.downsampleWidth);
                setNetwork(null);
                //
                FeedForwardPattern ffPattern=new FeedForwardPattern();
                if(hidden1>0)ffPattern.addHiddenLayer(hidden1);
                if(hidden2>0)ffPattern.addHiddenLayer(hidden2);
		ffPattern.setInputNeurons(this.training
				.getInputSize());
		ffPattern.setOutputNeurons(this.training.getIdealSize());
//                ffPattern.setActivationFunction(new ActivationTANH());
                ffPattern.setActivationFunction(new ActivationSigmoid());
		this.setNetwork((BasicNetwork ) ffPattern.generate());
                
		System.out.println("Created network ");
	}


	public void processWhatIs(final File file, String expected) throws IOException {
		final Image img = ImageIO.read(file);
		final ImageMLData input = new ImageMLData(img);
		input.downsample(this.downsample, false, this.downsampleHeight,
				this.downsampleWidth, 1, 0); 
		final MLData output;
//                if(this.jRadioButtonPNN.isSelected())output = this.pnn.compute(input);
//                else 
                output = this.network.compute(input);
		final int winner =  EngineArray.maxIndex(output.getData());
		System.out.println("What is: " + file.getName() + ", it seems to be: "
				+ this.neuron2identity.get(winner) + ", expected: " +expected);
                System.out.println(output.toString());
	}
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jButton1 = new javax.swing.JButton();
        checkButton = new javax.swing.JButton();
        jSpinner1 = new javax.swing.JSpinner();
        trainButton = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        hiden1Spinner = new javax.swing.JSpinner();
        hiden2Spinner = new javax.swing.JSpinner();
        jLabel2 = new javax.swing.JLabel();
        saveButton = new javax.swing.JButton();
        loadButton = new javax.swing.JButton();
        createNetworkButton = new javax.swing.JButton();
        stopButton = new javax.swing.JButton();
        testButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jButton1.setText("Create Dataset");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        checkButton.setText("Check");
        checkButton.setEnabled(false);
        checkButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                checkButtonActionPerformed(evt);
            }
        });

        jSpinner1.setValue(10);

        trainButton.setText("Train");
        trainButton.setEnabled(false);
        trainButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                trainButtonActionPerformed(evt);
            }
        });

        jLabel1.setText("Hiden1:");

        jLabel2.setText("Hiden2:");

        saveButton.setText("Save");
        saveButton.setEnabled(false);
        saveButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveButtonActionPerformed(evt);
            }
        });

        loadButton.setText("Load");
        loadButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                loadButtonActionPerformed(evt);
            }
        });

        createNetworkButton.setText("Create Network");
        createNetworkButton.setEnabled(false);
        createNetworkButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                createNetworkButtonActionPerformed(evt);
            }
        });

        stopButton.setText("Stop");
        stopButton.setEnabled(false);
        stopButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                stopButtonActionPerformed(evt);
            }
        });

        testButton.setText("Test");
        testButton.setEnabled(false);
        testButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                testButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(testButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(checkButton)
                        .addContainerGap())
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jButton1)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(hiden1Spinner, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jLabel2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(hiden2Spinner, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(createNetworkButton)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(loadButton)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(saveButton))
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(18, 18, 18)
                                    .addComponent(trainButton))
                                .addComponent(stopButton)))
                        .addGap(0, 111, Short.MAX_VALUE))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jButton1)
                .addGap(21, 21, 21)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(hiden1Spinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2)
                    .addComponent(hiden2Spinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(loadButton)
                    .addComponent(saveButton)
                    .addComponent(createNetworkButton))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(trainButton))
                .addGap(24, 24, 24)
                .addComponent(stopButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 111, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(checkButton)
                    .addComponent(testButton))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        
        
        JFileChooser jf=new JFileChooser(".");
        jf.setMultiSelectionEnabled(true);
        jf.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        if(JFileChooser.APPROVE_OPTION == jf.showOpenDialog(this)){
            processCreateTraining(100, 100, "RGB");//"RGB"
            File dir= jf.getSelectedFile();
            File[] dirs = dir.listFiles();

            List<File[]> images= new ArrayList();
            List<String> ids=new ArrayList<String>();
            for(File kind:dirs){
                if(kind.isDirectory()){
                    ids.add(kind.getName());
                    images.add(kind.listFiles());
                }
            }
            boolean added=true;
            int i=0;
            while(added){
                added=false;
                for(int j=0; j<ids.size();j++){
                    if(i<images.get(j).length) {
                        processInput(images.get(j)[i], ids.get(j));
                        added=true;
                    }
                }
                i++;
            }
             createNetworkButton.setEnabled(true);
        }
        System.out.println("Downsampling images...");

        for (final ImagePair pair : this.imageList) {
            try {
                final MLData ideal = new BasicMLData(this.outputCount);
                final int idx = pair.getIdentity();
                for (int i = 0; i < this.outputCount; i++) {
                        if (i == idx) {
                                ideal.setData(i, 1);
                        } else {
                                ideal.setData(i, 0);//-1);
                        }
                }

                final Image img = ImageIO.read(pair.getFile());
                final ImageMLData data = new ImageMLData(img);
                
                data.downsample(this.downsample, false, this.downsampleHeight,
                        this.downsampleWidth, 1, 0);
                this.training.add(data, ideal);
            } catch (IOException ex) {
                Logger.getLogger(TestFrameE3.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        this.imageList.clear();
        System.out.println("Done.");
    }//GEN-LAST:event_jButton1ActionPerformed

    private void checkButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkButtonActionPerformed
        JFileChooser jf=new JFileChooser(".");
        jf.setMultiSelectionEnabled(true);
        if(JFileChooser.APPROVE_OPTION == jf.showOpenDialog(this)){
            try {
                for(File f :jf.getSelectedFiles()) processWhatIs(f,f.getParentFile().getName());
            } catch (IOException ex) {
                Logger.getLogger(TestFrameE3.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }//GEN-LAST:event_checkButtonActionPerformed

    private void trainButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_trainButtonActionPerformed
//        final boolean pnn= jRadioButtonPNN.isSelected();
        trainingWorker=new SwingWorker() {

                @Override
                protected Object doInBackground() throws Exception {
                        trainButton.setEnabled(false);
                        //processTrain(0.1, 100, null);
//                        processTrain(0.1, 100, (Integer) jSpinner1.getValue(),pnn);
                        ResilientPropagation train=new ResilientPropagation(network, training);
                        train.setRPROPType(RPROPType.iRPROPp);
                        train.addStrategy(new ResetStrategy(0.1, 100));
                        System.gc();
                        
                        long remaining=0;
                        int minutes=(Integer) jSpinner1.getValue();
                        System.out.println("Beginning training...");
                        final long start = System.currentTimeMillis();
                        do {
                            try{
                                train.iteration();

                                final long current = System.currentTimeMillis();
                                final long elapsed = (current - start) / 1000;// seconds
                                remaining = minutes - elapsed / 60;

                                int iteration = train.getIteration();

                                System.out.println("Iteration #" + Format.formatInteger(iteration)
                                                + " Error:" + Format.formatPercent(train.getError())
                                                + " elapsed time = " + Format.formatTimeSpan((int) elapsed)
                                                + " time left = "
                                                + Format.formatTimeSpan((int) remaining * 60));
                            }catch(Throwable e){
                                System.out.println(e.getLocalizedMessage());
                            }
                        } while (remaining > 0 && !this.isCancelled());// && train.getError()>0.02);//
                        train.finishTraining();
                        trainButton.setEnabled(true);
                    return null;
                }
            };
            trainingWorker.execute();
    }//GEN-LAST:event_trainButtonActionPerformed

    private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveButtonActionPerformed
        JFileChooser jf=new JFileChooser(".");
        if(JFileChooser.APPROVE_OPTION == jf.showSaveDialog(this)){
        EncogDirectoryPersistence.saveObject(jf.getSelectedFile(), network);
//        try{
//            PrintStream ps=new PrintStream("network");
//            for(int layer=1;layer<network.getLayerCount();layer++){
//                ps.println("newLayer");
//                for(int neuron=0; neuron<network.getLayerNeuronCount(layer);neuron++){
//                    for(int weight=0;weight<network.getLayerNeuronCount(layer-1);weight++){
//                        ps.print(","+network.getWeight(layer, weight, neuron));
//                    }
//                }
//            }
//            ps.close();
//            PrintStream ps2=new PrintStream("networkCSV");
//            ps2.print(network.dumpWeights());
//            ps2.close();
//        }catch(Exception e){
        System.out.println("Network saved.");
        }
    }//GEN-LAST:event_saveButtonActionPerformed

    private void loadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loadButtonActionPerformed
        /*
		System.out.println("Downsampling images...");

		for (final ImagePair pair : this.imageList) {
                    final MLData ideal = new BasicMLData(this.outputCount);
                    final int idx = pair.getIdentity();
                    for (int i = 0; i < this.outputCount; i++) {
                            if (i == idx) {
                                    ideal.setData(i, 1);
                            } else {
                                    ideal.setData(i, -1);
                            }
                    }

                    final Image img;
                    try {
                        img = ImageIO.read(pair.getFile());
			final ImageMLData data = new ImageMLData(img);
                        data.downsample(this.downsample, false, this.downsampleHeight,
				this.downsampleWidth, 1, -1);
			this.training.add(data, ideal);
                    } catch (IOException ex) {
                        Logger.getLogger(TestFrameE3.class.getName()).log(Level.SEVERE, null, ex);
                    }
                        
		}

		this.training.downsample(this.downsampleHeight, this.downsampleWidth);
*/                                           
        JFileChooser jf=new JFileChooser(".");
        if(JFileChooser.APPROVE_OPTION == jf.showOpenDialog(this)){
            setNetwork((BasicNetwork) EncogDirectoryPersistence.loadObject(jf.getSelectedFile()));
        }
    }//GEN-LAST:event_loadButtonActionPerformed

    private void createNetworkButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_createNetworkButtonActionPerformed
        try {
            processNetwork((Integer) hiden1Spinner.getValue(), (Integer) hiden2Spinner.getValue());
        } catch (IOException ex) {
            Logger.getLogger(TestFrameE3.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_createNetworkButtonActionPerformed

    private void stopButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stopButtonActionPerformed
        if(null!=trainingWorker)trainingWorker.cancel(false);
    }//GEN-LAST:event_stopButtonActionPerformed

    private void testButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_testButtonActionPerformed
        JFileChooser jf=new JFileChooser(".");
        jf.setMultiSelectionEnabled(false);
        jf.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        if(JFileChooser.APPROVE_OPTION == jf.showOpenDialog(this)){
            File dir= jf.getSelectedFile();
            File[] dirs = dir.listFiles();

            Map<String,Double> scores=new HashMap();
            Map<String,Double> scoresOcistene=new HashMap();
            int total=0;
            int totalMatches=0;
            int ocisteneCelkem=0;
            for(File kind:dirs){
                if(kind.isDirectory()){
                    String id = kind.getName().toLowerCase();
                    int matches=0;
                    int ocistene=0;
                    for(File imgFile:kind.listFiles()){
                        try {
                            final Image img = ImageIO.read(imgFile);
                            final ImageMLData input = new ImageMLData(img);
                            input.downsample(this.downsample, false, this.downsampleHeight,
                                            this.downsampleWidth, 1, 0); 
                            final MLData output = this.network.compute(input);
                            int winner = EngineArray.maxIndex(output.getData());
                            if(identity2neuron.get(id)==winner){
                                matches++;
                            }else{
                                String name=imgFile.getName();
                                System.out.println("File: "+ name +" detected:"+neuron2identity.get(winner)
                                        +" expected: "+id);
                                System.out.print("Values: ");
                                for(int n:neuron2identity.keySet()){
                                    System.out.print(" "+neuron2identity.get(n)+" = "+Format.formatDouble(output.getData(n), 4));
                                }
                                System.out.println("");
                                int i=name.indexOf("img");
                                if(name.substring(0, i).contains(id+"_")){
                                    ocistene++;
                                }
                            }
                        } catch (IOException ex) {
                            Logger.getLogger(TestFrameE3.class.getName()).log(Level.SEVERE, null, ex);
                        }
                    }
                    ocisteneCelkem+=ocistene;
                    total+=kind.listFiles().length;
                    totalMatches+=matches;
                    scores.put(id, ((double)matches)/(double)kind.listFiles().length);
                    scoresOcistene.put(id, ((double)matches+ocistene)/(double)kind.listFiles().length);
                }
            }
            StringBuilder sb= new StringBuilder();
            sb.append("Succesfuly detected - strictly ").append(Format.formatPercent(totalMatches/(double)total)).append(":\n");
            for(String id:scores.keySet()){
                sb.append(id).append(": ").append(Format.formatPercent(scores.get(id))).append("\n");
            }
            sb.append("Succesfuly detected - loosely ").append(Format.formatPercent((totalMatches+ocisteneCelkem)/(double)total)).append(":\n");
            for(String id:scores.keySet()){
                sb.append(id).append(": ").append(Format.formatPercent(scoresOcistene.get(id))).append("\n");
            }
            System.out.println(sb.toString());
            
        }
    }//GEN-LAST:event_testButtonActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(TestFrameE3.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(TestFrameE3.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(TestFrameE3.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(TestFrameE3.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new TestFrameE3().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JButton checkButton;
    private javax.swing.JButton createNetworkButton;
    private javax.swing.JSpinner hiden1Spinner;
    private javax.swing.JSpinner hiden2Spinner;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JSpinner jSpinner1;
    private javax.swing.JButton loadButton;
    private javax.swing.JButton saveButton;
    private javax.swing.JButton stopButton;
    private javax.swing.JButton testButton;
    private javax.swing.JButton trainButton;
    // End of variables declaration//GEN-END:variables
}
