【问题标题】:Test accuracy decrease during training iteration训练迭代期间测试准确度下降
【发布时间】:2017-08-10 07:04:34
【问题描述】:

在我的神经网络模型中,测试精度在迭代中下降。我检查了学习率并将其调小了,但我的测试准确度一直在下降但没有波动,所以我认为这不是问题的原因。

我使用 tempotron 学习规则,并处理 Iris 数据集,我使用了 100 个训练样本和 50 个测试样本。

我检查了我的代码,一开始测试准确率有所提高,所以我认为学习规则确实对权重起作用。

但我无法弄清楚为什么在那之后性能下降。 有人可以有任何想法吗? 谢谢。

testing accuracy

for Iterate = 1:iteration  %% Run 100 times

  %% Test the correct rate each time

正确 = 0; 对于 test_sample = 1:length(test)

   % In each iteration, T = 100ms

    for t = 1:T                

        for neuron = 1:neurons %% Response function for 48 neurons at time t

                 Response(neuron) = K(t,test(test_sample,neuron));              

        end

        % Calculate PSP

        for j = 1:3                

           V(j,t) = Response*weight(:,j) + V_rest;            

        end           

    end         

    %% find t_max: first index that V cross threshold

    for j = 1:3

        for timing = 1:T

            if V(j,timing) >= threshold

                t_max(j) = timing;

                Max_state(j) = V(j,timing);

                break;

            end

        end     

       V(j,t_max(j):end) = V(j,t_max(j)).*exp(-(Time(t_max(j):end)-Time(t_max(j)))/Tou_m);

    end

    [~,output_class] = min(t_max); 

    if output_class == test_target(test_sample)

        correct = correct + 1;

    end

结束

正确率(迭代)=正确/(长度(测试));

如果迭代 > 1

 if correct_rate(Iterate) < correct_rate(Iterate-1)

     fprintf('Correct rate decrease\n');

     %break;

 end

结束

%% 训练

for samples = 1:size(InputSpike,1)  %% Training samples for each iteration 

    % In each iteration, T = 100ms

    for t = 1:T                  

        for neuron = 1:neurons %% Response function for 48 neurons at time t

            Response(neuron) = K(t,InputSpike(samples,neuron));              

        end       

        % Calculate PSP

        for j = 1:3                

           V(j,t) = Response*weight(:,j) + V_rest;            

        end

    end           

    %% find t_max: first index that V cross threshold

    for j = 1:3

        for timing = 1:T

            if V(j,timing) >= threshold

                t_max(j) = timing;

                Max_state(j) = V(j,timing);

                break;

            end

        end        

       V(j,t_max(j):end) = V(j,t_max(j)).*exp(-(Time(t_max(j):end)-
Time(t_max(j)))/Tou_m);

end

    [~,output_class] = min(t_max);

    %% weight modify when error occurs       

    if train_target(samples) ~= output_class        

        for j = 1:3               

            if j == train_target(samples) %% error in target neuron

                if Max_state(j) < threshold %% if P+ error occurs

                    for i = 1:neurons

                        %% for all t_i < t_max

                        if InputSpike(samples,i) < t_max(j) 

                            %% weight modified

                            weight(i,j) = weight(i,j) + ...
                                lr*K(t_max(j),InputSpike(samples,i));

                        end

                    end

                end

            elseif j ~= train_target(samples) %% error on other 2 output neurons  

               if Max_state(j) >= threshold %% if P- error occurs

                   for i = 1:neurons

                        %% for all t_i < t_max

                        if InputSpike(samples,i) < t_max(j) 

                            %% weight modified

                            weight(i,j) = weight(i,j) - ...
                                lr*K(t_max(j),InputSpike(samples,i));

                        end

                   end

               end

            end 

        end     

    %% for neurons that fired but weaker than target neuron     

    elseif train_target(samples) == output_class

        for j = 1:3

            if j ~= train_target(samples) %% other 2 output neurons

                if Max_state(j) >= threshold

                   for i = 1:neurons %% P- error occurs

                        %% for all t_i < t_max

                        if InputSpike(samples,i) < t_max(j) 

                            %% weight modified

                            weight(i,j) = weight(i,j) - ...
                                lr*K(t_max(j),InputSpike(samples,i));

                        end 

                   end

                end

            end

        end

    end         

end    

结束

【问题讨论】:

  • 你听说过过拟合吗?此问题中也没有代码,因此不适合 SO。
  • 对不起,我附上了我的代码。如果是过拟合问题怎么办?
  • 为了尽量减少过度拟合,您应该从较少的隐藏单元(例如 1 或 2)开始,然后增加它们,直到测试集的性能开始下降。

标签: machine-learning neural-network biological-neural-network


【解决方案1】:

您应该扩大训练数据集以避免过度拟合。你也可以尝试增加你的训练周期。

【讨论】:

    猜你喜欢
    • 2021-03-25
    • 1970-01-01
    • 2017-10-09
    • 1970-01-01
    • 1970-01-01
    • 2018-10-08
    • 2020-11-06
    • 2020-12-03
    • 1970-01-01
    相关资源
    最近更新 更多