/*
 This is a proprietary part of DataMelt package.
 License: the Creative Commons Attribution-Share Alike License; either version 3.0 of the License, 
 or any later version.
 http://creativecommons.org/licenses/by-sa/3.0/
 

Redistributions of the source code, or parts of the source codes, must retain the copyright notice, this list of conditions and the following disclaimer (all at the top of each source code) and requires the written permission from DataMelt.

Redistribution in binary form of all or parts of a class must reproduce the copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution and requires the written permission of ScaVis

Details about license agreement or commercial use are: http://jwork.org/scavis/ */ package jhpro.nnet; /** * The pattern file of a Backpropagation Net contains the input and target * patterns for the net. The patterns should contain ASCII characters that are * defined in the net's conversion file. The number of patterns can be changed * freely. * * The length of an input pattern must be the same as the number of neurons in * the net's input neuron layer. The length of a target pattern must be the same * as the number of neurons in the net's output neuron layer. * * * * The general structure of a pattern file is as follows: *

* * In the first line: * Number of patterns *

* In the second line: * Length of input patterns (same as number of neurons in input layer) *

* In the third line: * Length of target patterns (same as number of neurons in output layer) *

* Each following line: * The input pattern [whitespace] the target pattern * * @author Jochen Fröhlich and S.Chekanov * */ public class Pattern implements java.io.Serializable { public Pattern(String s, String as[][]) { patString = s; pat = new int[s.length() * as[0][1].length()]; String s1 = new String(); String s2 = new String(); for (int i = 0; i < s.length(); i++) { for (int j = 0; j < as.length; j++) { String s3 = String.valueOf(s.charAt(i)); if (s3.compareTo(" ") == 0) { s1 += as[0][1]; break; } if (s3.compareTo(as[j][0]) != 0) continue; s1 += as[j][1]; break; } } char ac[] = new char[s1.length()]; ac = s1.toCharArray(); for (int k = 0; k < pat.length; k++) pat[k] = Character.digit(ac[k], 10); } public String getPatternString() { return patString; } public float getValue(int i) { return (float) pat[i]; } public int size() { return pat.length; } public boolean checkValues() { for (int i = 0; i < pat.length; i++) if (pat[i] < 0 || pat[i] > 1) return false; return true; } int pat[]; int nr; String type; String patString; }

Ads help maintain this website.