daily pastebin goal
19%
SHARE
TWEET

Untitled

a guest Mar 25th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Arrays;
  2.  
  3. import org.neuroph.core.data.DataSet;
  4. import org.neuroph.core.data.DataSetRow;
  5. import org.neuroph.nnet.MultiLayerPerceptron;
  6. import org.neuroph.nnet.learning.MomentumBackpropagation;
  7. import org.neuroph.util.TransferFunctionType;
  8.  
  9. public class CodeOR {
  10.  
  11.     public static void main(String[] args) {
  12.         // TODO Auto-generated method stub
  13.        
  14.         //3.KREIRANJE TRAINING SETA
  15.         DataSet trainigSet= DataSet.createFromFile("C:\\Users\\korisnik\\Desktop\\OR.txt",2, 1, "\t");
  16.        
  17.         //4. KREIRANJE VNM
  18.         MultiLayerPerceptron vnm_mlp_or = new MultiLayerPerceptron(TransferFunctionType.SIGMOID, 2,3,1);
  19.        
  20.         //5. OBUCAVANJE VNM
  21.         MomentumBackpropagation obucavanje= new MomentumBackpropagation();
  22.        
  23.         obucavanje.setMaxError(0.001);
  24.         obucavanje.setMaxIterations(5000);
  25.         obucavanje.setLearningRate(0.1);
  26.         obucavanje.setMomentum(0.7);
  27.        
  28.         vnm_mlp_or.learn(trainigSet, obucavanje);
  29.        
  30.         //6. TESTIRANJE
  31.        
  32.         vnm_mlp_or.setInput(1.0,1.0);
  33.         vnm_mlp_or.calculate();
  34.         System.out.println("Za ulazne vrednosti 1 i 1, izlaz je "+ Arrays.toString(vnm_mlp_or.getOutput()));
  35.         vnm_mlp_or.setInput(1.0,0.0);
  36.         vnm_mlp_or.calculate();
  37.         System.out.println("Za ulazne vrednosti 1 i 0, izlaz je "+ Arrays.toString(vnm_mlp_or.getOutput()));
  38.         vnm_mlp_or.setInput(0.0,1.0);
  39.         vnm_mlp_or.calculate();
  40.         System.out.println("Za ulazne vrednosti 0 i 1, izlaz je "+ Arrays.toString(vnm_mlp_or.getOutput()));
  41.         vnm_mlp_or.setInput(0.0,0.0);
  42.         vnm_mlp_or.calculate();
  43.         System.out.println("Za ulazne vrednosti 0 i 0, izlaz je "+ vnm_mlp_or.getOutput()[0]);
  44.        
  45.     }
  46.  
  47. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top