⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kohonen_units.java

📁 som 算法实现。在别的网站上下载的
💻 JAVA
字号:
package dm.clustering.KNN;

import java.util.Random;

public class Kohonen_units {

	 /**输入矢量的维数.*/
	int number_of_inputs;
	/**输出神经元节点个数.*/
	int number_of_outputs;
	
	double[] input_weight_vector;
	double[] input_value;
	double[] output_value;
	  
	double transfer_function_width;                 // RBFN
	double Gaussian_transfer_output;                // RBFN
	  
	Kohonen_units(){
	    number_of_outputs = 1;
	}
	
	void establish_input_output_arrays(){
	  input_value = new double[number_of_inputs];
	  output_value = new double[number_of_outputs];
	}
	
	void establish_input_weight_vector_array(){
		input_weight_vector = new double[number_of_inputs];
	}
	
	void initialize_inputs_and_weights(){
      Random random = new Random();
	  for(int k = 0; k < number_of_inputs; k++){		  
		  input_weight_vector[k] = random.nextDouble();
		  
		  System.out.println("input_weight_vetor["+k+"]="+input_weight_vector[k]);
	  }
	}
	
	void calculate_sum_square_Euclidean_distance(){
	  double sumsquare;
	  double ss1;
	  int ci;
	  output_value[0] = 0.0;
	  for(int k = 0; k < number_of_inputs; k++){
	    ci = k;

	    if(input_value[ci] == 0.0){
	      sumsquare = Math.pow(input_weight_vector[ci], 2.0);
	    }else{
	      sumsquare = Math.pow(Math.abs(input_weight_vector[ci] - input_value[ci]), 2.0);
	    }
	    output_value[0] += sumsquare;
	  }
	  ss1 = output_value[0];
	  output_value[0] = Math.sqrt(Math.abs(ss1));
	}
	
	void update_the_weights(double learning_rate){
	  for(int k = 0; k < number_of_inputs; k++){
		  input_weight_vector[k] = input_weight_vector[k] + (learning_rate * (input_value[k] - input_weight_vector[k]));
	  }
	}
	
    //RBFN //
	void execute_Gaussian_transfer_function(){
	  double transfer_ratio = (-1.0) * Math.pow((output_value[0] / transfer_function_width), 2.0);
	  Gaussian_transfer_output = Math.exp(transfer_ratio);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -