Skip to content
Snippets Groups Projects
Commit 7f68d353 authored by David Lanzendörfer's avatar David Lanzendörfer
Browse files

Add training for RNN during backprop

parent 0fa5860d
No related branches found
No related tags found
No related merge requests found
...@@ -101,7 +101,7 @@ module neuron #( ...@@ -101,7 +101,7 @@ module neuron #(
else else
if(!backprop_done && backprop_running) if(!backprop_done && backprop_running)
begin begin
// Adjust normal weights
if( regidx < NUMBER_SYNAPSES ) if( regidx < NUMBER_SYNAPSES )
begin begin
if(backprop_in_port_store[regidx] && neuron_output) begin if(backprop_in_port_store[regidx] && neuron_output) begin
...@@ -113,15 +113,26 @@ module neuron #( ...@@ -113,15 +113,26 @@ module neuron #(
end end
regidx <= regidx+1; regidx <= regidx+1;
end end
// Adjust RNN weights
else if( regidx == NUMBER_SYNAPSES ) else if( regidx < NUM_WEIGHTS )
begin
if(rnn_inputs[regidx] && neuron_output) begin
RNNW[regidx-NUMBER_SYNAPSES] <= $signed(RNNW[regidx-NUMBER_SYNAPSES]) - $signed(dw);
end
else
if(rnn_inputs[regidx] && !neuron_output) begin
RNNW[regidx-NUMBER_SYNAPSES] <= $signed(RNNW[regidx-NUMBER_SYNAPSES]) + $signed(dw);
end
regidx <= regidx+1;
end
// Reset the redister index counter
else if( regidx == NUM_WEIGHTS )
begin begin
//$display("Backprop done"); //$display("Backprop done");
backprop_done <= 1; backprop_done <= 1;
backprop_running <= 0; backprop_running <= 0;
regidx <= 0; regidx <= 0;
end end
end end
else else
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment