• PUDN用户
    了解作者
  • Java
    开发工具
  • 2KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 7
    下载次数
  • 2010-04-17 06:41
    上传日期
Neural Network with data example for iris flower classification
neuralNetwork.java.zip
  • neuralNetwork.java
    10.6KB
内容介绍
package neuron; public class neuralNetwork { //4 input neurons //4 intern neurons //1 output neuron static float[][] inputTrainVersicolor = new float[][]{ {7.0f, 3.2f, 4.7f, 1.4f},//versicolor {6.4f, 3.2f, 4.5f, 1.5f},//versicolor {6.9f, 3.1f, 4.9f, 1.5f},//versicolor {5.5f, 2.3f, 4.0f, 1.3f},//versicolor {6.5f, 2.8f, 4.6f, 1.5f},//versicolor {5.7f, 2.8f, 4.5f, 1.3f},//versicolor {6.3f, 3.3f, 4.7f, 1.6f},//versicolor {4.9f, 2.4f, 3.3f, 1.0f},//versicolor {6.6f, 2.9f, 4.6f, 1.3f},//versicolor {5.2f, 2.7f, 3.9f, 1.4f},//versicolor {5.0f, 2.0f, 3.5f, 1.0f},//versicolor {5.9f, 3.0f, 4.2f, 1.5f},//versicolor {6.0f, 2.2f, 4.0f, 1.0f},//versicolor {6.1f, 2.9f, 4.7f, 1.4f},//versicolor {5.6f, 2.9f, 3.6f, 1.3f},//versicolor {6.7f, 3.1f, 4.4f, 1.4f},//versicolor {5.6f, 3.0f, 4.5f, 1.5f},//versicolor {5.8f, 2.7f, 4.1f, 1.0f},//versicolor {6.2f, 2.2f, 4.5f, 1.5f},//versicolor {5.6f, 2.5f, 3.9f, 1.1f},//versicolor {5.9f, 3.2f, 4.8f, 1.8f},//versicolor {6.1f, 2.8f, 4.0f, 1.3f},//versicolor {6.3f, 2.5f, 4.9f, 1.5f},//versicolor {6.1f, 2.8f, 4.7f, 1.2f},//versicolor {6.4f, 2.9f, 4.3f, 1.3f}//versicolor }; static float[][] inputTrainVirginica = new float[][]{ {6.3f, 3.3f, 6.0f, 2.5f},//virginica {5.8f, 2.7f, 5.1f, 1.9f},//virginica {7.1f, 3.0f, 5.9f, 2.1f},//virginica {6.3f, 2.9f, 5.6f, 1.8f},//virginica {6.5f, 3.0f, 5.8f, 2.2f},//virginica {7.6f, 3.0f, 6.6f, 2.1f},//virginica {4.9f, 2.5f, 4.5f, 1.7f},//virginica {7.3f, 2.9f, 6.3f, 1.8f},//virginica {6.7f, 2.5f, 5.8f, 1.8f},//virginica {7.2f, 3.6f, 6.1f, 2.5f},//virginica {6.5f, 3.2f, 5.1f, 2.0f},//virginica {6.4f, 2.7f, 5.3f, 1.9f},//virginica {6.8f, 3.0f, 5.5f, 2.1f},//virginica {5.7f, 2.5f, 5.0f, 2.0f},//virginica {5.8f, 2.8f, 5.1f, 2.4f},//virginica {6.4f, 3.2f, 5.3f, 2.3f},//virginica {6.5f, 3.0f, 5.5f, 1.8f},//virginica {7.7f, 3.8f, 6.7f, 2.2f},//virginica {7.7f, 2.6f, 6.9f, 2.3f},//virginica {6.0f, 2.2f, 5.0f, 1.5f},//virginica {6.9f, 3.2f, 5.7f, 2.3f},//virginica {5.6f, 2.8f, 4.9f, 2.0f},//virginica {7.7f, 2.8f, 6.7f, 2.0f},//virginica {6.3f, 2.7f, 4.9f, 1.8f},//virginica {6.7f, 3.3f, 5.7f, 2.1f}//virginica }; static float[][] inputTrainSetosa = new float[][]{ {5.1f, 3.5f, 1.4f, 0.2f},//setosa {4.9f, 3.0f, 1.4f, 0.2f},//setosa {4.7f, 3.2f, 1.3f, 0.2f},//setosa {4.6f, 3.1f, 1.5f, 0.2f},//setosa {5.0f, 3.6f, 1.4f, 0.2f},//setosa {5.4f, 3.9f, 1.7f, 0.4f},//setosa {4.6f, 3.4f, 1.4f, 0.3f},//setosa {5.0f, 3.4f, 1.5f, 0.2f},//setosa {4.4f, 2.9f, 1.4f, 0.2f},//setosa {4.9f, 3.1f, 1.5f, 0.1f},//setosa {5.4f, 3.7f, 1.5f, 0.2f},//setosa {4.8f, 3.4f, 1.6f, 0.2f},//setosa {4.8f, 3.0f, 1.4f, 0.1f},//setosa {4.3f, 3.0f, 1.1f, 0.1f},//setosa {5.8f, 4.0f, 1.2f, 0.2f},//setosa {5.7f, 4.4f, 1.5f, 0.4f},//setosa {5.4f, 3.9f, 1.3f, 0.4f},//setosa {5.1f, 3.5f, 1.4f, 0.3f},//setosa {5.7f, 3.8f, 1.7f, 0.3f},//setosa {5.1f, 3.8f, 1.5f, 0.3f},//setosa {5.4f, 3.4f, 1.7f, 0.2f},//setosa {5.1f, 3.7f, 1.5f, 0.4f},//setosa {4.6f, 3.6f, 1.0f, 0.2f},//setosa {5.1f, 3.3f, 1.7f, 0.5f},//setosa {4.8f, 3.4f, 1.9f, 0.2f}//setosa }; static float[][] inputValidVersicolor = new float[][]{ {6.6f, 3.0f, 4.4f, 1.4f},//versicolor {6.8f, 2.8f, 4.8f, 1.4f},//versicolor {6.7f, 3.0f, 5.0f, 1.7f},//versicolor {6.0f, 2.9f, 4.5f, 1.5f},//versicolor {5.7f, 2.6f, 3.5f, 1.0f},//versicolor {5.5f, 2.4f, 3.8f, 1.1f},//versicolor {5.5f, 2.4f, 3.7f, 1.0f},//versicolor {5.8f, 2.7f, 3.9f, 1.2f},//versicolor {6.0f, 2.7f, 5.1f, 1.6f},//versicolor {5.4f, 3.0f, 4.5f, 1.5f},//versicolor {6.0f, 3.4f, 4.5f, 1.6f},//versicolor {6.7f, 3.1f, 4.7f, 1.5f},//versicolor {6.3f, 2.3f, 4.4f, 1.3f},//versicolor {5.6f, 3.0f, 4.1f, 1.3f},//versicolor {5.5f, 2.5f, 4.0f, 1.3f},//versicolor {5.5f, 2.6f, 4.4f, 1.2f},//versicolor {6.1f, 3.0f, 4.6f, 1.4f},//versicolor {5.8f, 2.6f, 4.0f, 1.2f},//versicolor {5.0f, 2.3f, 3.3f, 1.0f},//versicolor {5.6f, 2.7f, 4.2f, 1.3f},//versicolor {5.7f, 3.0f, 4.2f, 1.2f},//versicolor {5.7f, 2.9f, 4.2f, 1.3f},//versicolor {6.2f, 2.9f, 4.3f, 1.3f},//versicolor {5.1f, 2.5f, 3.0f, 1.1f},//versicolor {5.7f, 2.8f, 4.1f, 1.3f}//versicolor }; static float[][] inputValidVirginica = new float[][]{ {7.2f, 3.2f, 6.0f, 1.8f},//virginica {6.2f, 2.8f, 4.8f, 1.8f},//virginica {6.1f, 3.0f, 4.9f, 1.8f},//virginica {6.4f, 2.8f, 5.6f, 2.1f},//virginica {7.2f, 3.0f, 5.8f, 1.6f},//virginica {7.4f, 2.8f, 6.1f, 1.9f},//virginica {7.9f, 3.8f, 6.4f, 2.0f},//virginica {6.4f, 2.8f, 5.6f, 2.2f},//virginica {6.3f, 2.8f, 5.1f, 1.5f},//virginica {6.1f, 2.6f, 5.6f, 1.4f},//virginica {7.7f, 3.0f, 6.1f, 2.3f},//virginica {6.3f, 3.4f, 5.6f, 2.4f},//virginica {6.4f, 3.1f, 5.5f, 1.8f},//virginica {6.0f, 3.0f, 4.8f, 1.8f},//virginica {6.9f, 3.1f, 5.4f, 2.1f},//virginica {6.7f, 3.1f, 5.6f, 2.4f},//virginica {6.9f, 3.1f, 5.1f, 2.3f},//virginica {5.8f, 2.7f, 5.1f, 1.9f},//virginica {6.8f, 3.2f, 5.9f, 2.3f},//virginica {6.7f, 3.3f, 5.7f, 2.5f},//virginica {6.7f, 3.0f, 5.2f, 2.3f},//virginica {6.3f, 2.5f, 5.0f, 1.9f},//virginica {6.5f, 3.0f, 5.2f, 2.0f},//virginica {6.2f, 3.4f, 5.4f, 2.3f},//virginica {5.9f, 3.0f, 5.1f, 1.8f},//virginica }; static float[][] inputValidSetosa = new float[][]{ {5.0f, 3.0f, 1.6f, 0.2f},//setosa {5.0f, 3.4f, 1.6f, 0.4f},//setosa {5.2f, 3.5f, 1.5f, 0.2f},//setosa {5.2f, 3.4f, 1.4f, 0.2f},//setosa {4.7f, 3.2f, 1.6f, 0.2f},//setosa {4.8f, 3.1f, 1.6f, 0.2f},//setosa {5.4f, 3.4f, 1.5f, 0.4f},//setosa {5.2f, 4.1f, 1.5f, 0.1f},//setosa {5.5f, 4.2f, 1.4f, 0.2f},//setosa {4.9f, 3.1f, 1.5f, 0.2f},//setosa {5.0f, 3.2f, 1.2f, 0.2f},//setosa {5.5f, 3.5f, 1.3f, 0.2f},//setosa {4.9f, 3.6f, 1.4f, 0.1f},//setosa {4.4f, 3.0f, 1.3f, 0.2f},//setosa {5.1f, 3.4f, 1.5f, 0.2f},//setosa {5.0f, 3.5f, 1.3f, 0.3f},//setosa {4.5f, 2.3f, 1.3f, 0.3f},//setosa {4.4f, 3.2f, 1.3f, 0.2f},//setosa {5.0f, 3.5f, 1.6f, 0.6f},//setosa {5.1f, 3.8f, 1.9f, 0.4f},//setosa {4.8f, 3.0f, 1.4f, 0.3f},//setosa {5.1f, 3.8f, 1.6f, 0.2f},//setosa {4.6f, 3.2f, 1.4f, 0.2f},//setosa {5.3f, 3.7f, 1.5f, 0.2f},//setosa {5.0f, 3.3f, 1.4f, 0.2f}//setosa }; final static int IN_SIZE = 6; final static int INPUT_SIZE = 4; final static int OUT_SIZE = 3; static float[][] weightsIn = new float[INPUT_SIZE][IN_SIZE]; static float[][] weights = new float[IN_SIZE][OUT_SIZE]; static float[] outIn = new float[IN_SIZE]; static float rate = 0.05f; public static void changeWeight(float[] output, float[] desiredOut, float[] input){ for(int i = 0; i< weights.length; i++){ for(int j = 0; j< weights[0].length; j++){ weights[i][j] = weights[i][j]+(rate*deltaO[j]*outIn[i]); } } } public static void changeWeightIn(float[] input){ for(int i = 0; i< weightsIn.length; i++){ for(int j = 0; j< weightsIn[0].length; j++){ weightsIn[i][j] = weightsIn[i][j]+(rate*(deltas[j]*input[i])); } } } public static float[] normalize(float[] origin){ float[] norm = new float[origin.length]; float sum = 0.0f; for(int i = 0; i<origin.length; i++) sum+=origin[i]; for(int i = 0; i<origin.length; i++) norm[i] = origin[i]/sum; return norm; } static float error = 1.0f; public static void main(String[] args){ //Versicolor & Setosa System.out.println("Setosa & Versicolor & Virginica"); for(int i = 0; i< weights.length; i++){ for(int j = 0; j< weights[0].length; j++){ weights[i][j]=(float)Math.random(); } } for(int i = 0; i< weightsIn.length; i++){ for(int j = 0; j< weightsIn[0].length; j++){ weightsIn[i][j]=(float)Math.random(); } } float[] outVersicolor = new float[]{0.9f,0.1f,0.1f}; float[] outSetosa = new float[]{0.1f,0.9f,0.1f}; float[] outVirginica = new float[
评论
    相关推荐
    • Wall.Flower.rar
      Background maintenance is a frequent element of video surveillance systems. We develop Wallflower, a three-component system for background maintenance
    • Flower_Classifier.zip
      DEEP LEARNING FOR CLASSIFICATION FLOWERS
    • simple-iris-flower-classification-ML-
      鸢尾花数据集的数据分类和可视化。 使用KNN进行模型训练以预测未来的样本。
    • fgvcx_flower_comp
      2018 FGVCx花卉分类挑战赛 2018年竞赛是的一部分。 我们的赞助商和已经提供了经过精心策划的数据库的数据集,其中包含来自997种花卉的669,000幅带注释的花卉图像。 如果您对数据集有疑问或问题,请打开一个问题。...
    • iris_flower_classification
      iris_flower_classification 这是一个简单的分类模型,可使用KNN对从sklearn加载的虹膜数据集中的数据进行分类
    • Iris-flower-classification
      鸢尾花分类 我已经从获得了这个项目 在这里,我们将尝试所有算法。 我们不知道哪种算法是最好的,并且精度很高。 看完所有算法的准确性得分后,我们看到SVM具有很高的准确性,因此我们将在模型中使用该算法。
    • Iris-Flower-Classification-Web-App
      鸢尾花分类Web应用程序 如何在本地计算机上运行 克隆存储库 在克隆的存储库内部,从终端运行“ npm install”(您应该具有node.js CLI) 从终端运行命令“ npm start” 在浏览器上转到 (尽管第3步后它将在默认...
    • flower-classification-master.zip
      花分类 使用mobilenet v2对102种花朵进行分类并进行转移学习。 使用Costom数据集对花朵图像进行分类 下载资料 在该项目中,使用了 。 您可以下载和。 数据集为tar文件形式,一旦提取,所有图像均位于jpg文件夹内。...
    • Iris_Flower_Classification_Model_Deployment:使用Flask- Iris花卉分类器的机
      Iris_Flower_Classification_Model_Deployment 使用Flask- Iris Flower分类器在网站上进行机器学习模型部署