title: Test accuracy decrease during training iteration
body: <p>In my neural network model, the test accuracy decrease in the iteration. I have check the learning rate and tune it smaller, but my test accuracy keep decreasing but not oscillating, so I think it is not the cause of the problem.</p>
  
  <p>I use tempotron learning rule, and work on Iris dataset, which I use 100 training samples and 50 testing samples.</p>
  
  <p>I have check my code, the test accuracy have increased at the beginning, so I think the learning rule do work on the weight.</p>
  
  <p>But I can't figure out why the performance decrease after that.
  Can someone have any ideas?
  Thanks.</p>
  
  <p><a href="https://i.stack.imgur.com/u5zBv.png" rel="nofollow noreferrer">testing accuracy</a></p>
  
  <pre><code>for Iterate = 1:iteration  %% Run 100 times
  
    %% Test the correct rate each time
  </code></pre>
  
  <p>correct = 0;
     for test_sample = 1:length(test)</p>
  
  <pre><code>   % 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) &gt;= 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
  </code></pre>
  
  <p>end</p>
  
  <p>correct_rate(Iterate) = correct/(length(test));</p>
  
  <p>if Iterate > 1</p>
  
  <pre><code> if correct_rate(Iterate) &lt; correct_rate(Iterate-1)
  
       fprintf('Correct rate decrease\n');
  
       %break;
  
   end
  </code></pre>
  
  <p>end</p>
  
  <p>%% Training</p>
  
  <pre><code>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) &gt;= 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) &lt; threshold %% if P+ error occurs
  
                      for i = 1:neurons
  
                          %% for all t_i &lt; t_max
  
                          if InputSpike(samples,i) &lt; 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) &gt;= threshold %% if P- error occurs
  
                     for i = 1:neurons
  
                          %% for all t_i &lt; t_max
  
                          if InputSpike(samples,i) &lt; 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) &gt;= threshold
  
                     for i = 1:neurons %% P- error occurs
  
                          %% for all t_i &lt; t_max
  
                          if InputSpike(samples,i) &lt; 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    
  </code></pre>
  
  <p>end</p>