public void makeGraph(File linkGraph) throws Exception {
  String temp212;
  int rowNum=0;
  BufferedReader br=new BufferedReader(new InputStreamReader(new FileInputStream(linkGraph)));
  while ((temp212=br.readLine()) != null) {
    String[] strs=temp212.split(" ");
    for (int i=0; i < strs.length; i++) {
      graph[rowNum][i]=Double.parseDouble(strs[i]);
    }
    rowNum++;
  }
  for (int i=0; i < dataNum; i++) {
    for (int j=0; j < dimension; j++) {
      W[i][j]=r.nextDouble();
      H[j][i]=r.nextDouble();
    }
  }
  for (int i=0; i < dataNum; i++) {
    double sumW=0;
    double sumH=0;
    for (int j=0; j < dimension; j++) {
      sumW+=W[i][j] * W[i][j];
      sumH+=H[j][i] * H[j][i];
    }
    sumW=Math.sqrt(sumW);
    sumH=Math.sqrt(sumH);
    for (int j=0; j < dimension; j++) {
      W[i][j]/=sumW;
      H[j][i]/=sumH;
    }
  }
  trainW();
  init=false;
}

public void makeGraph ( File linkGraph ) throws Exception { String temp212 ; int rowNum = 0 ; BufferedReader br = new BufferedReader ( new InputStreamReader ( new FileInputStream ( linkGraph ) ) ) ; while ( ( temp212 = br . readLine ( ) ) != null ) { String [ ] strs = temp212 . split ( " " ) ; for ( int i = 0 ; i < strs . length ; i ++ ) { graph [ rowNum ] [ i ] = Double . parseDouble ( strs [ i ] ) ; } rowNum ++ ; } for ( int i = 0 ; i < dataNum ; i ++ ) { for ( int j = 0 ; j < dimension ; j ++ ) { W [ i ] [ j ] = r . nextDouble ( ) ; H [ j ] [ i ] = r . nextDouble ( ) ; } } for ( int i = 0 ; i < dataNum ; i ++ ) { double sumW = 0 ; double sumH = 0 ; for ( int j = 0 ; j < dimension ; j ++ ) { sumW += W [ i ] [ j ] * W [ i ] [ j ] ; sumH += H [ j ] [ i ] * H [ j ] [ i ] ; } sumW = Math . sqrt ( sumW ) ; sumH = Math . sqrt ( sumH ) ; for ( int j = 0 ; j < dimension ; j ++ ) { W [ i ] [ j ] /= sumW ; H [ j ] [ i ] /= sumH ; } } trainW ( ) ; init = false ; }
read in the normalized category file .
