clear all;
clc;
%% 数据导入
iris_data=csvread("iris_dataset.csv");
%% 数据预处理
nums_train=70;
nums_test=30;
Dimension=5;
[train_set,test_set]=split(iris_data, nums_train, nums_test);
training_x = train_set(:,1:4)';
training_y = train_set(:,5)';
testing_x = test_set(:,1:4)';
testing_y = test_set(:,5)';
%% 神经网络初始化
%参数设置
Net_Scale = [4 5 1];
step = 0.01;
nums_iteration = 200;
%偏置添加 & 初始化
global Neural_Net_layer_1;
global Neural_Net_layer_2;
Neural_Net_layer_1 = rand([Net_Scale(2) Net_Scale(1)]+[0 1]);
Neural_Net_layer_2 = rand([Net_Scale(3) Net_Scale(2)]+[0 1]);
%% 神经网络训练
train_neural_net(training_x,training_y,step, nums_iteration);
%% 神经网络评价
error = 0.02;
accuracy = test_neural_net(testing_x,testing_y,error);
fprintf("the accuracy is %.1f\n%",100*accuracy);
神经网络训练
function []= train_neur