하드웨어/Verilog-NN

Verilog-NN : Radial Basis Network, RBF

wareeasy 2023. 2. 9. 11:48
반응형

 

module RBFN(input x, output y);
  parameter N = 8; // number of basis functions
  parameter M = 2; // number of inputs
  parameter r = 1; // width of Gaussian function

  reg [N-1:0] w; // weights
  reg [M-1:0] mu; // centers of basis functions

  // Gaussian radial basis function
  assign y = exp(-r * (x - mu)**2);

  // Network architecture
  assign y = w * y;
endmodule​

 

https://towardsdatascience.com/the-mostly-complete-chart-of-neural-networks-explained-3fb6f2367464

 

The mostly complete chart of Neural Networks, explained

The zoo of neural network types grows exponentially. One needs a map to navigate between many emerging architectures and approaches.

towardsdatascience.com

 

module RBFNetwork(input clk,
                  input [2:0] inputs,
                  output reg [0:0] output);
  
  reg [1:0] hidden_neurons;
  reg [0:0] output_neuron;
  
  // center values for each hidden neuron
  parameter c0 = 0.3;
  parameter c1 = 0.7;
  
  // width values for each hidden neuron
  parameter w0 = 0.1;
  parameter w1 = 0.2;
  
  // weights for hidden layer to output
  parameter w2 = 0.5;
  parameter w3 = 0.7;
  
  always @(posedge clk) begin
    hidden_neurons[0] <= exp(-(inputs-c0)*(inputs-c0)/(2*w0*w0));
    hidden_neurons[1] <= exp(-(inputs-c1)*(inputs-c1)/(2*w1*w1));
    output_neuron <= hidden_neurons[0] * w2 + hidden_neurons[1] * w3;
  end
  
  assign output = output_neuron;
endmodule

 

 

 

 

 

 

반응형