Pattern Recognition Letters 7 (1988) 19 25 North-Holland
.lanuary 1988
Handprinted Chinese character recognition via neural networks Yao Y O N G * Institute ~[ Electrical Engineering and Computer Sciences, Shanghai Jiao Tong University, Shanghai, ('hina Received 17 April 1987 Revised 2(1 September 1987
Abstract. A new recognition scheme for handprinted Chinese Characters is presented, which is composed of two phases: a stroke recognizing phase in which a handprinted character is matched with a standard character whose code is the closest ~o that of the handprinted character. The main idea is to use neural networks instead of a digital computer to perform the task of recognition. The charactcr recognizing neural network is based on the neural network model of a content addressable associative memory (CAAM) developed in this paper. In the C A A M model, one thing will remind us of another, and partial information can retrieve the whole. Simulation results demonstrating the performance of the neural network model are presented. The model may be extended so that it will be also useful in understanding some other pattern analysis in biological systems. Key words: Neural network, content addressable associative memory (CAAM), handprinted Chinese character, recognition.
!. Introduction
About one third of the world's population can read Chinese. Most of them also write in Chinese in their daily lives. While recognizing handwritten Chinese characters is simple and efficient for us, such a task is very difficult for present computers. Within the past two decades, much research in the recognition of handprinted Chinese characters has been carried out. For on-line recognition, although individual's handwriting of Chinese characters has been recognized with more than 95% precision (under some reasonable restrictions), the recognition speed is only about one character per second [1]. Thus the most important research question is how to enhance the processing speed. In [2], Hopfield has renewed interest in neural network models and has shown that arrays of high-
* At present, the author is with the Department of Electrical Engineering and Computer Sciences, University of California, Berkeley, CA 94720, USA.
ly interconnected saturable amplifiers can perform calculations using collective properties similar to those observed in biological systems. Recently, there has been a mounting interest for researchers in problems related to pattern recognition [3], associative memory [4], and neural networks [5]. The aims of this paper are to develop a neural network model of a content addressable associative memory (CAAM) based on the Hopfield model [2] and to consider the application of the C A A M model to handprinted Chinese character recognition.
2. Neural network model of CAAM: A simple case
The use of analog networks to implement associative or content addressable memories has been studied previously (see, for example [3]). Here, beginning with Hopfield's work [2], we develop a model of C A A M , which can find a whole item starting from its partial content, and can remind us of some other items. For simplicity, we restrict our attention to the case in which one memory will at most asso-
0167-8655,'88/$3.50 (~ 1988, Elsevier Science Publishers B.V. (North-Holland)
19
Volume 7, N u m b e r l
PATTERN RECOGNITION LETTERS
J a n u a r y 1988
-L Cg /,/5
T
?
Figure 1. A content addressable associative memory: A simple case.
ciate with one other m e m o r y . The circuit of the C A A M model is sketched in Figure 1. The circuit can be described by the following differential equations: du i
Cs' dt
ui
-
N
+ ~ TijVj+Ii, 7s, j 1 =
N
7y,'=RylI+ Y IT, jI, j
dtt k
cgk dt
tt k
--
7xk
i = 1 , 2 .... N,
(1)
1
Furthermore, in Figure 1 let all of the amplifiers f l ...... /~. be identical, with input/output relationship shown in Figure 2a, let all of the amplifiers gl . . . . . gN also be identical, with input output characteristic of Figure 2b. The only difference between f and g is their thresholding values. The former is zero, and the latter is 1/2. Let Cf l
= Cf 2 . . . . .
R f , = R j, . . . . . % = % = ....
.~,'
~- 2 HkiVi-~- Ik,
i= 1
R~, = Rx~' = . . . .
C f N = Cf ,
gfN = R f, c~.~ = C~,
Rx~~ = Rx,
N
?g 1 = Rg 1 + Z lHkil ,
i = 1,2 ..... N,
(2)
with csR s 4~ %R~.
i=1
where 17/=.li(ui) = (1 + e ~ " ' ) 1 (see Figure 2).
With this choice of parameters, the C A A M model can be d e c o m p o s e d into two subnetworks (see
S --.U
Figure 2. I n p u t - o u t p u t curves of amplifiers (a) for./"1...... /~,' (b) for gl ..... g~. 20
//
Volume 7. N u m b c r 1
PATTERN RECOGNITION LETTERS
Figure 1). The dynamics of the subnetwork 1, $1, are much faster than that of the subnetwork 2, $2. Therefore when daling with the dynamics of $2, we may consider that S~ has reached steady-state. N o w suppose we wish to store several memories V= ( s = 1,2 ..... n, n < ~ N ) in the C A A M model, where there are q memories (say by V ~. . . . . Vq), each of which, V~, is to be stored together with its associative m e m o r y ~ ( < i _< q, q < n). The most important thing is how to choose T u and Hk~. Assume V ~, V2..... V" are linearly independent, and Pl, ~2 . . . . . ~'q are lineary independent too. Then the choice of T,.j follows H e b b ' s rule [6]: Tzj = ~ (2 V~- 1)(2 V] - 1 ) s
(3)
1
where i ¢ j and T, = 0. U n d e r this choice, V= (s = 1,2 ..... n) will be the equilibrium of the subnetwork 1 as long as n <~ N [2]. In order that V~ ..... I~q be stable equilibria of $2, and that $2 approaches (/= (! < s < q) while the subnetwork 1 tends to V~, we must choose Hk~ to satisfy the following matrix equation:
(Hki)N × N( V1 V 2 " " vq) = ( ~/1 ~/2... ~/q).
HN_ q :
January 1988
...hNq
"
(7) then
l<_k<_Nandq+l
Hki = 0.
Hq:
(8)
where assume the existence of Vq ~ since V x..... V" are linearly independent. For example, assume we wish to store three memories V ~, V 2, V 3 and their associative m e m o ries I~1, ~ 2 ft3 in the fast subnetwork and in the slow subnetwork, respectively: Vl=(11000100101011000000), V2 : ( 0 l 101000010001110001), V3 = ( 0 0 1 1 0 1 0 1 1 0 1 1 1 0 0 0 0 0 0 0 ) ,
V~--(10001110110010101110), I~2=(010 I 0100111010110011), t~3=(10011001000111010000).
(4) F r o m the following initial condition:
To see this, let us discuss the thresholding function of amplifier g. In (2), let I k = 0. Then dfi~ dt
N -
0
yields
fik : )'gk ~'~ HkiVi"
(5)
i: 1
V=(01001001010001110001), V= (00000000000000000000), the C A A M model tends to V 2 and p2.
W h e n V~ = V~ (i = 1,2 . . . . . N, 1 < s_< q), this yields ffk:7~'l?~=~_"
(6)
ifl~F,=O.
That is to say: t7"=is a stable equilibrium of the subnetwork 2 as well as corresponds to V= (s = 1,2 . . . . . q) provided that 7e~ > 1/2, which m a y be guaranteed through the choice of ReIf we denote
I.Hll""/%1
=
'
vj...v
3. Neural network model of CAAM: General case F r o m the above, we know that in the simple case of the C A A M model, on one hand the neural network can memorize n items V ~..... V", and some of them may remind of others respectively. O n the other hand, if the network is started near enough to any V= (1 < s _< n), it will proceed in time until V = VL These are the essential characteristics of a content addressable memory. In the C A A M model, the error correcting power can be understood without the need to follow the network dynamics in detail. Generally, at times one thing m a y remind us of more than one other in our h u m a n brains. To simulate this biological function yields the following neural network (see Figure 3). The network consists of one fast subnetwork and p slow subnetworks. 21
Volume 7, Number 1
PATTERN RECOGNITION LETTERS
January 1988
1N
T 2N
I
7
BI
S1
~" l
i
I I
I
I
I
{__
!°
$2
0 0 0
7 Sp+l
I¢I')
WN
Figure 3. A content addressable associative memory: General case.
In Figure 3, if V" (1 < s _< n) reminds of h others (1 _< h _< p), then there are h slow subnetworks associated with V". The synaptic interconnection matrix (H~li))u × N, I = ! . . . . . p can be constructed similarly to (4). As we notice, the key point of the C A A M model is that the neural network is split in two parts: one fast subnetwork and several slow subnetworks. This idea m a y be extended to the more general situation. See the following abstract formation (Figure 4). The fast-slow network structure will allow us to treat P and leg ( i = 1,2 ..... N; k = 1,2 ..... M) separately, i.e. when we treat the fast subnetwork, we
S1
S 2 • - . Sp
FAST
SLOW
can consider l?k is unchanged, and Vi m a y be considered in its steady-state when we treat the slow subnetwork. F o r pattern recognition, m a y b e one of the parts will help us understand the overall structure of the object, and another will tell us the detail. By examining the Hopfield original model from the point of view of biology, we consider that the neuronal form, analogy, massive parallelism, and high interconnectivity are essential, while the features of symmetry, fixed synaptic connections, uniformity, same dynamics a m o n g the neurons are not necessary. Thus by calling the abstract structure a neural network, we mean it is in ' n e u r o n a l ' form, and the featuring high parallelism, and interconnectivity. In the rest of paper, we discuss the application of the model shown in Figure 3 to handprinted Chinese character recognition. Some applications of the model shown in Figure 4 will be studied in a later paper.
4. A new recognition scheme of handprinted chinese characters
Figure 4. An abstract neural network model. 22
N o w let us consider the recognition of handprinted Chinese characters. This can be done with
Volume 7, N u m b e r l
PATTERN RECOGNITION LETTERS
,
--
I ) \
,'
)
---
7
L z
L
E
January 1988 3
J (
Figure 5. Twenty basic strokes of Chinese characters.
some serial algorithms [1], but is computationally expensive. We hope that at least the major task of the recognition can be completed with 'neural' hardware rather than some algorithm. In the neural network model of CAAM, each 'neuron' is simple, and computation is massively paralleled, so information processing in the neural network will be much faster than in conventional serial digital computers. Let us apply our CAAM model to some stages of the process of recognition of handprinted Chinese characters. The recognition scheme consists of two phases: a stroke recognizing the phase in which a handprinted character is encoded, and a character recognizing the phase in which the handwriting character is matched with a standard character whose code is the closest to that of the handwriting character. Since there are about 6000 commonly used Chinese characters, most information processing occurs in the second phase. In the following section, we will show how the second phase can be carried with a certain CAAM circuit model. Before doing this, let us give a brief discussion of how to encode a Chinese character. The strokes of Chinese characters may roughly be classified into 20 basic strokes (see Figure 5), and each of the basic strokes consists of one or more segments. Any segment will be characterized by one of eight orientation features (see Figure 6). On average, a Chinese character has 8 to 12 basic strokes and each basic stroke consists of two segments, where every character has its writing order 1. Thus we will use the first twenty segments of each of the Chinese characters to encode it. If some characters are of less than twenty segments, zeroes are added Using the recognition scheme developed in the paper, one has to prepare the article on a special kind of plane named symbolization plane, which is already available. With the symbolization plane, a character is transformed into a point sequence (x~, Yl) through a light-electricity convertor. Thus, the writing order of the character is memorizing while one writes on the symbolization plane.
J,7
z._ 1
/76
/
Figure 6. Eight orientation features of segments.
to make up the dificit. For instance, in Figure 7a (where arrows indicate the order of strokes), the character has a code 17100 000 000 000 000 000. In terms of the encoding rule, every Chinese character can be mapped to a code. There are, however, a few cases in which more than one character has the same code (see Figure 7b). For other encoding rules now available, the phenomenon of two or more characters having the same code in unavoidable because of the complicated structure of Chinese characters. Keeping this fact in mind, we discuss how to complete the character recognization phase using the neural network model of CAAM.
5. Character recognizing via neural networks
Let X be a recognized handprinted Chinese character, whose code has been obtained in the stroke recognizing phase. First of all, the decade code is transformed to its binary form. Any character has an 80-bit binary code because every orientation feature can be expressed using a 4-bit binary word. Assume that V 1 , V 2 . . . . . Vl°°°e{0, 1}s° are the
f7"~ f
/
1
1
1
Figure 7. Encoding a Chinese character, where two different characters in (a) and (b) have the same code and the arrows indicate the writing order. 23
Volume 7, Number
January 1988
PATTERN R E C O G N I T I O N LETTERS
1
/]
18o
T I0000,80
|
H 80,1 tp~
•
T8o,81
i
• • '
10000
V
L
I-
]L~~'_".
L
f
J
¢ .
Vl
I
I
_
+
v80 Figure 8. A character recognizing neural network model.
standard binary codes of 6000 c o m m o n l y used characters, which should be stored in the fast subnetwork of the C A A M model as memories. Thus T u can be chosen as follows: 6000
Tq =
~ (2V s -
1 ) ( 2 V ~ - 1),
s = l
i,j = 1,2 ..... 10000.
(9)
where V7 = V~ = 0 when i, j > 80. That is 0
i f / > 80 and.j > 80,
6 000
Tu =
~ (I-2V~)
ifj>80,
(10)
S=I
6000
(1 - 2V])
i f / > 80,
In another point of view, a Chinese character ts characterized by a 10000-bit binary word, but only the first 80 bits m a y not be zero. W h y so much zeros introduced is to guarantee that the fast subnetwork has 6000 equillibria which correspond to 6000 standard Chinese characters one by one. Here we suppose these 6000 characters have different codes from each other. While the characters whose codes are same as some of the 6000 characters will be stored in the slow subnetworks. Then, we know that the fast subnetwork is c o m p o s e d of 10000 24
recognition neurons connected by conductances ] Tij [ (i,j = 1, 2 . . . . . 10000). Let us consider the slow subnetworks in the C A A M model. As we have mentioned above, there are a few cases in which two or more characters have the same code. It can be solved using the slow subnetwork. Assume p ( < 7) is the m a x i m u m value of the numbers of characters whose codes are the same as one of the 6000 characters. Thus p slow subnetworks are adopted. Unlike the fast subnetwork, the n u m b e r of recognition neurons in each slow subnetwork is just 80. U p to now, the neural network for solving the character recognizing phase can be constructed (see Figure 8). In Figure 8, H}~ ~ (k,i = 1,2 . . . . . 80; l = 1,2 ..... p) can be chosen as follows: Assume V a, V2..... V q possess codes which are the same as some others, the rest of the 6000 characters are matched with their codes, one by one. Next, some characters should be recharacterized. As an example, let pl, 1..... p~, r, Vi (1 _< i < q, r _< p) have the same code. Then the orientation features of the first segments of U ' l ..... P~'r are changed to be 9 . . . . . 8 + r, respectively. T h r o u g h this recharacterization, there is no two characters with the same code. The interconnection matrix
( H;~,~)80 × so( V 1..... V q) = ( ~-t ,l ..... ~/q. t),
Volume 7, N umber I
l:
1,2 ..... p.
P A T T E R N R E C O G N I T I O N LETTERS
(11)
If there are only r characters whose codes are the same as some of the 6000 commonly used characters before recharacterized, and r < p, then let Vi't=O,l=r
+ 1 . . . . . p.
6. Conclusion and c o m m e n t s
The major theme in this paper has been the processing of information in neural networks that serve as a model of a content addressable associative memory. This approach provides a tool which quickly performs the main task in handprinted Chinese character recognition. Conventionally, memory is characterized in terms of storing information in some place. Any two pieces of information are at different places. The process of rectrieval has been considered as 'finding the right place in memory'. However, from the context, we tend to consider that to store any individual item needs many interconnected neurons, and these neurons can also store certain numbers of items simultaneously. Information is better thought of as 'evoked' than 'found'. A biological memory not only has its memorizing capacity, but also computing power. On the other hand, forgetting something will not always be thought of as a bad thing, which may save space and make information retrieval more precisely. May be clearing old and unusable information takes place wery often in our human brains so that the brains can remain its efficient memory and computation. With the development of VLSI C A D technology,
January 1988
it is not hard to manufacture neural networks with 10000 neurons. Thus the neural networks developed in the paper are feasible in practice. Their effectiveness can be understood if one notices that the configuration space of the networks has 2 a° elements and only 6000 characters are desired to be stored as memories. So the characters are distributed sparsely so that a polluted character can also be mapped to its standard code. In fact, the new recognition scheme of handprinted Chinese characters is a hybrid implementation, i.e. the neural network is actually attached as a coprocessor to a standard computer. The neural network shares some tasks which need much information processing, and the rest of the jobs are still done by computers. Since every person has his own writing habit and his own character style, a real and fast Chinese character recognizing machine will still call for careful study. References [1] Pei-jie, Yie (1987). On-line computer recognition of handprinted Chinese characters. Aeta Automatica Siniea 13 (I) 24~29. [2] Hopfield, J.J. (1982). Neural networks and physical systems with emergent computational abilities. Proc. Natl. Acad. Sci. 79, 2554 2560. [3] Arbib, M. and A.R. Hanson (eds.) (1985). Vision, Brain and Cooperative Computation. MIT Press Cambridge, MA. [4] Hinton, G.E. and J.A. Anderson (Eds.) ( 1981 ). Parallel Models o f Associative Memory. Laurence Erlbraum Associate Inc. [5] Hopfield, J.J. and D.W. Tank (1986). Computing with neural circuits: A model. Science 233 (4764), 625 636. [6] Hebb, D.O. (1949). The Organization ¢~f Behavior. Wiley, New York.
25