<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Hardware Implementation of the Softmax Function on FPGA</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Francesco Di Franco</string-name>
          <email>f.difranco@vicosystems.it</email>
          <xref ref-type="aff" rid="aff1">1</xref>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Corrado Rametta</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Michele Russo</string-name>
          <email>m.russo@vicosystems.it</email>
          <xref ref-type="aff" rid="aff1">1</xref>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Mario Vaccaro</string-name>
          <email>m.vaccaro@vicosystems.it</email>
          <xref ref-type="aff" rid="aff1">1</xref>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Softmax</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Deep Learning</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>FPGA.</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Department of Computer, Control, and Management Engineering, Sapienza University of Rome</institution>
          ,
          <addr-line>Via Ariosto 25, Roma</addr-line>
          ,
          <country country="IT">Italy</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Informatics, Mathematics, and Engineering</institution>
          ,
          <addr-line>Online</addr-line>
        </aff>
        <aff id="aff2">
          <label>2</label>
          <institution>VICOSYSTEMS S.r.l V.le Odorico da Pordenone</institution>
          ,
          <addr-line>33, Catania, CT</addr-line>
          ,
          <country country="IT">Italy</country>
        </aff>
      </contrib-group>
      <fpage>21</fpage>
      <lpage>25</lpage>
      <abstract>
        <p>The softmax operation is used in the last layer of deep learning classifiers. This function is characterized by complex arithmetic operations as exponentials and divisions. In hardware implementations, such complexity negatively impacts on hardware resources. In this paper, we present an eficient hardware implementation of the softmax function. The proposed architecture has been designed and simulated in Simulink, coded in VHDL, and finally synthesized using the Xilinx Vivado toolchain. Implementation results are presented in terms of area and power.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>
        In the last few years, we assisted to a significant
increase in Machine Learning based applications and
re1. The availability of a great amount of data thanks
to internet difusion.
tems that makes possible the eficient parallel
computations as for example GPUs and FPGAs.
3. The introduction of new technologies that allow
the implementation of artificial neural networks
more and more similar to natural ones [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ].
      </p>
      <p>
        New technologies can range from sensors [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ], new
cellular systems [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ], satellite [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ] and critical services [
        <xref ref-type="bibr" rid="ref10 ref8 ref9">8,
9, 10</xref>
        ]. In all those machine learning systems
characterized by high-speed computations requirements,
hardware solutions are preferred to software solutions, such
as in the case of FIR filters [
        <xref ref-type="bibr" rid="ref11">11</xref>
        ], it is very important to
design hardware architectures optimized in terms of
complexity in order to reduce costs and power
consumption. In this scenario, the softmax function
represents an important issue.
      </p>
      <p>
        In Machine learning systems, the softmax [
        <xref ref-type="bibr" rid="ref12 ref13">12, 13</xref>
        ]
function finds its application in the output layer of
ICYRIME 2020: International Conference for Young Researchers in
      </p>
      <p>Vaccaro)
© 2020 Copyright for this paper by its authors. Use permitted under Creative
 ∶ ℝ
→</p>
      <p>∈ ℝ |  &gt; 0, ∑   = 1
 (z) =
{
  

∑ =1   

 =1
 = 1, … ,  .</p>
      <p>}</p>
      <p>As shown in eq. 2 the Softmax function replaces the
activation function of the output layer of the neural
network.</p>
      <p>( =  |x) =
 (</p>
      <p>w x+  )
∑ ∈ 
( 
w x+  )</p>
      <p>The block diagram of the softmax function is shown
in Fig. 1 and works as follows:
• The system accepts a k-dimensional vector "y"</p>
      <p>as input;
• The vector is input to a logic block that produces
k results, the result of the exponential function
of the input values. This result is input to two
logic blocks;
(1)
(2)
2. Softmax hardware
implementation
• The “summation” block compresses a k-dimensional Because the exponential relationship between the
vector into a numerical value equal to the sum number of the bit of the input and the location number
of the k values; of the Look-Up table used for the exponential function
computation, it is necessary to introduce a technique
• The last block divides each element produced by able to reduce the location number of the Look-Up
tathe exponential by the sum of the exponentials ble in order to not negatively impact on the hardware
themselves, producing a k-dimensional vector resources used for the implementation. For this
purcontaining the percentages. pose we use the linear interpolation.</p>
      <p>Let’s consider the function  ( ) =   we define the
function g as linear interpolation function in the
interval  0 &lt;  &lt;  0 + ℎ, with h defined as the interpolation
step. The function g is defined in eq. 3.</p>
      <p>The proposed architecture for the hardware softmax
implementation is shown in Fig. 2. It is composed of
three main blocks:
• Look Up tables for the exponential computation</p>
      <p>of e
• An adders tree for the summation computation
• Dividers for the division computation
 (,  0) =   0 +
 (,  0) =  ( 0) +  ⋅ ( ( 0 + ℎ) −  ( 0))</p>
      <p>−  0  −  0
 = =
 0 + ℎ −  0 ℎ
  0</p>
      <p>⋅ ( ℎ − 1) ⋅ ( −  0)
ℎ</p>
      <p>It is now possible to define the absolute error as
shown in eq. 4 and the relative error shown in eq. 5</p>
      <p>(3)
  (,  0) =  (,  0) −  ( ) =
  0
ℎ
=   0 +</p>
      <p>⋅ ( ℎ − 1) ⋅ ( −  0) −  
   (,  0) =
 
  0 = 1 +
 ℎ − 1</p>
      <p>ℎ
= 1 −   − 0 +
⋅ ( −  0) −
 ℎ − 1
ℎ


  0 =
⋅ ( −  0)</p>
      <p>Choosing h = 0.25 and = 0.125 it is possible to
obtain maximum relative errors less than 0.8% with rms
= 0.566% and less of 0.2% with rms = 0.14%.</p>
      <p>In fig. 2 is shown a comparison between the
exponential function and an interpolated exponential
function.</p>
      <p>In order to characterize the performance of the
proposed system in terms of maximum frequency,
hardexperiments on several implementations varying the
ware resources, and power consumption, we performed device.
range of the exponent and the size of the LUTs.</p>
      <p>As regards the range, simulations were carried out
with x in the range [-16; 15] and [-2; 1].</p>
      <p>The device used for our experiments is the Zynq
Ultrascale + ZCU 104, which allows you to manage the
input to 8.</p>
      <p>For x in the range [-15;15] we choose 5 bit for the
integer part and 11 bit for the fractional part. The linear
interpolation has been implemented with h=0.5.
Using this approach the total amount of locations is equal
(4)
to 64. The minimum relative error in terms of rms is
2.22%. The values stored in the Look-up table are in
the range [ −16 = 1.1254 ∗ 10−7;  15.5 = 5.3897 ∗ 10−6].</p>
      <p>For x in the range [-2;1] we choose 2 bit for the
integer part and 7 for the fractional part. The linear
interpolation has been implemented with h=0.125. Using
this approach the total amount of locations is equal to
8. The minimum relative error in terms of rms is 0.25%.
(5) The values stored in the Look-up table are in the range
[ −2 = 0.1353;  2 = 7.3891].
3. Experimental results
After a floating point and a fixed point Simulink
simulation, the proposed softmax architectures were coded
in VHDL and implemented using the XILINX Vivado
toolchain. Finally, they have been characterized in terms
of hardware resources speed and power consumption.</p>
      <p>For our experiments we use a Xilinx Zynq Ultrascale+</p>
      <p>Implementation results are shown in Fig. 3 and in
Fig. 3 Implementations have been performed with a
clock constraint of 20 ns. Experimental results show
a very low use of hardware resources available in the
device For what concerns power consumption, the
results show a reduced dissipation. This is aspect is very
power is not provided directly by the power line but it
is provided by batteries or energy harvesting systems.</p>
      <p>This is the case for example of IoT systems. Results
show a power consumption of 0.120w and 0.107w for
the two analyzed cases.
In our experiment we fix the value of the number of
numerous inputs and outputs of 16-bit architectures. important especially in all those applications where</p>
    </sec>
    <sec id="sec-2">
      <title>4. Conclusion</title>
      <p>In this paper, we presented the main features and
potential of Xilinx RFSoCs. Thanks to RF converters
(until 6 Gsps) they are very suitable for direct sampling of
RF signals with bandwidth up to 4 GHz. As well as
being fully supported from Vivado tool, these devices
are also supported by other tools such us Mathworks
Simulink.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>P.</given-names>
            <surname>Ferroni</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Zanzotto</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N.</given-names>
            <surname>Scarpato</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Spila</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>Fofi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G.</given-names>
            <surname>Egeo</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Rullo</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Palmirotta</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Barbanti</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Guadagni</surname>
          </string-name>
          ,
          <article-title>Machine learning approach to predict medication overuse in migraine patients</article-title>
          ,
          <source>Computational and Structural Biotechnology Journal</source>
          <volume>18</volume>
          (
          <year>2020</year>
          )
          <fpage>1487</fpage>
          -
          <lpage>1496</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>R.</given-names>
            <surname>Giuliano</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G. C.</given-names>
            <surname>Cardarilli</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Cesarini</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L. Di</given-names>
            <surname>Nunzio</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Fallucchi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Fazzolari</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Mazzenga</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Re</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Vizzarri</surname>
          </string-name>
          ,
          <article-title>Indoor localization system based on bluetooth low energy for museum applications</article-title>
          ,
          <source>Electronics</source>
          <volume>9</volume>
          (
          <year>2020</year>
          )
          <fpage>1055</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>F.</given-names>
            <surname>Bonanno</surname>
          </string-name>
          , G. Capizzi, G. Sciuto,
          <string-name>
            <surname>C. Napoli,</surname>
          </string-name>
          <article-title>Wavelet recurrent neural network with semiparametric input data preprocessing for microwind power forecasting in integrated generation systems</article-title>
          ,
          <source>in: 5th International Conference on Clean Electrical Power: Renewable Energy Resources Impact, ICCEP</source>
          <year>2015</year>
          ,
          <year>2015</year>
          , pp.
          <fpage>602</fpage>
          -
          <lpage>609</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>G. M.</given-names>
            <surname>Khanal</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G.</given-names>
            <surname>Cardarilli</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Chakraborty</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Acciarito</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M. Y.</given-names>
            <surname>Mulla</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L. Di</given-names>
            <surname>Nunzio</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Fazzolari</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Re</surname>
          </string-name>
          ,
          <article-title>A zno-rgo composite thin film discrete memristor</article-title>
          ,
          <source>in: 2016 IEEE International Conference on Semiconductor Electronics (ICSE)</source>
          , IEEE,
          <year>2016</year>
          , pp.
          <fpage>129</fpage>
          -
          <lpage>132</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>S. L.</given-names>
            <surname>Ullo</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G. R.</given-names>
            <surname>Sinha</surname>
          </string-name>
          ,
          <article-title>Advances in smart environment monitoring systems using iot and sensors</article-title>
          ,
          <source>Sensors (Switzerland) 20</source>
          (
          <year>2020</year>
          )
          <fpage>3113</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>D.</given-names>
            <surname>Gutiérrez</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Giménez</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Zerbini</surname>
          </string-name>
          , G. Riva,
          <article-title>Measurement of 4g lte cells with sdr technology</article-title>
          ,
          <source>IEEE Latin America Transactions</source>
          <volume>18</volume>
          (
          <year>February 2020</year>
          )
          <fpage>206</fpage>
          -
          <lpage>213</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>R.</given-names>
            <surname>Giuliano</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Mazzenga</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Vizzarri</surname>
          </string-name>
          ,
          <article-title>Satellitebased capillary 5g-mmtc networks for environmental applications</article-title>
          ,
          <source>IEEE Aerospace and Electronic Systems Magazine</source>
          <volume>34</volume>
          (
          <year>2019</year>
          )
          <fpage>40</fpage>
          -
          <lpage>48</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>C.</given-names>
            <surname>Napoli</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G.</given-names>
            <surname>Pappalardo</surname>
          </string-name>
          ,
          <string-name>
            <given-names>E.</given-names>
            <surname>Tramontana</surname>
          </string-name>
          ,
          <article-title>A hybrid neuro-wavelet predictor for qos control and stability</article-title>
          ,
          <source>in: AI*IA 2013: Advances in Artificial Intelligence</source>
          , volume
          <volume>8249</volume>
          , Springer International Publishing,
          <year>2013</year>
          , pp.
          <fpage>527</fpage>
          -
          <lpage>538</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <given-names>T.</given-names>
            <surname>Yoshizawa</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S. B. M.</given-names>
            <surname>Baskaran</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Kunz</surname>
          </string-name>
          ,
          <article-title>Overview of 5g urllc system and security aspects in 3gpp</article-title>
          ,
          <source>in: IEEE Conference on Standards for Communications and Networking (CSCN)</source>
          , IEEE, Granada, Spain,
          <year>2019</year>
          , pp.
          <fpage>1</fpage>
          -
          <lpage>5</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <given-names>G.</given-names>
            <surname>Borowik</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Wozniak</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Fornaia</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Giunta</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Napoli</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G.</given-names>
            <surname>Pappalardo</surname>
          </string-name>
          ,
          <string-name>
            <given-names>E.</given-names>
            <surname>Tramontana</surname>
          </string-name>
          ,
          <article-title>A software architecture assisting workflow executions on cloud resources</article-title>
          ,
          <source>International Journal of Electronics and Telecommunications</source>
          <volume>61</volume>
          (
          <year>2015</year>
          )
          <fpage>17</fpage>
          -
          <lpage>23</lpage>
          . doi:
          <volume>10</volume>
          .1515/eletel-2015-0002.
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          [11]
          <string-name>
            <given-names>G.</given-names>
            <surname>Capizzi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Coco</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G. Lo</given-names>
            <surname>Sciuto</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Napoli</surname>
          </string-name>
          ,
          <article-title>A new iterative fir filter design approach using a gaussian approximation</article-title>
          ,
          <source>IEEE Signal Processing Letters</source>
          <volume>25</volume>
          (
          <year>2018</year>
          )
          <fpage>1615</fpage>
          -
          <lpage>1619</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          [12]
          <string-name>
            <given-names>G.</given-names>
            <surname>Du</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Tian</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Z.</given-names>
            <surname>Li</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Zhang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Yin</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Ouyang</surname>
          </string-name>
          ,
          <article-title>Eficient softmax hardware architecture for deep neural networks</article-title>
          ,
          <source>in: Proceedings of the 2019 on Great Lakes Symposium on VLSI</source>
          ,
          <year>2019</year>
          , pp.
          <fpage>75</fpage>
          -
          <lpage>80</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          [13]
          <string-name>
            <given-names>I.</given-names>
            <surname>Kouretas</surname>
          </string-name>
          ,
          <string-name>
            <given-names>V.</given-names>
            <surname>Paliouras</surname>
          </string-name>
          ,
          <article-title>Hardware implementation of a softmax-like function for deep learning</article-title>
          ,
          <source>Technologies</source>
          <volume>8</volume>
          (
          <year>2020</year>
          )
          <fpage>46</fpage>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>