JPH06203058A - Sigmoid function arithmetic unit and its computing method - Google Patents

Sigmoid function arithmetic unit and its computing method

Info

Publication number
JPH06203058A
JPH06203058A JP4347620A JP34762092A JPH06203058A JP H06203058 A JPH06203058 A JP H06203058A JP 4347620 A JP4347620 A JP 4347620A JP 34762092 A JP34762092 A JP 34762092A JP H06203058 A JPH06203058 A JP H06203058A
Authority
JP
Japan
Prior art keywords
output
multiplier
register
adder
subtractor
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Withdrawn
Application number
JP4347620A
Other languages
Japanese (ja)
Inventor
Yoshio Hirose
佳生 広瀬
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Fujitsu Ltd
Original Assignee
Fujitsu Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Fujitsu Ltd filed Critical Fujitsu Ltd
Priority to JP4347620A priority Critical patent/JPH06203058A/en
Publication of JPH06203058A publication Critical patent/JPH06203058A/en
Withdrawn legal-status Critical Current

Links

Landscapes

  • Complex Calculations (AREA)

Abstract

PURPOSE:To perform calculation with high accuracy and at high speed without complicating hardware constitution. CONSTITUTION:The square of the output e<x> of a register 25 is taken on a multiplier 25 when it is -x2<=x<-x1, and a result e<2x> is held with the register 25. thence, e<2x>, e<4x>, e<6x>,... are outputted from the multiplier 24 by repeating processing to calculate the product of the output of the multiplier 24 and that of the register 25, and the products -e<2x>, +e<4x>, -e<6x>,... of the output of the multiplier 24 and that of a ROM 30 are calculated by a multiplier 13 in parallel with the above processing, and furthermore, the sum 1 of the output 1 of a ROM 34 and the output 0 of a constant setting circuit 32 is outputted to an adder/substractor 14 first in parallel with the above processing, thence, the sum of the output of the multiplier 13 and that of the adder/subtractor 14 is calculated repeatedly, thereby, g(x)=1-e2x+e<4x>, -e<6x>,... is outputted from the adder/subtractor 14, thence, the product of the output g(x) of the adder/ subtractor 14 and the output e<2x> of the register 25 is calculated by the multiplier 13, and it is outputted as a value of sigmoid function.

Description

【発明の詳細な説明】Detailed Description of the Invention

【0001】[0001]

【産業上の利用分野】本発明は、ニューロコンピュータ
のニューロンモデル等に用いられるシグモイド関数演算
装置及びその演算方法に関する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a sigmoid function computing device used in a neuron model of a neurocomputer and a computing method thereof.

【0002】[0002]

【従来の技術】ニューラルネットワークは、図15に示
すようなニューロンモデルが多数結合されて構成されて
いる。このニューロンモデルは、入力信号V1 、V2
・・V n とシナプス荷重W1 、W2 、・・・、Wn との
積和x=V11 +V22 +・・・+Vnn を演算
し、これをシグモイド関数(S字状関数)f(x)に通
してy=f(x)を出力する。シグモイド関数f(x)
としては色々な形のものが考えられているが、次のよう
な、双曲正接関数を並行移動したものが広く使用されて
いる。
2. Description of the Related Art A neural network is shown in FIG.
It consists of many connected neuron models
There is. This neuron model uses the input signal V1, V2
..V nAnd synapse load W1, W2, ..., WnWith
Sum of products x = V1W1+ V2W2+ ... + VnWnCalculate
And pass this to the sigmoid function (S-shaped function) f (x).
Then, y = f (x) is output. Sigmoid function f (x)
Although various shapes are considered as,
A parallel translation of the hyperbolic tangent function is widely used.
There is.

【0003】 f(x)={1+tan(x/s)}/2 ・・・(1) ここに、sはシグモイド関数の傾きを決める定数であ
り、以下においては、簡単化のためにs=1とする。
F (x) = {1 + tan (x / s)} / 2 (1) where s is a constant that determines the slope of the sigmoid function, and in the following, s = Set to 1.

【0004】シグモイド関数の計算には不動小数点プロ
セッサ(FPU)などを用いて高速化が図られている
が、計算に時間がかかるため、より高速に計算を行う演
算装置が要求されている。
Although a fixed point processor (FPU) or the like is used to speed up the calculation of the sigmoid function, since the calculation takes time, an arithmetic unit for performing the calculation at higher speed is required.

【0005】そこで、本案と同一出願人により、次のよ
うな方法で計算を行う演算装置が提案されている(特願
平2−5343号)。すなわち、例えばx1=0.7
8、x2=10.75に対し、0≦x<x1の範囲では、
Σをn=1〜p1の総和とし、 f(x)=1/2+Σ(−1)n-1{22n(22n−1)Bn2n-1} /{2・(2n)!} =1/2+Σβ2n-12n-1 ・・・(2) x1≦x<x2の範囲では、Σをn=0〜p2の総和と
し、 f(x)=Σ(−1)n-2nx ・・・(3) と展開した近似式を用いる。
Therefore, the same applicant as the present invention has proposed an arithmetic unit for performing the calculation by the following method (Japanese Patent Application No. 2-5343). That is, for example, x 1 = 0.7
8, x 2 = 1.75, in the range of 0 ≦ x <x 1 ,
Let Σ be the sum of n = 1 to p1, and f (x) = 1/2 + Σ (−1) n−1 {2 2n (2 2n −1) B n x 2n−1 } / {2 · (2n)! } = 1/2 + Σβ 2n-1 x 2n-1 (2) In the range of x 1 ≦ x <x 2 , Σ is the sum of n = 0 to p2, and f (x) = Σ (-1) n e -2nx ... (3) The approximate expression that is expanded is used.

【0006】x≧x2の範囲では、 f(x)=1 ・・・(4) と近似し、x<−x2の範囲では、 f(x)=0 ・・・(5) と近似する。In the range of x ≧ x 2 , it is approximated as f (x) = 1 (4), and in the range of x <−x 2 , it is approximated as f (x) = 0 (5) To do.

【0007】−x2≦x<0の範囲では、次の関係式、 f(x)=1−f(−x) ・・・(6) と、上式(2)及び(3)を用いる。In the range of -x 2 ≤x <0, the following relational expression, f (x) = 1-f (-x) (6) and the above expressions (2) and (3) are used. .

【0008】上式(3)の右辺中のexは、Σをk=0
〜p3の総和とする次のようなチェビシェフの展開式、 ex=Σαkk ・・・(7) で近似する。この式(8)は、|x|≦1の範囲でしか
使えない。|x|>1の範囲では、xの仮数部及び指数
部をそれぞれA及びmとすると、 x=A×2m ・・・(8) と表され、 exはeAの2m 乗 ・・・(9) となり、|A|<1であるから、eAを式(7)で計算
した後、式(9)を用いてexを算出する。
In the right side of the above equation (3), e x is k = 0.
Is approximated by the following Chebyshev expansion equation, which is the sum of p3 to p3: e x = Σα k x k (7) This expression (8) can be used only in the range of | x | ≦ 1. In the range of | x |> 1, assuming that the mantissa part and the exponent part of x are A and m, respectively, x = A × 2 m is expressed as (8), and e x is e A to the 2 m- th power. .. (9), and | A | <1. Therefore, after calculating e A by the equation (7), e x is calculated by using the equation (9).

【0009】[0009]

【発明が解決しようとする課題】しかし、上式(6)に
おいて、f(−x)の値が1に非常に近いときには、1
−f(x)の計算で桁落ちが生じるため、計算精度が低
下する。
However, in the above equation (6), when the value of f (-x) is very close to 1, 1
The precision of calculation is reduced because a digit is lost in the calculation of −f (x).

【0010】本発明の目的は、このような問題点に鑑
み、ハードウエア構成を殆ど複雑化することなく、高精
度かつ高速で計算することがが可能なシグモイド関数演
算装置及びその演算方法を提供することにある。
In view of the above problems, an object of the present invention is to provide a sigmoid function computing device and a computing method therefor capable of performing highly accurate and high-speed computation without complicating the hardware configuration. To do.

【0011】[0011]

【課題を解決するための手段及びその作用】本発明で
は、仮数部がAで指数部がmの入力値xに対し、xの範
囲に応じた、シグモイド関数f(x)の近似展開式に基
づいて、該シグモイド関数f(x)の値を計算し出力す
る、シグモイド関数演算装置による演算方法において、
0<x1<x2なる定数x1、x2に対しxが−x2≦x<
−x1である場合に、Aの累乗を算出させ、これと並行
して、該Aの累乗と展開係数α1、α2、・・・、αpと
の積α1A、α22、・・・、αp3p3を算出させ、さ
らにこれと並行して、初項α0 と該積の総和eA=α0
+α1A+・・・+αp3p3を算出させる第1ステップ
と、eAを2m乗させてexを算出させる第2ステップ
と、exに基づいてe2x、e4x、e6x、・・・、e
2(p2)xを算出させ、これと並行して、−e2x、+e4x
−e6x、・・・、(−1)p22(p2)xを求めさせ、さら
にこれと並行して、g(x)=1−e2x+e4x−e6x
・・・+(−1)p22( p2)xを算出させる第3ステップ
と、g(x)とe2xとの積を算出させ、該積e2x
(x)を該シグモイド関数f(x)の値とする第3ステ
ップとを備えている。
According to the present invention, an approximate expansion of a sigmoid function f (x) according to the range of x is applied to an input value x having a mantissa A and an exponent m. Based on the sigmoid function calculating device for calculating and outputting the value of the sigmoid function f (x),
For constants x 1 and x 2 such that 0 <x 1 <x 2, x is −x 2 ≦ x <
In the case of −x 1 , the power of A is calculated, and in parallel with this, the product of the power of A and the expansion coefficients α 1 , α 2 , ..., αp α 1 A, α 2 A 2 , ..., α p3 A p3 is calculated, and in parallel with this, the total sum eA = α 0 of the first term α 0 and the product
A first step of calculating a + α 1 A + ··· + α p3 A p3, a second step of calculating a e x by the e A 2 m-th power is, e based on e x 2x, e 4x, e 6x, ... e
2 (p2) x is calculated, and in parallel with this, −e 2x , + e 4x ,
-E 6x, ···, (- 1 ) p2 allowed sought e 2 (p2) x, and further parallel with this, g (x) = 1- e 2x + e 4x -e 6x +
... + (- 1) and the third step of calculating the p2 e 2 (p2) x, is calculated the product of g (x) and e 2x, integrating e 2x g
A third step of setting (x) to the value of the sigmoid function f (x).

【0012】本発明に係るシグモイド関数演算装置は、
上記方法を実施するためのものであり、実施例図中の対
応する構成要素の符号を引用して説明する。
A sigmoid function computing device according to the present invention is
The method is for carrying out the above method, and will be described with reference to the reference numerals of corresponding constituent elements in the embodiment drawings.

【0013】このシグモイド関数演算装置は、例えば図
1に示す如く、レジスタ25と、第1入力端に供給され
た値と第2入力端に供給された値との積を算出する第1
乗算器24と、レジスタ25の出力と第1乗算器24の
出力との一方を選択して第1乗算器24の該第1入力端
に供給する第1マルチプレクサ26と、レジスタ25の
出力と第1乗算器24の出力との一方を選択して第1乗
算器24の該第2入力端に供給する第2マルチプレクサ
27と、関数を多項展開したときの初項以外の各項の係
数が設定された係数設定手段30と、第1入力端に供給
された値と第2入力端に供給された値との積を算出する
第2乗算器13と、該関数を多項展開したときの該初項
に対応した値が設定された初項設定手段34と、定数が
設定された定数設定手段32と、第1入力端に供給され
た値と第2入力端に供給された値との和又は差を算出す
る加減算器14と、レジスタ25の出力と第1乗算器2
4の出力との一方を選択して第2乗算器13の該第1入
力端に供給する第3マルチプレクサ28と、係数設定手
段30の出力と加減算器14の出力との一方を選択して
第2乗算器13の該第2入力端に供給する第4マルチプ
レクサ29と、定数設定手段32の出力と加減算器14
の出力との一方を選択して加減算器14の該第1入力端
に供給する第5マルチプレクサ31と、初項設定手段3
4の出力と第2乗算器13の出力との一方を選択して加
減算器14の該第2入力端に供給する第6マルチプレク
サ33と、該シグモイド関数をどの展開式で求めるかを
決定するためのxの範囲を判定する判定手段16〜20
と、判定手段16〜20による判定結果に応じて、該第
1〜6マルチプレクサを切換制御し、第1乗算器24、
第2乗算器13及び加減算器14に演算を実行させて該
シグモイド関数の値を求めさせる制御手段Cとを備えて
いる。
This sigmoid function computing device is, for example, as shown in FIG. 1, a register 25 and a first unit for calculating a product of a value supplied to a first input terminal and a value supplied to a second input terminal.
A multiplier 24; a first multiplexer 26 that selects one of the output of the register 25 and the output of the first multiplier 24 and supplies it to the first input terminal of the first multiplier 24; The second multiplexer 27 which selects one of the output of the 1 multiplier 24 and supplies it to the second input terminal of the first multiplier 24, and the coefficient of each term other than the first term when the function is polynomial expanded are set. The coefficient setting means 30, the second multiplier 13 for calculating the product of the value supplied to the first input terminal and the value supplied to the second input terminal, and the first when the function is polynomial expanded. The first term setting means 34 in which a value corresponding to the term is set, the constant setting means 32 in which a constant is set, the sum of the value supplied to the first input end and the value supplied to the second input end, or The adder / subtractor 14 for calculating the difference, the output of the register 25, and the first multiplier 2
No. 4 output and one of the output of the coefficient setting means 30 and the output of the adder / subtractor 14 are selected to select the third multiplexer 28 for supplying to the first input terminal of the second multiplier 13. The fourth multiplexer 29 which supplies the second input terminal of the 2 multiplier 13, the output of the constant setting means 32 and the adder / subtractor 14
And a first multiplexer for selecting one of the outputs of the first and second input terminals to supply the first input terminal of the adder / subtractor 14 to the first input terminal.
4 to select one of the output of the second multiplier 13 and the output of the second multiplier 13 to determine the sixth multiplexer 33 to be supplied to the second input terminal of the adder-subtractor 14 and which expansion formula to obtain the sigmoid function. Determination means 16 to 20 for determining the range of x
Then, the first to sixth multiplexers are switched and controlled according to the judgment result by the judging means 16 to 20, and the first multiplier 24,
And a control unit C for causing the second multiplier 13 and the adder / subtractor 14 to execute an operation to obtain the value of the sigmoid function.

【0014】この制御手段Cは、0<x1<x2なる定数
1、x2に対し、該判定結果が−x2≦x<−x1である
場合に、例えば図6〜9で−AをAと置き換えたときの
動作のように、第1乗算器24に対し、第1乗算器24
の出力とレジスタ25の出力Aとの積を繰り返し算出さ
せてAの累乗を算出させ、これと並行して、第2乗算器
13に対し、第1乗算器24の出力と係数設定手段30
の出力との積を算出させ、さらにこれと並行して、加減
算器14に対し、最初は初項設定手段34の出力と定数
設定手段32の出力との演算結果α0 を出力させ、次
に、第2乗算器13の出力と加減算器14の出力との和
を繰り返し算出させることにより、加減算器14からe
A=α0 +α1A+・・・+αp3p3を出力させてレジス
タ25に保持させ、次に、例えば図10で−AをAと置
き換えたときの動作のように、第1乗算器24に対し、
レジスタ25の出力を平方させてその結果をレジスタ2
5に保持させる処理を繰り返させることにより、レジス
タ25から、eAを2m乗したexを出力させ、次に、例
えば図11〜13で−AをAと置き換えたときの動作の
ように、第1乗算器24に対し、レジスタ25の出力e
xを平方させてその結果をレジスタ25に保持させ、次
に、第1乗算器24の出力とレジスタ25の出力との積
を算出させる処理を繰り返させることにより、第1乗算
器24からe2x、e4x、e6x、・・・、e2(p2)xを出力
させ、これと並行して、第2乗算器13に対し、第1乗
算器24の出力と係数設定手段30の出力との積−
2x、+e4x、−e6x、・・・、(−1)p22(p2)x
算出させ、さらにこれと並行して、加減算器14に対
し、最初は初項設定手段34の出力と定数設定手段32
の出力との演算結果1を出力させ、次に、第2乗算器1
3の出力と加減算器14の出力との和を繰り返し算出さ
せることにより、加減算器14からg(x)=1−e2x
+e4x−e6x+・・・、+(−1)p22(p2)xを出力さ
せ、次に、例えば図14に示すように、第2乗算器13
に対し、加減算器14の出力g(x)とレジスタ25の
出力e2xとの積を算出させ、該積e2xg(x)を該シグ
モイド関数f(x)の値として出力させる。
This control means C, for constants x 1 and x 2 satisfying 0 <x 1 <x 2 , when the judgment result is −x 2 ≦ x <−x 1 , for example, in FIGS. As in the operation when -A is replaced with A, the first multiplier 24
Of the output of the register 25 and the output A of the register 25 are repeatedly calculated to calculate the power of A. In parallel with this, the output of the first multiplier 24 and the coefficient setting means 30 are transmitted to the second multiplier 13.
It is calculated the product of the output of the further parallel with this, with respect to the adder-subtracter 14, initially to output the operation result alpha 0 of the outputs of the constant setting means 32 of the first term setting means 34, then , By repeatedly calculating the sum of the output of the second multiplier 13 and the output of the adder / subtractor 14,
A = α 0 + α 1 A + ... + α p3 A p3 is output and held in the register 25, and then, for example, as in the operation when −A is replaced with A in FIG. 10, the first multiplier 24 As opposed to
The output of register 25 is squared and the result is registered in register 2
5 is repeated to output e x, which is the power of e A raised to the power of 2 m , from the register 25. Next, for example, the operation when -A is replaced with A in FIGS. , The output e of the register 25 to the first multiplier 24
By squaring x and holding the result in the register 25, and then repeating the process of calculating the product of the output of the first multiplier 24 and the output of the register 25, the first multiplier 24 e 2x , E 4x , e 6x , ..., E 2 (p2) x are output, and in parallel with this, the second multiplier 13 outputs the output of the first multiplier 24 and the output of the coefficient setting means 30. Product of −
e 2x , + e 4x , −e 6x , ..., (−1) p2 e 2 (p2) x are calculated, and in parallel with this, the adder / subtractor 14 is initially operated by the first term setting means 34. Output and constant setting means 32
Output the calculation result 1 and the second multiplier 1
By repeatedly calculating the sum of the output of 3 and the output of the adder / subtractor 14, g (x) = 1-e 2x from the adder / subtractor 14 is calculated.
+ E 4x −e 6x + ..., + (− 1) p2 e 2 (p2) x is output, and then, as shown in FIG. 14, for example, the second multiplier 13
In contrast, the product of the output g (x) of the adder / subtractor 14 and the output e 2x of the register 25 is calculated, and the product e 2x g (x) is output as the value of the sigmoid function f (x).

【0015】−x2≦x<−x1のときは、従来、図6〜
13の処理を行い、次に、1−f(−x)を加減算器1
4で計算していたのを、本発明では、例えば、図6〜1
3で−AをAと置き換えたときの処理を行い、次に、図
14の処理を行うので、従来と同程度の計算時間で、す
なわち高速に、しかも、桁落ちなく高精度でシグモイド
関数f(x)の値を求めることができる。
When −x 2 ≦ x <−x 1 , the conventional method shown in FIG.
13 is performed, and then 1-f (-x) is added to the adder / subtractor 1
In the present invention, the calculation performed in step 4 is, for example, in FIGS.
Since the process of replacing -A with A in 3 is performed, and then the process of FIG. 14 is performed, the sigmoid function f is calculated in the same calculation time as the conventional one, that is, at high speed and with high precision without digit loss. The value of (x) can be obtained.

【0016】また、本発明のハードウエア構成は、従来
と比較すると、従来では、係数設定手段30の出力を直
接第2乗算器13に供給していたのを、本発明では、第
4マルチプレクサ29を備え係数設定手段30又は加減
算器14の出力を選択して第2乗算器13に供給してい
る点、及び、制御手段Cの制御方法の点で相違している
が、シグモイド関数演算装置全体としては、複雑さの程
度は従来と殆ど同じである。
In comparison with the conventional hardware configuration, the hardware configuration of the present invention conventionally supplies the output of the coefficient setting means 30 directly to the second multiplier 13, but in the present invention, the fourth multiplexer 29. The difference is that the output of the coefficient setting means 30 or the adder / subtractor 14 is selected and supplied to the second multiplier 13 and the control method of the control means C is different, but the sigmoid function computing device as a whole. As a result, the degree of complexity is almost the same as the conventional one.

【0017】[0017]

【実施例】以下、図面に基づいて本発明に係るシグモイ
ド関数演算装置の一実施例を説明する。
DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS An embodiment of a sigmoid function computing device according to the present invention will be described below with reference to the drawings.

【0018】このシグモイド関数演算装置は、上式
(1)のシグモイド関数f(x)を、xについてべき展
開した近似式に基づき計算するものであり、ハードウエ
ア構成でパイプライン処理することにより、高速で演算
を実行する。
This sigmoid function computing device calculates the sigmoid function f (x) of the above equation (1) based on an approximate expression that is a power expansion of x, and by pipeline processing with a hardware configuration, Performs calculations at high speed.

【0019】高速かつ高精度で演算を行うために、xの
範囲に応じて異なるxのべき展開式を用いる。0≦x<
1の範囲では上式(2)を用い、x1≦x<x2の範囲
で上式(3)を用い、x≧x2の範囲では上式(4)を
用い、x<−x2の範囲では上式(5)を用い、かつ、
式(3)中のexを上式(7)〜(9)に基づき計算す
る点では、従来と同一である。本実施例の新規な点は、
上式(6)の関係を−x1≦x<0の範囲でのみ用い、
−x2≦x<x1の範囲では、Σをn=0〜p2の総和と
し、 f(x)=1/(1+e-2x) =e2x/(e2x+1) =e2xg(x) ・・・(11) g(x)=Σ(−1)n2nx ・・・(12) を用い、かつ、e2xを、上式(7)〜(9)を用いて計
算する点である。
In order to perform calculation at high speed and with high accuracy, different exponential expansions of x are used depending on the range of x. 0 ≦ x <
the above equation (2) used in the range of x 1, the above equation (3) used in the range of x 1 ≦ x <x 2, above equation (4) used in the range of x ≧ x 2, x <-x In the range of 2 , the above formula (5) is used, and
It is the same as the conventional one in that ex in Expression (3) is calculated based on Expressions (7) to (9) above. The novel point of this embodiment is that
Using the relationship of the above formula (6) only in the range of −x 1 ≦ x <0,
In the range of −x 2 ≦ x <x 1 , Σ is the sum of n = 0 to p2, and f (x) = 1 / (1 + e −2x ) = e 2x / (e 2x +1) = e 2x g (x ) (11) g (x) = Σ (-1) n e 2nx (12) and the point where e 2x is calculated using the above equations (7) to (9) Is.

【0020】図1は、シグモイド関数演算装置のブロッ
ク構成を示す。以下の各種制御は、制御回路Cからの制
御信号に基づいて行われる。また、上式(2)、
(3)、(7)及び(12)の展開項数は制御回路Cに
与えられている。
FIG. 1 shows a block configuration of a sigmoid function computing device. The following various controls are performed based on the control signal from the control circuit C. Also, the above formula (2),
The number of expansion terms of (3), (7) and (12) is given to the control circuit C.

【0021】マルチプレクサ10は、外部からの浮動小
数点表記のx、値0が設定された定数設定回路11、値
1が設定された定数設定回路12、乗算器13及び加減
算器14の出力の1つを選択し、入出力レジスタ15へ
供給する。最初は、xを選択する。符号ビット判定・反
転回路16は、入出力レジスタ15に最初にxが保持さ
れているとき、xの仮数部Aの符号ビットを調べ、xが
負数のときフラグレジスタ17中の符号フラブをセット
し、xが正数のときこの符号フラブをリセットする。符
号ビット判定・反転回路16はさらに、xが負数のと
き、その符号ビットを反転させて正の数|x|とする。
比較器18は、符号ビット判定・反転回路16からの|
x|を、定数設定回路19及び20に設定された定数x
1及びx2と比較し、その比較結果を2ビットの値として
フラグレジスタ17に保持させる。
The multiplexer 10 is one of the outputs of x from floating point notation, a constant setting circuit 11 with a value 0 set, a constant setting circuit 12 with a value 1 set, a multiplier 13 and an adder / subtractor 14. Is selected and supplied to the input / output register 15. First, select x. The sign bit determination / inversion circuit 16 checks the sign bit of the mantissa part A of x when x is initially held in the input / output register 15, and sets the sign flag in the flag register 17 when x is a negative number. , X is a positive number, this code flag is reset. The sign bit determination / inversion circuit 16 further inverts the sign bit to obtain a positive number | x | when x is a negative number.
The comparator 18 outputs the | from the sign bit determination / inversion circuit 16.
x | is a constant x set in the constant setting circuits 19 and 20.
It is compared with 1 and x 2, and the comparison result is held in the flag register 17 as a 2-bit value.

【0022】指数部クリア・符号ビット反転回路21
は、フラグレジスタ17の内容がx1<|x|≦x2を表
しているとき、|x|の指数部mを指数部レジスタ22
に保持させた後、m=0、すなわちxをAとし、さらに
フラグレジスタ17の符号フラグが正数であることを表
しているときには、仮数部の符号ビットを反転させてx
を−Aとする。
Exponent part clearing / sign bit inverting circuit 21
When the content of the flag register 17 represents x 1 <| x | ≦ x 2 , the exponent part m of | x |
M = 0, that is, x is set to A, and when the sign flag of the flag register 17 indicates a positive number, the sign bit of the mantissa part is inverted and x
Be -A.

【0023】以上の処理は、第0サイクルの動作として
行われる。
The above processing is performed as the operation of the 0th cycle.

【0024】マルチプレクサ23は、指数部クリア・符
号ビット反転回路21、乗算器24及び加減算器14の
出力の1つを選択し、これをレジスタ25へ供給する。
レジスタ25の内容は、マルチプレクサ26の一方の入
力端及びマルチプレクサ27の一方の入力端へ供給され
る。マルチプレクサ26の他方の入力端及びマルチプレ
クサ27の他方の入力端には、乗算器24の出力が供給
される。マルチプレクサ26及び27の出力は、乗算器
24へ供給され、両者の積が算出される。このような構
成要素23〜27により、xの累乗演算等が行われる。
The multiplexer 23 selects one of the outputs of the exponent part clearing / sign bit inverting circuit 21, the multiplier 24 and the adder / subtractor 14 and supplies it to the register 25.
The contents of the register 25 are supplied to one input end of the multiplexer 26 and one input end of the multiplexer 27. The output of the multiplier 24 is supplied to the other input end of the multiplexer 26 and the other input end of the multiplexer 27. The outputs of the multiplexers 26 and 27 are supplied to the multiplier 24, and the product of both is calculated. With the components 23 to 27 as described above, a power calculation of x or the like is performed.

【0025】マルチプレクサ28には、乗算器24及び
レジスタ25の出力が供給され、一方、マルチプレクサ
29には、加減算器14及びROM30の出力が供給さ
れる。ROM30には、f(x)の上式(2)、(3)
及び(7)の展開係数が格納されている(上式(12)
の展開係数は上式(3)の展開係数と同一)。ROM3
0から読み出される展開係数は、フラグレジスタ17の
内容及び後述の動作サイクルで定まる。マルチプレクサ
28及び29の出力は乗算器13へ供給され、xの累乗
等とその係数の積が算出される。
The multiplexer 28 is supplied with the outputs of the multiplier 24 and the register 25, while the multiplexer 29 is supplied with the outputs of the adder / subtractor 14 and the ROM 30. The ROM 30 stores the above formulas (2) and (3) of f (x).
And the expansion coefficients of (7) are stored (the above equation (12)).
The expansion coefficient of is the same as the expansion coefficient of the above equation (3)). ROM3
The expansion coefficient read from 0 is determined by the contents of the flag register 17 and the operation cycle described later. The outputs of the multiplexers 28 and 29 are supplied to the multiplier 13, and the product of the power of x and the coefficient thereof is calculated.

【0026】マルチプレクサ31には、0が設定された
定数設定回路32及び加減算器14の出力が供給され、
一方、マルチプレクサ33には、乗算器13及びROM
34の出力が供給される。ROM34には、f(x)の
上式(2)、(3)及び(7)の展開式の初項(定数)
1/2、1及びα0 が格納されている(上式(12)の
展開式の初項は上式(3)の展開式の初項1と同一)。
マルチプレクサ31及び33の出力は加減算器14へ供
給され、積和と前記積等との和又は差が算出される。
The multiplexer 31 is supplied with the outputs of the constant setting circuit 32 in which 0 is set and the adder / subtractor 14,
On the other hand, the multiplexer 33 includes a multiplier 13 and a ROM.
34 outputs are provided. The ROM 34 stores the first term (constant) of the expansion equations of the above equations (2), (3), and (7) of f (x).
1/2, 1 and α 0 are stored (the first term of the expansion equation of the above equation (12) is the same as the first term 1 of the expansion equation of the above equation (3)).
The outputs of the multiplexers 31 and 33 are supplied to the adder / subtractor 14, and the sum or difference between the product sum and the product or the like is calculated.

【0027】なお、乗算器24、13及び加減算器14
はそれぞれ、内部の出力段にバッファレジスタを備えて
いる。
The multipliers 24 and 13 and the adder / subtractor 14
Each has a buffer register in the internal output stage.

【0028】以下、上記第0サイクルに続く第1サイク
ル以降の動作を、フラグレジスタ17の内容、すなわち
xの範囲で区分される5つの場合に分けて説明する。
The operation of the first and subsequent cycles following the 0th cycle will be described below for each of the five cases of the contents of the flag register 17, that is, the range of x.

【0029】(A)x≧x2のとき マルチプレクサ10で定数設定回路12を選択させて入
出力レジスタ15に値1を保持させ、これをf(x)と
して出力させる。
(A) When x ≧ x 2 The multiplexer 10 selects the constant setting circuit 12 to hold the value 1 in the input / output register 15 and output it as f (x).

【0030】(B)x≦−x2のとき マルチプレクサ10で定数設定回路11を選択させて入
出力レジスタ15に値0を保持させ、これをf(x)と
して出力させる。
(B) When x≤-x 2 The constant setting circuit 11 is selected by the multiplexer 10 to hold the value 0 in the input / output register 15 and output as f (x).

【0031】(C)0≦|x|<x1のとき(図2〜
5) このとき、第0サイクルでレジスタ25に|x|が保持
されている。上式(2)の展開式を、以下のようにして
計算する。
(C) When 0 ≦ | x | <x 1 (see FIG.
5) At this time, | x | is held in the register 25 in the 0th cycle. The expansion formula of the above formula (2) is calculated as follows.

【0032】(1)第1サイクル 図2に示すようにマルチプレクサ26、27、28、2
9、31及び33を切換制御する。そして、乗算器24
でレジスタ25の出力|x|を平方し、これと並行し
て、レジスタ25の出力|x|とROM30の出力β1
との積を乗算器13で求め、さらにこれと並行して、定
数設定回路32の出力0とROM34の出力1/2との
和を加減算器14で求める。
(1) First Cycle As shown in FIG. 2, multiplexers 26, 27, 28, 2
Switching control is performed on 9, 31, and 33. And the multiplier 24
The output | x | of the register 25 is squared with, and in parallel with this, the output | x | of the register 25 and the output β 1 of the ROM 30
The product of and is obtained by the multiplier 13, and in parallel with this, the sum of the output 0 of the constant setting circuit 32 and the output 1/2 of the ROM 34 is obtained by the adder / subtractor 14.

【0033】(2)第2サイクル 図3に示すようにマルチプレクサ23、26、27、2
8、29、31及び33を切換制御する。そして、乗算
器24の出力|x|2 とレジスタ25の出力|x|との
積を乗算器24で求め、かつ、これを求める前の乗算器
24の出力|x|2 をレジスタ25に保持させる。これ
と並行して、乗算器24の出力|x|2とROM30の
出力0との積を乗算器13で求め、さらにこれと並行し
て、加減算器14の出力1/2と乗算器13の出力β1
|x|との和を加減算器14で求める。
(2) Second Cycle As shown in FIG. 3, multiplexers 23, 26, 27, 2
8, 29, 31 and 33 are switch-controlled. The output of the multiplier 24 | x | | output 2 and the register 25 | x a product of the calculated with the multiplier 24 and the output of the multiplier 24 before obtaining this | hold 2 in register 25 | x Let In parallel with this, the product of the output | x | 2 of the multiplier 24 and the output 0 of the ROM 30 is obtained by the multiplier 13, and in parallel with this, the output ½ of the adder / subtractor 14 and the multiplier 13 Output β 1
The sum with | x | is obtained by the adder / subtractor 14.

【0034】(3)第3サイクル 図4に示すようにマルチプレクサ26、27、28、2
9、31及び33を切換制御する。そして、乗算器24
の出力|x|3 とレジスタ25の出力|x|2との積を
乗算器24で求め、これと並行して、乗算器24の出力
|x|3 とROM30の出力β3 との積を乗算器13で
求め、さらにこれと並行して、加減算器14の出力1/
2+β1 |x|と乗算器13の出力0との和を加減算器
14で求める。
(3) Third Cycle As shown in FIG. 4, multiplexers 26, 27, 28, 2
Switching control is performed on 9, 31, and 33. And the multiplier 24
Of the output | x | 3 of the register 25 and the output | x | 2 of the register 25 are obtained by the multiplier 24. In parallel with this, the product of the output | x | 3 of the multiplier 24 and the output β 3 of the ROM 30 is calculated. Calculated by the multiplier 13, and in parallel with this, the output of the adder / subtractor 14 1 /
The adder / subtractor 14 calculates the sum of 2 + β 1 | x | and the output 0 of the multiplier 13.

【0035】(4)第4サイクル 図5に示すようにマルチプレクサ26、27、28、2
9、31及び33を切換制御する。そして、乗算器24
の出力|x|5 とレジスタ25の出力|x|2との積を
乗算器24で求め、これと並行して、乗算器24の出力
|x|5 とROM30の出力β5 との積を乗算器13で
求め、さらにこれと並行して、加減算器14の出力1/
2+β1 |x|と乗算器13の出力β3 |x|3 との和
を加減算器14で求める。
(4) Fourth Cycle As shown in FIG. 5, multiplexers 26, 27, 28, 2
Switching control is performed on 9, 31, and 33. And the multiplier 24
Of the output | x | 5 of the register 25 and the output | x | 2 of the register 25 are obtained by the multiplier 24. In parallel with this, the product of the output | x | 5 of the multiplier 24 and the output β 5 of the ROM 30 is calculated. Calculated by the multiplier 13, and in parallel with this, the output of the adder / subtractor 14 1 /
The sum of 2 + β 1 | x | and the output β 3 | x | 3 of the multiplier 13 is calculated by the adder / subtractor 14.

【0036】以下、この第4サイクルと同様の動作を繰
り返して行うことにより、第(p1+2)サイクルで上
式(2)の計算結果が加減算器14から得られる。フラ
グレジスタ17の符号フラグが負を表しているときには
更に、ROM34の出力1と加減算器14の出力f(−
x)との差を加減算器14で算出する。
Thereafter, by repeating the same operation as the fourth cycle, the calculation result of the above equation (2) is obtained from the adder / subtractor 14 in the (p1 + 2) th cycle. When the sign flag of the flag register 17 indicates negative, the output 1 of the ROM 34 and the output f (-
x) is calculated by the adder / subtractor 14.

【0037】次に、図1のマルチプレクサ10で加減算
器14の出力を選択させて、加減算器14の出力を入出
力レジスタ15に保持させ、これをf(x)として出力
させる。
Next, the multiplexer 10 of FIG. 1 selects the output of the adder / subtractor 14 to hold the output of the adder / subtractor 14 in the input / output register 15 and output it as f (x).

【0038】(D)x1≦x<x2のとき(図6〜13) このとき、第0サイクルで、レジスタ25にxの仮数部
−Aが保持され、指数部レジスタ22にxの指数部mが
保持されている。上式(3)の展開式を計算するにあた
って、まず、上式(7)においてx=−Aとしたときの
展開式を、以下のようにして計算する。
(D) When x 1 ≤x <x 2 (FIGS. 6 to 13) At this time, in the 0th cycle, the mantissa part -A of x is held in the register 25 and the exponent part of x is stored in the exponent part register 22. The part m is retained. In calculating the expansion formula of the above formula (3), first, the expansion formula when x = −A in the above formula (7) is calculated as follows.

【0039】(1)第1サイクル 図6に示すようにマルチプレクサ26、27、28、2
9、31及び33を切換制御する。そして、乗算器24
でレジスタ25の出力−Aを平方し、これと並行して、
レジスタ25の出力−AとROM30の出力α1 との積
を乗算器13で求め、さらにこれと並行して、定数設定
回路32の出力0とROM34の出力α 0 との和を加減
算器14で求める。
(1) First cycle As shown in FIG. 6, multiplexers 26, 27, 28, 2
Switching control is performed on 9, 31, and 33. And the multiplier 24
The output of register 25-A is squared with, and in parallel with this,
Output of register 25-A and output of ROM 30 α1Product of
Is calculated by the multiplier 13, and in parallel with this, a constant is set.
Output 0 of circuit 32 and output α of ROM 34 0Adjust the sum of
Calculated by the calculator 14.

【0040】(2)第2サイクル 図7に示すようにマルチプレクサ26、27、28、2
9、31及び33を切換制御する。そして、乗算器24
の出力(−A)2 とレジスタ25の出力−Aとの積を乗
算器24で求め、これと並行して、乗算器24の出力
(−A)2 とROM30の出力α2 との積を乗算器13
で求め、さらにこれと並行して、加減算器14の出力α
0 と乗算器13の出力α1 (−A)との和を加減算器1
4で求める。
(2) Second Cycle As shown in FIG. 7, multiplexers 26, 27, 28, 2
Switching control is performed on 9, 31, and 33. And the multiplier 24
Of the output (-A) 2 of the register 25 and the output -A of the register 25 are obtained by the multiplier 24. In parallel with this, the product of the output (-A) 2 of the multiplier 24 and the output α 2 of the ROM 30 is calculated. Multiplier 13
And in parallel with this, the output α of the adder / subtractor 14
The adder / subtractor 1 calculates the sum of 0 and the output α 1 (−A) of the multiplier 13.
Find in 4.

【0041】(3)第3サイクル 図8に示すようにマルチプレクサ26、27、28、2
9、31及び33を切換制御する。そして、乗算器24
の出力(−A)3 とレジスタ25の出力−Aとの積を乗
算器24で求め、これと並行して、乗算器24の出力
(−A)3 とROM30の出力α3 との積を乗算器13
で求め、さらにこれと並行して、加減算器14の出力α
0 +α1 (−A)と乗算器13の出力α2 (−A)2
の和を加減算器14で求める。
(3) Third Cycle As shown in FIG. 8, multiplexers 26, 27, 28, 2
Switching control is performed on 9, 31, and 33. And the multiplier 24
Of the output (-A) 3 of the register 25 and the output -A of the register 25 are obtained by the multiplier 24. In parallel with this, the product of the output (-A) 3 of the multiplier 24 and the output α 3 of the ROM 30 is calculated. Multiplier 13
And in parallel with this, the output α of the adder / subtractor 14
The sum of 0 + α 1 (−A) and the output α 2 (−A) 2 of the multiplier 13 is calculated by the adder / subtractor 14.

【0042】(4)第4〜(p3+1)サイクル 以下、前記第3サイクルと同様の動作を繰り返し行うこ
とにより、第(p3+1)サイクルにおいて、上式
(7)でx=−Aとしたときの右辺の計算結果が加減算
器14から得られる。図9に示すように、この加減算器
14の出力e-Aを、マルチプレクサ23を介しレジスタ
25に保持させる。
(4) Fourth to (p3 + 1) cycles Hereinafter, by repeating the same operation as the third cycle, when x = -A in the above equation (7) in the (p3 + 1) cycle, The calculation result on the right side is obtained from the adder / subtractor 14. As shown in FIG. 9, the output e −A of the adder / subtractor 14 is held in the register 25 via the multiplexer 23.

【0043】(6)第(p3+2)〜(p3+m+1)
サイクル 図10に示すようにマルチプレクサ23、26及び27
を切換制御する。そして、レジスタ25の出力を乗算器
24で平方し、レジスタ25に保持させ、これを図1の
指数部レジスタ22の内容mに等しい回数だけ繰り返す
ことにより、第(p3+m+1)サイクルで、e-Aを2
m乗したe-xを乗算器24から得ることができる。この
-xは、レジスタ25に保持される。
(6) No. (p3 + 2) to (p3 + m + 1)
Cycle Multiplexers 23, 26 and 27 as shown in FIG.
Switch control. Then, the output of the register 25 is squared by the multiplier 24, held in the register 25, and this is repeated a number of times equal to the content m of the exponent part register 22 of FIG. 1 to obtain e −A in the (p3 + m + 1) th cycle. 2
The e −x raised to the m- th power can be obtained from the multiplier 24. This e −x is held in the register 25.

【0044】(7)第(p3+m+2)サイクル 図11に示すようにマルチプレクサ26、27、28、
29、31及び33を切換制御する。そして、乗算器2
4でレジスタ25の出力e-xを平方し、これと並行し
て、レジスタ25の出力e-xとROM30の出力0との
積を乗算器13で求め、さらにこれと並行して、定数設
定回路32の出力0とROM34の出力1との和を加減
算器14で求める。
(7) Cycle (p3 + m + 2) The multiplexers 26, 27, 28, as shown in FIG.
29, 31 and 33 are switch-controlled. And the multiplier 2
In step 4, the output e −x of the register 25 is squared, and in parallel with this, the product of the output e −x of the register 25 and the output 0 of the ROM 30 is obtained by the multiplier 13, and in parallel with this, the constant setting is performed. The adder / subtractor 14 calculates the sum of the output 0 of the circuit 32 and the output 1 of the ROM 34.

【0045】(8)第(p3+m+3)サイクル 図12に示すようにマルチプレクサ23、26、27、
28、29、31及び33を切換制御する。そして、乗
算器24の出力e-2xの平方を乗算器24で求め、これ
と並行して、乗算器24の出力e-2xとROM30の出
力−1との積を乗算器13で求め、さらにこれと並行し
て、加減算器14の出力1と乗算器13の出力0との和
を加減算器14で求める。
(8) Cycle (p3 + m + 3) As shown in FIG. 12, multiplexers 23, 26, 27,
28, 29, 31 and 33 are switch-controlled. Then, the square of the output e -2x of the multiplier 24 is obtained by the multiplier 24, and in parallel with this, the product of the output e -2x of the multiplier 24 and the output -1 of the ROM 30 is obtained by the multiplier 13, and In parallel with this, the adder / subtractor 14 calculates the sum of the output 1 of the adder / subtractor 14 and the output 0 of the multiplier 13.

【0046】(9)第(p3+m+4)サイクル 図13に示すようにマルチプレクサ26、27、28、
29、31及び33を切換制御する。そして、乗算器2
4の出力e-4xとレジスタ25の出力e-2xとの積を乗算
器24で求め、これと並行して、乗算器24の出力e
-4xとROM30の出力1との積を乗算器13で求め、
さらにこれと並行して、加減算器14の出力1と乗算器
13の出力−e-2xとの和を加減算器14で求める。
(9) Cycle (p3 + m + 4) As shown in FIG. 13, multiplexers 26, 27, 28,
29, 31 and 33 are switch-controlled. And the multiplier 2
4 output e -4x and register 25 output e -2x are calculated by the multiplier 24, and in parallel with this, the output e of the multiplier 24
The product of -4x and the output 1 of the ROM 30 is calculated by the multiplier 13,
Further, in parallel with this, the sum of the output 1 of the adder / subtractor 14 and the output −e −2x of the multiplier 13 is obtained by the adder / subtractor 14.

【0047】以下、この第(p3+m+3)サイクルと
同様の動作を繰り返して行うことにより、第(p3+m
+p2+3)サイクルで上式(3)の右辺の計算結果が
加減算器14から得られる。
Thereafter, the same operation as the (p3 + m + 3) th cycle is repeated to obtain the (p3 + m) th cycle.
The calculation result of the right side of the above equation (3) is obtained from the adder / subtractor 14 in + p2 + 3) cycles.

【0048】次に、図1のマルチプレクサ10で加減算
器14の出力を選択させて、加減算器14の出力を入出
力レジスタ15に保持させ、これをf(x)として出力
させる。
Then, the multiplexer 10 shown in FIG. 1 selects the output of the adder / subtractor 14 to hold the output of the adder / subtractor 14 in the input / output register 15 and output it as f (x).

【0049】(E)−x2≦x<−x1のとき(図14) このとき、第0サイクルで、レジスタ25にxの仮数部
Aが保持され、指数部レジスタ22にxの指数部mが保
持されている。上式(12)の右辺は、上式(3)の右
辺でxの符号を反転したものに等しいので、上記(D)
の第1〜(p3+m+p2+3)サイクルと同一処理を
行うことにより、上式(11)の右辺の計算結果が加減
算器14から得られる。
(E) When -x 2 ≤x <-x 1 (FIG. 14) At this time, in the 0th cycle, the mantissa part A of x is held in the register 25 and the exponent part of x is held in the exponent part register 22. m is retained. Since the right side of the above equation (12) is equal to the right side of the above equation (3) in which the sign of x is inverted, the above (D)
By performing the same processing as the first to (p3 + m + p2 + 3) cycles of, the calculation result of the right side of the above equation (11) is obtained from the adder / subtractor 14.

【0050】第(p3+m+p2+4)サイクルでは、
図14に示すようにマルチプレクサ28及び29を切換
制御する。そして、加減算器14の出力g(x)とレジ
スタ25の出力e2xとの積を乗算器13で求める。次に
図1のマルチプレクサ10で乗算器13の出力を選択さ
せて、加減算器14の出力を入出力レジスタ15に保持
させ、これをf(x)として出力させる。
In the (p3 + m + p2 + 4) th cycle,
As shown in FIG. 14, the multiplexers 28 and 29 are switch-controlled. Then, the product of the output g (x) of the adder / subtractor 14 and the output e 2x of the register 25 is obtained by the multiplier 13. Next, the output of the multiplier 13 is selected by the multiplexer 10 of FIG. 1, the output of the adder / subtractor 14 is held in the input / output register 15, and this is output as f (x).

【0051】したがって、−x2≦x<−x1のときは、
従来、仮数部−A、指数部mに対し上記(D)の第1〜
(p3+m+p2+3)サイクルの処理を行った後、第
(p3+m+p2+4)サイクルにおいて1−f(−
x)を加減算器14で計算していたのを、本実施例で
は、仮数部A、指数部mに対し上記(D)の第1〜(p
3+m+p2+3)サイクルと同一処理を行った後、上
記第(p3+m+p2+4)サイクルの処理を行うこと
により、すなわち従来と同じ計算時間で、桁落ちなく高
精度でシグモイド関数f(x)の値を求めることができ
る。
Therefore, when -x 2 ≤x <-x 1 ,
Conventionally, with respect to the mantissa part -A and the exponent part m, the first to the above (D)
After performing the processing of the (p3 + m + p2 + 3) cycle, 1-f (-in the (p3 + m + p2 + 4) th cycle
In the present embodiment, x) is calculated by the adder / subtractor 14, but the first through (p) of (D) are calculated for the mantissa part A and the exponent part m.
By performing the same processing as the (3 + m + p2 + 3) cycle and then performing the above-mentioned (p3 + m + p2 + 4) cycle processing, that is, the value of the sigmoid function f (x) can be obtained with high precision without loss of precision in the same calculation time as the conventional one. it can.

【0052】また、図1のハードウエア構成は、従来と
比較すると、従来では、ROM30の出力を直接乗算器
13に供給していたのを、本実施例では、マルチプレク
サ29を備えROM30又は加減算器14の出力を選択
して乗算器13に供給し、また、従来では、マルチプレ
クサ10の入力が4点であったのを、本実施例では、マ
ルチプレクサ10の入力を5点にして乗算器13の出力
をマルチプレクサ10に供給している点で相違し、さら
に制御回路Cの制御方法の点で相違しているが、シグモ
イド関数演算装置全体としては、複雑さの程度は従来と
殆ど同じである。
In the hardware configuration of FIG. 1, the output of the ROM 30 is directly supplied to the multiplier 13 in the prior art as compared with the prior art, but in the present embodiment, the ROM 30 or the adder / subtractor is provided with the multiplexer 29. The output of 14 is selected and supplied to the multiplier 13. Further, in the conventional example, the input of the multiplexer 10 was 4 points. Although the output is supplied to the multiplexer 10 and the control method of the control circuit C is different, the degree of complexity of the sigmoid function arithmetic device as a whole is almost the same as the conventional one.

【0053】次に、図1のシグモイド関数演算装置で用
いられる定数の具体的な数値を、計算精度との関係で説
明する。
Next, specific numerical values of constants used in the sigmoid function computing device of FIG. 1 will be described in relation to calculation accuracy.

【0054】シグモイド関数f(x)の値を比較器18
ビットの精度で得るためには、上式(2)、(3)、
(7)及び(12)の展開最終項を表すp1、p2、p
3及びp2を、p1=8、p2=7、p3=8とし、定
数を次のように設定すればよい。
The value of the sigmoid function f (x) is compared by the comparator 18
To obtain the bit precision, the above equations (2), (3),
P1, p2, p representing the final terms of the expansions of (7) and (12)
3 and p2 are set to p1 = 8, p2 = 7, p3 = 8, and the constants may be set as follows.

【0055】x1=0.78 x2=10.75 β1 =0.5 β3 =−1.66667 β5 =0.0666667 β7 =−0.0269841 β9 =0.109347 β11=−0.00443162 β13=0.00179606 β15=−0.000727917 α1 =1 α2 =1 α3 =0.500006 α4 =0.166668 α5 =0.0416350 α6 =0.00832860 α7 =0.00143927 α8 =0.000204700 また、シグモイド関数f(x)の値を乗算器24ビット
の精度で得るためには、上式(2)、(3)、(7)及
び(12)の展開最終項を表すp1、p2、p3及びp
2を、p1=9、p2=12、p3=9とし、定数を次
のように設定すればよい。
X 1 = 0.78 x 2 = 10.75 β 1 = 0.5 β 3 = -1.66667 β 5 = 0.0666667 67 β 7 = -0.0269841 β 9 = 0.109347 β 11 = -0.00443162 β 13 = 0.00179606 β 15 = -0.000727917 α 1 = 1 α 2 = 1 α 3 = 0.500006 α 4 = 0.166668 α 5 = 0.0416350 α 6 = 0.00832860 α 7 = 0.00143927 α 8 = 0.000204700 Further, in order to obtain the value of the sigmoid function f (x) with a precision of 24 bits of the multiplier, the above equations (2), (3), (7) and (12) ) P1, p2, p3 and p representing the final term of the expansion
2, p1 = 9, p2 = 12, p3 = 9, and the constants may be set as follows.

【0056】x1=0.65 x2=43.67 β1 =0.5 β3 =−1.666667 β5 =0.666667 β7 =−0.02698413 β9 =0.1093474 β11=−0.004431618 β13=0.001796064 β15=−0.0007279172 β17=0.0002950137 α1 =1 α2 =0.9999999 α3 =0.5 α4 =0.1666680 α5 =0.04166689 α6 =0.008328596 α7 =0.001388276 α8 =0.0002046999 α9 =0.00002549920 なお、本発明には外にも種々の変形例が含まれる。X 1 = 0.65 x 2 = 43.67 β 1 = 0.5 β 3 = -1.666667 β 5 = 0.666667 β 7 = -0.02698413 β 9 = 0.1093474 β 11 = -0.0044331618 β 13 = 0.0017996064 β 15 = -0.0007279172 β 17 = 0.0002950137 α 1 = 1 α 2 = 0.99999999 α 3 = 0.5 α 4 = 0.16666680 α 5 = 0. 041666689 α 6 = 0.0083288596 α 7 = 0.001388276 α 8 = 0.0002046999 α 9 = 0.00002549920 The present invention includes various modifications other than the above.

【0057】例えば図6において、ROM34の出力と
定数設定器32の出力とを加減算器14で演算した結果
が初項α0 となればよく、ROM34及び定数設定器3
2の設定値に自由度がある。
For example, in FIG. 6, the result obtained by calculating the output of the ROM 34 and the output of the constant setter 32 by the adder / subtractor 14 should be the first term α 0. The ROM 34 and the constant setter 3
There is a degree of freedom in the setting value of 2.

【0058】また、図11において、乗算器24の出力
-2xをマルチプレクサ23を介しレジスタ25に保持
させ、図12において、レジスタ25の出力e-2xと乗
算器24の出力e-2xとを乗算器24に供給してもよ
い。
[0058] Further, in FIG. 11, the output e -2x of multiplier 24 is held in the register 25 via the multiplexer 23, 12, and an output e -2x output e -2x a multiplier 24 of the register 25 It may be supplied to the multiplier 24.

【0059】[0059]

【発明の効果】以上説明した如く、本発明に係るシグモ
イド関数演算装置及びその演算方法によれば、ハードウ
エア構成を殆ど複雑化することなく、高精度かつ高速で
計算することがが可能になるという優れた効果を奏す
る。
As described above, according to the sigmoid function operation device and the operation method thereof according to the present invention, it is possible to calculate with high accuracy and high speed, without making the hardware configuration complicated. It has an excellent effect.

【図面の簡単な説明】[Brief description of drawings]

【図1】本発明の一実施例のシグモイド関数演算装置の
ブロック図である。
FIG. 1 is a block diagram of a sigmoid function calculation device according to an embodiment of the present invention.

【図2】0≦|x|<x1のときの第1サイクルの動作
説明図である。
FIG. 2 is an operation explanatory diagram of a first cycle when 0 ≦ | x | <x 1 .

【図3】0≦|x|<x1のときの第2サイクルの動作
説明図である。
FIG. 3 is an operation explanatory diagram of a second cycle when 0 ≦ | x | <x 1 .

【図4】0≦|x|<x1のときの第3サイクルの動作
説明図である。
FIG. 4 is an operation explanatory diagram of a third cycle when 0 ≦ | x | <x 1 .

【図5】0≦|x|<x1のときの第4サイクルの動作
説明図である。
FIG. 5 is an operation explanatory diagram of a fourth cycle when 0 ≦ | x | <x 1 .

【図6】x1≦x<x2のときの第1サイクルの動作説明
図である。
FIG. 6 is an operation explanatory diagram of the first cycle when x 1 ≦ x <x 2 .

【図7】x1≦x<x2のときの第2サイクルの動作説明
図である。
FIG. 7 is an operation explanatory diagram of the second cycle when x 1 ≦ x <x 2 .

【図8】x1≦x<x2のときの第3サイクルの動作説明
図である。
FIG. 8 is an operation explanatory diagram of a third cycle when x 1 ≦ x <x 2 .

【図9】x1≦x<x2のときの第(p3+1)サイクル
の後段の動作説明図である。
FIG. 9 is an operation explanatory diagram of the latter stage of the (p3 + 1) th cycle when x 1 ≦ x <x 2 ;

【図10】x1≦x<x2のときの第(p3+2)〜(p
3+m+1)サイクルの動作説明図である。
FIG. 10 shows (p3 + 2)-(p when x 1 ≦ x <x 2
It is operation | movement explanatory drawing of 3 + m + 1) cycle.

【図11】x1≦x<x2のときの第(p3+m+2)サ
イクルの動作説明図である。
FIG. 11 is an operation explanatory diagram of the (p3 + m + 2) th cycle when x 1 ≦ x <x 2 .

【図12】x1≦x<x2のときの第(p3+m+3)サ
イクルの動作説明図である。
FIG. 12 is an operation explanatory diagram of the (p3 + m + 3) cycle when x 1 ≦ x <x 2 ;

【図13】x1≦x<x2のときの第(p3+m+4)サ
イクルの動作説明図である。
FIG. 13 is an operation explanatory diagram of the (p3 + m + 4) th cycle when x 1 ≦ x <x 2 .

【図14】−x2≦x<−x1のときの第(p3+m+p
2+4)サイクルの動作説明図である。
FIG. 14 is the (p3 + m + p) when −x 2 ≦ x <−x 1
It is operation | movement explanatory drawing of 2 + 4) cycle.

【図15】ニューロンモデルを示す図である。FIG. 15 is a diagram showing a neuron model.

【符号の説明】[Explanation of symbols]

10、23、26、27、28、29、31、33 マ
ルチプレクサ 11、12、19、20、32 定数設定回路 14 加減算器 15 入出力レジスタ 16 符号ビット判定・反転回路 17 フラグレジスタ 18 比較器 21 指数部クリア・符号ビット反転回路 22 指数部レジスタ 24、13 乗算器 25 レジスタ 30、34 ROM C 制御回路
10, 23, 26, 27, 28, 29, 31, 33 Multiplexer 11, 12, 19, 20, 32 Constant setting circuit 14 Adder / subtractor 15 Input / output register 16 Sign bit determination / inversion circuit 17 Flag register 18 Comparator 21 Exponent Part clear / sign bit inversion circuit 22 exponent part register 24, 13 multiplier 25 register 30, 34 ROM C control circuit

Claims (2)

【特許請求の範囲】[Claims] 【請求項1】 仮数部がAで指数部がmの入力値xに対
し、xの範囲に応じた、シグモイド関数f(x)の近似
展開式に基づいて、該シグモイド関数f(x)の値を計
算し出力する、シグモイド関数演算装置による演算方法
において、0<x1<x2なる定数x1、x2に対しxが−
2≦x<−x1である場合に、 Aの累乗を算出させ、これと並行して、該Aの累乗と展
開係数α1、α2、・・・、αp3との積α1A 、α
22、・・・、αp3p3を算出させ、さらにこれと並行
して、初項α0 と該積の総和eA=α0 +α1A+・・・
+αp3p3を算出させる第1ステップと、 eAを2m乗させてexを算出させる第2ステップと、 exに基づいてe2x、e4x、e6x、・・・、e2(p2)x
算出させ、これと並行して、−e2x、+e4x、−e6x
・・・、(−1)p22(p2)xを求めさせ、さらにこれと
並行して、g(x)=1−e2x+e4x−e6x+・・・+
(−1)p22( p2)xを算出させる第3ステップと、 g(x)とe2xとの積を算出させ、該積e2xg(x)を
該シグモイド関数f(x)の値とする第3ステップと、 を有することを特徴とする、シグモイド関数演算装置に
よる演算方法。
1. A sigmoid function f (x) is calculated based on an approximate expansion formula of the sigmoid function f (x) according to the range of x for an input value x having a mantissa part A and an exponent part m. In a calculation method using a sigmoid function calculation device that calculates and outputs a value, x is − for constants x 1 and x 2 such that 0 <x 1 <x 2.
When x 2 ≦ x <−x 1 , the power of A is calculated, and in parallel with this, the product α 1 of the power of A and the expansion coefficients α 1 , α 2 , ..., α p3. A, α
2 A 2 , ..., α p3 A p3 is calculated, and in parallel with this, the sum of the first term α 0 and the product eA = α 0 + α 1 A + ...
+ Alpha p3 A p3 a first step of calculating a second step of calculating a e x by the e A 2 m-th power is, e based on e x 2x, e 4x, e 6x, ···, e 2 (p2) x is calculated, and in parallel with this, −e 2x , + e 4x , −e 6x ,
..., (- 1) allowed sought p2 e 2 (p2) x, and further parallel with this, g (x) = 1- e 2x + e 4x -e 6x + ··· +
(-1) and the third step of calculating the p2 e 2 (p2) x, g of (x) and to calculate the product of the e 2x, integrating e 2x g (x) the sigmoid function f (x) An arithmetic method using a sigmoid function arithmetic device, comprising:
【請求項2】 仮数部がAで指数部がmの入力値xに対
し、xの範囲に応じた、シグモイド関数f(x)の近似
展開式に基づいて、該シグモイド関数f(x)の値を計
算し出力するシグモイド関数演算装置において、 レジスタ(25)と、 第1入力端に供給された値と第2入力端に供給された値
との積を算出する第1乗算器(24)と、 該レジスタの出力と該第1乗算器の出力との一方を選択
して該第1乗算器の該第1入力端に供給する第1マルチ
プレクサ(26)と、 該レジスタの出力と該第1乗算器の出力との一方を選択
して該第1乗算器の該第2入力端に供給する第2マルチ
プレクサ(27)と、 関数を多項展開したときの初項以外の各項の係数が設定
された係数設定手段(30)と、 第1入力端に供給された値と第2入力端に供給された値
との積を算出する第2乗算器(13)と、 該関数を多項展開したときの該初項に対応した値が設定
された初項設定手段(34)と、 定数が設定された定数設定手段(32)と、 第1入力端に供給された値と第2入力端に供給された値
との和又は差を算出する加減算器(14)と、 該レジスタの出力と該第1乗算器の出力との一方を選択
して該第2乗算器の該第1入力端に供給する第3マルチ
プレクサ(28)と、 該係数設定手段の出力と該加減算器の出力との一方を選
択して該第2乗算器の該第2入力端に供給する第4マル
チプレクサ(29)と、 該定数設定手段の出力と該加減算器の出力との一方を選
択して該加減算器の該第1入力端に供給する第5マルチ
プレクサ(31)と、 該初項設定手段の出力と該第2乗算器の出力との一方を
選択して該加減算器の該第2入力端に供給する第6マル
チプレクサ(33)と、 該シグモイド関数をどの展開式で求めるかを決定するた
めのxの範囲を判定する判定手段(16〜20)と、 該判定手段による判定結果に応じて、該第1〜6マルチ
プレクサを切換制御し、該第1乗算器、該第2乗算器及
び該加減算器に演算を実行させて該シグモイド関数の値
を求めさせる制御手段(C)とを有し、 該制御手段は、0<x1<x2なる定数x1、x2に対し、
該判定結果が−x2≦x<−x1である場合に、 該第1乗算器に対し、第1乗算器の出力と該レジスタの
出力Aとの積を繰り返し算出させてAの累乗を算出さ
せ、これと並行して、該第2乗算器に対し、該第1乗算
器の出力と該係数設定手段の出力との積を算出させ、さ
らにこれと並行して、該加減算器に対し、最初は該初項
設定手段の出力と該定数設定手段の出力との演算結果α
0 を出力させ、次に、該第2乗算器の出力と該加減算器
の出力との和を繰り返し算出させることにより、該加減
算器からeA=α0 +α1A+・・・+αp3p3を出力さ
せて該レジスタに保持させ、 次に、該第1乗算器に対し、該レジスタの出力を平方さ
せてその結果を該レジスタに保持させる処理を繰り返さ
せることにより、該レジスタから、eAを2m乗したeX
を出力させ、 次に、該第1乗算器に対し、該レジスタの出力eXを平
方させてその結果を該レジスタに保持させ、次に、該第
1乗算器の出力と該レジスタの出力との積を算出させる
処理を繰り返させることにより、該第1乗算器から
2x、e4x、e6x、・・・、e2(p2)xを出力させ、これ
と並行して、該第2乗算器に対し、該第1乗算器の出力
と該係数設定手段の出力との積−e2x、+e4x、−
6x、・・・、(−1)p22(p2)xを算出させ、さらに
これと並行して、該加減算器に対し、最初は該初項設定
手段の出力と該定数設定手段の出力との演算結果1を出
力させ、次に、該第2乗算器の出力と該加減算器の出力
との和を繰り返し算出させることにより、該加減算器か
らg(x)=1−e2x+e4x−e6x+・・・+(−1)
p2 2(p2)xを出力させ、 次に、該第2乗算器に対し、該加減算器の出力g(x)
と該レジスタの出力e 2xとの積を算出させ、該積e2x
(x)を該シグモイド関数f(x)の値として出力させ
ることを特徴とするシグモイド関数演算装置。
2. An input value x whose mantissa is A and whose exponent is m
And the approximation of the sigmoid function f (x) according to the range of x
The value of the sigmoid function f (x) is calculated based on the expansion formula.
In a sigmoid function operation device for calculating and outputting, a value supplied to a register (25), a first input terminal, and a value supplied to a second input terminal
A first multiplier (24) for calculating the product of and, and selecting one of the output of the register and the output of the first multiplier
And supplies the first multi-input to the first input terminal of the first multiplier.
Selector (26), one of the output of the register and the output of the first multiplier
And then supplies the second multi-input to the second input terminal of the first multiplier.
Plexer (27) and the coefficient of each term other than the first term when the function is polynomial expanded are set.
Coefficient setting means (30), the value supplied to the first input end and the value supplied to the second input end
A second multiplier (13) for calculating the product of and, and a value corresponding to the first term when the function is polynomial expanded are set.
The first term setting means (34), the constant setting means (32) for which a constant is set, the value supplied to the first input end and the value supplied to the second input end.
An adder / subtractor (14) for calculating the sum or difference between and, and selecting one of the output of the register and the output of the first multiplier
And supplies the third input signal to the first input terminal of the second multiplier.
The multiplexer (28) and one of the output of the coefficient setting means and the output of the adder / subtractor is selected.
And a fourth round signal which is selectively supplied to the second input terminal of the second multiplier.
A chipplexer (29) and one of the output of the constant setting means and the output of the adder / subtractor is selected.
A fifth multi-selector for supplying the first input terminal of the adder / subtractor
A plexer (31) and one of the output of the first term setting means and the output of the second multiplier
A sixth circle which is selected and supplied to the second input terminal of the adder / subtractor.
The chipplexer (33) and the expansion equation for determining the sigmoid function
Determination unit (16 to 20) for determining the range of x, and the first to sixth multis according to the determination result by the determination unit.
The first multiplexer, the second multiplier and the multiplier are switched and controlled.
Value of the sigmoid function by causing the adder / subtractor to execute an operation.
And a control means (C) for determining1<X2Constant x1, X2As opposed to
The determination result is -x2≤x <-x1, The output of the first multiplier and the register
The power of A is calculated by repeatedly calculating the product with the output A.
In parallel with this, the first multiplier is applied to the second multiplier.
The product of the output of the instrument and the output of the coefficient setting means,
In parallel with this, the first term for the adder / subtractor is
Calculation result α of the output of the setting means and the output of the constant setting means
0Is output, and then the output of the second multiplier and the adder / subtractor
By repeatedly calculating the sum with the output of
E from calculatorA= Α0+ Α1A + ... + αp3Ap3Is output
Hold the output in the register, and then, for the first multiplier,
Then, the process of holding the result in the register is repeated.
To allow e from the registerAE raised to the power of 2 mX
And then output the output e of the register to the first multiplier.XFlat
The result and hold the result in the register.
1 Calculate the product of the output of the multiplier and the output of the register
By repeating the process, the first multiplier
e2x, E4x, E6x, ... e2 (p2) xAnd output this
In parallel with the output of the first multiplier to the second multiplier
And the output of the coefficient setting means −e2x, + E4x,-
e6x, ..., (-1)p2e2 (p2) xAnd calculate
In parallel with this, the initial term setting is first performed for the adder / subtractor.
The calculation result 1 of the output of the means and the output of the constant setting means is output.
Then the output of the second multiplier and the output of the adder-subtractor
By repeatedly calculating the sum of
G (x) = 1-e2x+ E4x-E6x+ ... + (-1)
p2e 2 (p2) xIs output, and then the output g (x) of the adder / subtractor is output to the second multiplier.
And the output e of the register 2xAnd the product e is calculated.2xg
(X) is output as the value of the sigmoid function f (x).
A sigmoid function operation device characterized by the following.
JP4347620A 1992-12-28 1992-12-28 Sigmoid function arithmetic unit and its computing method Withdrawn JPH06203058A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP4347620A JPH06203058A (en) 1992-12-28 1992-12-28 Sigmoid function arithmetic unit and its computing method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP4347620A JPH06203058A (en) 1992-12-28 1992-12-28 Sigmoid function arithmetic unit and its computing method

Publications (1)

Publication Number Publication Date
JPH06203058A true JPH06203058A (en) 1994-07-22

Family

ID=18391456

Family Applications (1)

Application Number Title Priority Date Filing Date
JP4347620A Withdrawn JPH06203058A (en) 1992-12-28 1992-12-28 Sigmoid function arithmetic unit and its computing method

Country Status (1)

Country Link
JP (1) JPH06203058A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11733970B2 (en) 2019-09-20 2023-08-22 Kabushiki Kaisha Toshiba Arithmetic operation circuit

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11733970B2 (en) 2019-09-20 2023-08-22 Kabushiki Kaisha Toshiba Arithmetic operation circuit

Similar Documents

Publication Publication Date Title
KR100284799B1 (en) Exponential circuit using shifting means and method of use
US5313415A (en) Method and apparatus for performing floating point arithmetic operation and rounding the result thereof
US5506797A (en) Nonlinear function generator having efficient nonlinear conversion table and format converter
JPH0784975A (en) Information processor and learning arithmetic processing method
JPH04332036A (en) Floating decimal point multiplier and its multiplying system
JPS597990B2 (en) N-point discrete Fourier transform calculation device
JPH06203058A (en) Sigmoid function arithmetic unit and its computing method
JPS5939774B2 (en) Exponential function calculation method
JPH10111791A (en) Division device
Prasanna et al. An Efficient Fused Floating-Point Dot Product Unit Using Vedic Mathematics
KR940008610B1 (en) Method and processor for high-speed convergence factor determination
KR0176883B1 (en) Complex number multiplier
RU1784975C (en) Arithmetic-integrating device
Maffezzoni et al. VLSI design of radial functions hardware generator for neural computations
SU1608660A1 (en) Device for computing positional characteristics of modular code
JPH0414173A (en) Fixed point product sum computing element
JPH06105421B2 (en) Inverse trigonometric function calculator
EP1197874A1 (en) Signal processor and product-sum operating device for use therein with rounding function
JPS63195771A (en) Product sum arithmetic circuit
JPH032970A (en) Arithmetic circuit
WO2003071687A1 (en) Data processing device
SU661549A1 (en) Arithmetic device
JP3696307B2 (en) Product-sum operation unit
SU964635A1 (en) Conveyer device for computing functions
SU877575A2 (en) Device for computing random process dispersion

Legal Events

Date Code Title Description
A300 Withdrawal of application because of no request for examination

Free format text: JAPANESE INTERMEDIATE CODE: A300

Effective date: 20000307