Hebb or perceptron nets can be used to classify two-dimensional input patterns (
ID: 3598572 • Letter: H
Question
Hebb or perceptron nets can be used to classify two-dimensional input patterns (representing letters). For example, consider the following pattern:s and HH . . To treat this example as a pattern classification problem with one output class, we will designate that class "E" and take the pattern "F" to be an example of output that is not "E" The first thing we need to do is to convert the patterns to input vectors. That is easy to do by assigning each"#" the value l and each "." the value-1. To convert fromthe two- dimensional pattern to an input vector, we simply concatenate the rows, i.e., the second row of the pattern comes after the first row, and the third row follows etc. Pattern 1 then becomes Where a comma denotes the termination of a line of the original matrix. 1. Train a Hebb net to classify these two patterns 2. Repeat part one for a perceptron netExplanation / Answer
/* No Language is mention to implement the Algo..
If any thing is missed please comment and let me know */
import java.util.Scanner;
/*
Scanner class is use to take the input
*/
class Hebb{
public static void main(String s[]){
Scanner sc = new Scanner(System.in);
String pattern="";
System.out.println("Press q to exit the loop other wise enter the pattern # OR .");
/* below while loop is used to read the line
if q is in the input it will break the loop
*/
while(sc.hasNext()){
String name = sc.nextLine();
/* read character by character to make the pattern */
for(char x : name.toCharArray())
{
//System.out.println(x+" ");
if(x == '#')
pattern +="1";
if(x == '.')
pattern +="-1";
}
if(name.equals("q")){
break;// break the while loop
}
pattern +=", ";
}
System.out.println(pattern);
} // end main function
}// end class
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.