extfieldsofstudy:
Engineering
Computer Science
Physics
Mathematics

text:
Learned imaging with constraints and uncertainty quantification

We outline new approaches to incorporate ideas from convolutional networks into wave-based least-squares imaging. The aim is to combine hand-crafted constraints with deep convolutional networks allowing us to directly train a network capable of generating samples from the posterior. The main contributions include combination of weak deep priors with hard handcrafted constraints and a possible new way to sample the posterior. The seismic imaging problem In least-squares imaging, we are interested in inverting the following inconsistent mildly ill-conditioned linear inverse problem:

The seismic imaging problem
In least-squares imaging, we are interested in inverting the following inconsistent mildly ill-conditioned linear inverse problem: In this expression, the unknown vector x represents the image, y i , i = 1, . . . , N the observed data from N experiments and A i the discretized linearized forward operator for the ith source experiment. Despite being overdetermined, the above least-squares imaging problem is challenging. The linear systems A i are large, expensive to evaluate, and inconsistent because of noise and/or linearization errors.
As in many inverse problems, solutions of problem 1 benefit from adding prior information in the form of penalties or preferentially in the form of constraints, yielding with C representing a single or multiple (convex) constraint set(s). While this approach offers flexibility to include multiple handcrafted constraints, several key issues remain, namely; (i) we can not afford to work with all N experiments when computing gradients for the above data-misfit objective; (ii) constrained optimization problems converge slowly; (iii) handcrafted priors may not capture complexities of natural images; (iv) it is non-trivial to obtain UQ information.

Stochastic linearized Bregman
To meet the computational challenges that come with solving problem 2 for non-differentiable structure promoting constraints, such as the 1 -norm, we solve problem 2 with Bregman iterations for a batch size of one. The kth iteration readsx with A k the adjoint of A k and P C (x) = argmin being the projection onto the (convex) set and t k = A k x − y k 2 2 / A k (A k x − y k ) 2 2 the dynamic steplength. Contrary to the Iterative Shrinkage Thresholding Algorithm (ISTA), we iterate on the dual variablex. Moreover, to handle more general situations and to ensure we are for every iteration feasible (= in the constraint set) we replace sparsity-promoting thresholding with projections that ensure that each model iterate remains in the constraint set. As reported in Witte et al. [2019], iterations 3 are known to converge fast for pairs {y k , A k } that are randomly drawn from iteration to iteration. As such, Equation 3 can be interpreted as stochastic gradients on the dual variable.
To illustrate the improved convergence of Equation 3, we consider two linearized imaging examples. The first involves sparsity-promoting least-squares migration with curvelet domain thresholding, which solves where C is the curvelet transform matrix and λ the threshold level. The results of 50 thresholded Bregman iterations (we stop early do not overfit) are included in Figure 1. This example clearly shows the advantage of the redrawing pairs {y i , A i }. Similarly, we also improve the convergence when imposing the TV-norm [Esser et al., 2018, Peters et al. [2018] at each Bregman iteration. For this specific type of image, TV-norm minimization gives superior results compared to curvelets (cf. Figure 1). We also assumed knowledge on the size of the TV-ball τ , which we imposed as a constraint when solving

Stochastic deep prior with constraints
Handcrafted priors, encoded in the constraint set C, in combination with stochastic optimization, where we randomly draw a different source experiment for each iteration of Equation 3, have proven to be scalable allowing us to create high-fidelity images by only working with random subsets of the data. While encouraging, this approach relies on handcrafted priors encoded in the constraint set C. Motivated by recent successes in machine learning and deep convolutional networks (CNNs) in particular, we follow Van Veen et al. [2018] propose to incorporate CNNs as deep priors on the model. Compared to handcrafted priors, deep priors defined by CNNs are less biased since they only require the model to be in the range of the CNN, which includes natural images and excludes images with unnatural noise. In its most basic form, this involves solving problems of the following type [Van Veen et al., 2018]: In this expression, g(z, w) is a deep CNN parameterized by unknown weights w and z ∼ N(0, 1) is a fixed random vector in the latent space. In this formulation, we replaced the unknown model by a neural net. This makes this formulation suitable for situations where we do not have access to data-image training pairs but where we are looking for natural images that are in the range of the generator. In recent work by Van Veen et al. [2018], it is shown that solving problem 7 can lead to good estimates for x via the generator g(z, w) where w is the minimizer of problem 7 highly suitable for situations where we only have access to data. In this approach, the parameterization of the network by w for a fixed z plays the role of a non-linear redundant transform. While using neural nets as strong constraints-i.e. problem 7 is equivalent to may offer certain advantages, there are no guarantees that the model iterates remain physically feasible, which is a prerequisite if we want to solve non-linear imaging problems that include physical parameters [Esser et al., 2018, Peters et al. [2018]. Unless we pre-train the network, early iterations solving problems 7 or 8 will be unfeasible. Moreover, as mentioned by Van Veen et al. [2018], results from solving inverse problems with deep priors may benefit from additional types of regularization. We accomplish this by combining hard handcrafted constraints with a weak constraint for the deep prior resulting in a reformulation of the program 8 into minimize x∈C, w In this expression, the deep prior appears as a penalty term weighted by the trade-off parameter λ > 0. In this weak formulation, x is a slack variable, which by virtue of the hard constraint will be feasible throughout the iterations.
The above formulation offers flexibility to impose constraints on the model that can be relaxed during the iterations as the network is gradually "trained". We can do this by either relaxing the constraint set (eg. by increasing the size of the TV-norm ball) or by increasing the trade-off parameter λ.

Learning posterior statistics through inversion
While the combination of hard and soft constraints offers flexibility to get the best of handcrafted and deep priors, we have not exploited the fact that generative models are when trained properly capable of generating samples from a distribution. After training, samples from the generator are produced by via nonlinear mappings of random realizations of the latent variable z ∼ p z (z) to g(z, w * ).
Unfortunately, in inverse problems, it is often difficult, if not impossible, to have access to training pairs {x i , y i } to obtain estimates for w, as outlined in recent work by Adler and Öktem [2018] on deep Bayesian inversion. These authors argue that information on the posterior distribution can be obtained by a direct method, which estimates different moments (e.g. mean over standard deviation) of the posterior distribution, or by estimating the posterior during training by minimizing the Wasserstein p = 1 distance between the statistics of the generator and the posterior. The latter approach leads to a supervised training method, wich involves a Generative Adversarial Network, training pairs {x i , y i }, and random draws of the latent space variable z ∼ p z (z).
Since we do not have access to training pairs, we instead propose to solve problem 9 for different pairs {x, y i }, where x represents a single Earth model within the survey area and y i data obtained from multiple source experiments with that same area. We solve this problem by taking a single (expensive) Bregman step followed by multiple (cheap) neural network updates during which we redraw the latent variable z ∼ p z (z). Strictly speaking this approach, summarized in Algorithm 1, corresponds to solving an inverse problem but because we have multiplicity in the data, the argument can be made we are at the same time training the generator to produce random samples from the posterior via g(z, w * ) and z ∼ p z (z) where the w * is found by carrying out the iterations in Algorithm 1.

Example
To test our speculation that solving problem 10 with stochastic gradient descent on the dual not only yield in image but also reaps information on the posterior, we conduct an experiment where the source experiments contain incoherent noise and coherent linearization errors, e = (F k (m + δm) − F k (m) − ∇F k (m)δm), where A k = ∇F k is the Jacobian and F k (m) is the nonlinear forward operator. The results of this experiment are included in Figure 2 from which we make the following observations. First, as expected the models generated from g(z, w * ) are smoother than the primal Bregman variable. Second, there are clearly variations amongst the different g(z, w * )'s and these variations average out in the mean, which has fewer imaging artifacts.
Because we were able to train the g(z, w) as a "biproduct" of the inversion, we are able to compute statistical information from the trained generator that may give us information about uncertainty. In Figure 3, we Algorithm 1 Stochastic weak deep prior imaging with constraints. input: Latent space distribution, p z (z) N Pairs of observed data and discretized linearized forward operators, Trade-off parameter, λ > 0 Projection operator, P C (·) Maximum training steps, M Inner loop generator optimization steps, T Generator learning rate, η initialization Randomly initialize generator parameters, w Initialize primal variable (unknown vector) with zeros Initialize dual variable with zeros end for end for output: w included a plot of the pointwise standard deviation and two examples of sample "prior" (before training) and "posterior" distribution functions. As expected, the pointwise standard deviations show a reasonable sharpening of the probabilities before and after training through inversion. We also argue that the areas of high pointwise standard deviation coincide with regions that are difficult to image because of the linearization error and noise.

Discussion and Conclusions
Solving large-scale inverse problems with expensive to evaluate forward models is challenging by itself. For this reason, the problem of obtaining uncertainty information remains elusive except for certain special situations [see e.g. Fang et al., 2018]. While we do not yet offer formal proof, we argue that the presented method, which combines stochastic optimization on the dual variable with on-the-fly estimation of the generator's network weights, reaps information on the posterior distribution leveraging multiplicity in the data and the fact that this data is acquired over one and the same Earth model. Our preliminary results seem consistent with a behavior to be expected from a posterior distribution. Figure 2: Imaging according to Algorithm 1. Top left: the Bregman primal variable x * obtained after 401 iterations. Top right: the mean of g(z, w * ) obtained by generating 2000 random realizations of z ∼ p z (z) and averaging the corresponding g(z, w * )'s. Middle row: two examples of generated images from g(z, w * ) for different z's. Bottom row: the differences between images in the middle row with another generated image. Figure 3: Statistics of imaging according to Algorithm 1. Top row: the pointwise standard deviation among samples generated by evaluating g(z, w * ) over 2000 random realizations of z ∼ p z (z). Bottom row: sample "prior" (before training) and "posterior" distribution functions for two points in the model.


Using GGNN to recommend log statement level

In software engineering, log statement is an important part because programmers can't access to users' program and they can only rely on log message to find the root of bugs. The mechanism of"log level"allows developers and users to specify the appropriate amount of logs to print during the execution of the software. And 26\% of the log statement modification is to modify the level. We tried to use ML method to predict the suitable level of log statement. The specific model is GGNN(gated graph neural network) and we have drawn lessons from Microsoft's research. In this work, we apply Graph Neural Networks to predict the usage of log statement level of some open source java projects from github. Given the good performance of GGNN in this task, we are confident that GGNN is an excellent choice for processing source code. We envision this model can play an important role in applying AI/ML technique for Software Development Life Cycle more broadly.

Introduction
When a system breaks down, developers usually can't access to it because the program runs on user's computer. The only thing on which they can rely is the log statement. A log statement can report where the error takes place and the value of some critical variables so that developers can give a diagnosis. Ideally, coders can put log statements after every non-log statement. Theoretically speaking, doing like this eliminates ambiguity to the greatest extent. Unfortunately, it will introduce unbearable performance overhead. So we have to consider where to place a log statement is a best choice. Currently, there are some tools which can help programmers to make a decision whether to write a log statement. For example, Log20 can automates log statement placement without any domain knowledge. [5] But it's not enough to just locate log statements. In engineering, an experienced coder is often aware of which lines are turning points and that he should place a log statement there. The question is how to make a trade off between system overhead and program running information. Using log verbosity level is a solution. Common log libraries like Log4j and SLF4J support six log levels, including trace, debug, info, warn, error and fatal. Users can control the verbosity level of log statements to arXiv:1912.05097v1 [cs.SE] 11 Dec 2019 be printed out during execution. [1] By doing this, debuggers can adjust the amount of log information that they receive dynamically. However, assigning the right verbosity level requires sufficient experience. Developers spend significant efforts on adjusting the verbosity level of log messages, accounting for 26% of all the log improvements. Majority (72%) of them reflect the changes in developers' judgment about the criticality of an error event. [2] We build a machine learning model based on GGNN to help developers to choose the right verbosity level.
When it comes to using machine learning to solve problems in software engineering, most of the state-of-art projects are concentrated on natural language processing (NLP) method. Indeed, source code and natural language are similar in many ways, such as they are both made up by limited characters and symbols and are both sequential. But we still can't treat them equally. As the size of vocabulary of the source code is beyond imagination while the same of natural language is limited, we can find that most of the words in the code are created temporarily, and they are not used a lot. That means it is tough to learn the semantic information of these words. For example, the number of total tokens of WMT-14 English dataset is 304,000,000 and the size of vocabulary of it is 160,000, while there are 12,095,591 tokens in Eclipse 3.5.2 and its vocabulary size is 291,671. [6] All of these leads to difficulties in applying NLP to source code. The paradox is that some simple non-deep-learning method even outperforms complicated deep learning model in this field. [7] We assume the reason why some deep learning models don't perform well is that they can't take structural information into account and most identifiers are unknown for them so that they can't extract enough semantic information. Maybe we should change our perspective. Code is more like being organized as a graph. Whenever there is a function call, a variable definition or an operational expressions, an edge will be linked. So graph neural networks (GNN) is also a possibility because it can describe the structure information of the program by setting up some edges. GGNN is a kind of GNN. It realizes the information transfer between nodes through GRU. We use GGNN to learn the representation vector of a log statement and get a log level prediction by analysing the vector with a MLP.
We make the following contributions: 1)We build a model based on GGNN to predict log level. It can recommend level of a log statement according to the program subgraph whose center is the log statement. 2)We evaluate this model on 29 open-source java projects from Apache on Github and compare it with random model , LSTM model and Heng Li's model. [1] The result shows that this model outperforms them.

Related Work
Our work is based on prior researches on log sentences and log levels.  [8] presented log20 to determine a near optimal placement of log printing statements. Yuan et al.(2010) [9] analyzes source code by leveraging information provided by run-time logs to infer what must or may have happened during the failed production run. Zhu et al.(2015) [10] proposed LogAdvisor that extracts contextual features and helps developers to determine where to log. This model is constructed on recent works of representing source code in machine learning models. Alon et al.(2018a) [11], Alon et al.(2018b) [12] represent code snippets as a set of compositional paths over its abstract syntax tree (AST) and use LSTM to compress the paths into fixed-length vector. Allamanis et al.(2014) [13] introduce NATURALIZE to learn local context and solve coding convention inference problem. Vasic et al.(2019) [14] construct multi-head pointer network to perform joint prediction of both the location and the repair for variable misuse bugs. Our work is closely related to the research of Heng Li et al.(2017) [1] who analyze the key features of log level through case study and represented the features with arrays. However, they manually extract the features and do not use the semantic information of the code. Graph neural network is used to extract the syntactic and semantic features of source code in this model. Gori et al.(2005) [15] proposed GNN to cope with graphical data structures and Li et al.

Log Verbosity Level Prediction Task
Whatever programming language you use, printing log information is necessary. The main purposes of printing log information are as follows: 1.We can find bugs in programs through it. 2.We can monitor the status of the system and prevent problems from happening through it. 3.We can ferret out unsafe, unauthorized operations to guard against attacks from others. Although there are so many benefits, the best log library still have impact on performance. To minimize the overhead, one solution is to assign different levels to different log statements and print them by level in appropriate situations. Generally speaking, the log level can be divided into six categories: trace, debug, info, warn, error and fatal. Trace-level statements are the most detailed and mainly used in the development phase. Once being deployed to production environments, they should be deleted. Debug-level statements are similar to trace-level statements. The difference is that the former lasts longer. Info-level statements are used to print some normal information. Warn-level statements mean that there are some potential problems, but the program can go on. Error-level statements appear when some very serious problems occur. These problems will cause the current program to fail to execute properly. But if an exception handling mechanism exists, the system will not crash. Finally, fatal-level statements indicate that the worst case occurs, that is, the system crashes. Some of these levels are easily confused, such as trace and debug, warn and error. Choosing the right log level consumes a lot of energy for programmers, 26% of all the log improvements are targeted at adjusting the log level. [2] There is a correlation between the log statements and their program contexts, because they need to appear in the event of problems and print some related variables if necessary. If they don't appear in particular locations, the values of these variables may change and become meaningless. So it's possible to judge a log statement level from its context. Our goal is to build a model for predicting log levels based on program context.

Model
This model is based on GGNN [3], and the definitions of node and edge are inherited from a related Microsofts' research. [4]Considering the characteristics of this task, we use MLP to handle the output vector of GNN.

Graph Neural Networks
The first part of this model is GNN and we summarize it here. A graph G = (N , E , X ) has three parts: a set of nodes, a list of edges and initial representations of nodes, and there can be several kinds of edges. Edges are pairs e = (v 1 , v 2 ) ∈ N × N . The initial representations of nodes are generally a list of real vector x. The purpose of GNN is to learn node vector which is donated by h. Vector x n and vector h n have different meanings, the former is our prior knowledge about a node while the latter is the output of GNN with graph message.
Generally, GNN works like this: firstly there are several iterations of propagation that compute every node representation vector h; secondly there is a output function g(h, x) that calculate the output that we want to get. In order to get a prediction of log level, every node from which we want to get output is a log statement, and their initial representations are the same, so the output function can be simplified to g(h). The parameters of output function g(h) can be learned and we use MLP as function g(h).
In this section, we will elaborate on the propagation step. At the first, we assign the value of every initial node vector x n to v n0 . Generally, the sizes of x and v are the same. However we can enlarge the size of vector v by padding zeros at the end of it. In each iteration process, every node sends message to its neighbors. The content of messages is determined by both node vectors and the type of edges: m kn means the message which node n sends through edge of type k. And the parameters of function f k can be learned. Referring to the method in LEARNING TO REPRESENT PROGRAMS WITH GRAPHS [4], we set this function to be linear. For those nodes which have plural neighbors, a process of aggregating messages is necessary before updating. There are two simple methods to aggregate messages: maximizing or averaging. In each iteration, every node vector v is updated at the same time. The update operation is as follows: once every node gets its aggregated messagẽ m, the node vector of next step is calculated by: GRU is the recurrent cell function of gated recurrent unit. [18] After a certain number of iterations, the final node vector contains not only the information of the node itself, but also the information of a subgraph whose center is the node.

Program Graphs
In order to apply GGNN to processing code, we have to convert source code to graph. In fact, source code is inherently graphical. We use the definitions of nodes and edges in LEARNING TO REPRESENT PROGRAMS WITH GRAPHS [4] and we will elaborate on them in this section. node type: There are 7 kinds of node, and their definition is in Table 1. A COMPUTED FROM edge links a node to another node from which it is computed. Here is an instance in which there is a COMPUTED FROM edge between "x" and "y": 1 x = y + 5 ; A RETURNS TO edge links "return" token to the method declaration. A FORMAL ARG NAME edge links arguments in the method calls to the formal parameters that they are matched to. [19] Here is an instance in which there is a COMPUTED FROM edge between "param" and "x": GUARDED BY and GUARDED BY NEGATION edges are used to connect every token corresponding to a variable to enclosing guard expressions. Here is an instance in which there is a GUARDED BY edge between "x" and "x>y" and a GUARDED BY NEGATION edge between "y" and "x>y", "x>y" is an AST node:

MLP
MLP is the simplest neural network. The output of GGNN is supposed to be a real vector and it is suitable for processing with MLP. Now, our task is to divide the vector into six categories. So we construct a neural network consisting of several full-connected layers to extract the features of vectors automatically. The output of it is a vector of length 6. The value of the n-th component of this vector represents the possibility that the log statement is of level n. Figure 2 shows the overall framework of the model.

preprocessing method
The goal of preprocessing is to convert java source code to a number of labeled log statement-centric subgraph. We use an open-source java tool, features-javac, to accomplish the first step. 1 It not only converts source code to graph but also connects all defined edges. The graph are saved as proto format and then parsed with Google's protobuf library. 2 Sometimes log statements are hard to figure out. Different systems usually have log statements in different formats. In order to locate log statement and ascertain its verbosity level, we have to ensure that the program uses common log library. There are several common log library, e.g. Log4j 3 and slf4j 4 . Using these libraries, log statements are like the following: It's easy to determine whether a line of code is a log statement by identifying whether there is a string "log" and a verbosity level keyword in it. A simple script can accomplish this task.

subgraph extraction
The purpose of this model is to predict the verbosity level of a log statement according to a graph containing it. But we have to get rid of the log statement' own information. In order to ensure that the processed program can still be compiled so that graphs can be generated, we simply replace the log statement with a semicon. For example, the code block above will become like this after processing: Considering that the number of steps of propagation is limited, a subgraph already meets our needs. Then what we should do is to generate a subgraph whose center is the semicon. Specific approach is to add all points within several steps from the semicon to the node set of the subgraph and then add all edges whose starting node and ending node are in the node set to the edge set of the subgraph. In fact, selection of subgraph is pretty flexible. More steps will introduce more information and the model may learn more complex features while the problem of data sparsity will arise. Less steps helps to learn some direct or superficial features. Selecting nodes within m steps and outside n steps can help to exclude some unessential features.

token embedding
A universal problem in applying NLP or other ML methods to code is countless kinds of tokens. An important reason of this problem is that programmers prefer to combine several words into an identifier token. Generally, they do this with UnderScoreCase or camelCase. Once we split every identifier into several parts, the vocabulary is reduced to an acceptable level. Inspired by Deep-AutoCoder [6], we can further reduce the vocabulary by ignoring words that occur less than a certain number of times and replacing them with "UNKNOWN".
After reducing the vocabulary, we can directly make token embedding, and the parameters of the embedding layer are updated during training. For tokens which can be split into several words, we average the embeddings of these words as their embeddings. Finally we get embeddings of all nodes and use them as the initial node representations.

hyper-parameters and other configures
We use SparseGGNN in Microsoft's dpu_util library. 5 The size of embedding vector is 64. We use GRU as the rnn cell of the network. The activation function of gru is RELU. The number of propagation steps is 8. There are four layers in the succeeding MLP. Their sizes are 64, 32, 16, 6. The activation function of the first three layer is RELU.

dataset
We collected a dataset from 29 top-stared open-source java projects from Apache on Github. Then we filtered out the files with log sentences. After preprocessing, we got 8,000 labeled log samples. We selected the samples in 25 projects as seen data and divided them into train set, validation set and test set in the proportion 7-1-2 and use the samples in the other 4 projects as unseen data to examine the generalization capability of this model.

evaluation metrics
We use AUC and accuracy to evaluate this model. AUC is the area under ROC curve, and it is used to evaluate the degree of discrimination that is achieved by a model [1]. Higher AUC indicates better performance on discrimination of a model.

baseline
We compare this model with the performance of random-guessing model, RNN model and Heng Li's model [1]. The random guessing model randomly assign labels to samples and doesn't learn from the train set. The RNN(recurrent neural network) model is commonly used to process serial inputs. It takes all the sentences in the code as input and learn the structural and semantic information of the code. Heng Li's team analyzed the structural information of log sentences, extracted the key features of log level from case study and used ordinal regression to determine which log level should be chosen. Table 1 shows the performance of this model comparing to the baseline models.   Figure 3 shows the confusion matrix of this model. The frequency of fatal in the 25 projects is less than 0.1% so we omitted the label fatal in the matrix. As is shown in the graph, the correct log level account for the highest proportion for all true log levels except trace, because the use of trace varies in different projects. Even if a log sentence is assigned to the wrong log levels, they are most likely to be assigned to the log levels adjacent to their true log levels, which means the errors tend to be acceptable.

quantitative evaluation
The code blocks below show examples of determining log levels. The location of the log statements is connected to the statement 'throw' in the next line through NextToken edge, suggesting a high log level. Therefore, it is predicted as log level 'error' with high confidence and the prediction array is From the statement 'LOG.isDebugEnabled()', the model knows the log statement is of low log level, but due to lack of information in the block, it could not determine the precise log level and gave a high degree of confidence to both 'debug' and 'info', and it is likely for the model to assign a slightly wrong log level to the statement and the prediction array is [0.025, 0.369, 0.595, 0.0003, 0.011, 1.9e-6] for log levels [trace, debug, info, warn, error, fatal], indicating high possibility for both debug and info.


extfieldsofstudy:
Mathematics
Computer Science
Medicine

text:
Detection of Performance of Hybrid Rice Pot-Tray Sowing Utilizing Machine Vision and Machine Learning Approach

Monitoring the performance of hybrid rice seeding is very important for the seedling production line to adjust the sowing amount of the seeding device. The objective of this paper was to develop a system for the real-time online monitoring of the performance of hybrid rice seeding based on embedded machine vision and machine learning technology. The embedded detection system captured images of pot trays that passed under the illuminant cabinet installed in the seedling production line. This paper proposed an algorithm for fixed threshold segmentation by analyzing the images with the exploratory analysis method. With the algorithm, the grid image and seed image were extracted from the pot tray image. The paper also proposed a method for obtaining pixel coordinates of gridlines from the grid image. Binary images of seeds were divided into small pieces, according to the pixel coordinates of gridlines. Each piece corresponded to a cell on the pot tray. By scanning the contours in each piece of the image to check whether there were seeds in the cell, the number of empty cells was counted and then used to calculate the missing rate of hybrid rice seeding. The seed number sowed in pot trays was monitored while using the machine learning approach. The experimental results demonstrated that it would consume 4.863 s for the device to process an image, which allowed for the detection of the missing rate and seed number in real-time at the rate of 500 trays per hour (7.2 s per tray). The average accuracy of the detection of missing rates of a seedling production line was 94.67%. The average accuracy of the detection of seed numbers was 95.68%.

Introduction
Hybrid rice is an important grain crop in China. Most of the hybrid rice is transplanted while using nursery transplanting techniques. Seedlings are produced on rice seedling production lines in order to improve the work efficiency. Hybrid rice has a strong tillering ability, which can increase the number of effective panicles. A lower-cost and sparse-planting agronomic practice was required because of its strong tillering ability and the high cost of hybrid rice seed. One to three grains are usually sown in each tray cell in order to achieve high quality and high yield in the mechanized cultivation of hybrid rice [1,2]. This will achieve efficient utilization of the seeds and space. Due to the low sowing rate, there will be some tray cells that are not sown. This has an adverse effect on the final yield of hybrid rice. Therefore, it is important to detect the performance of hybrid rice seeding in real time, so as to adjust the seeding device in time and improve the performance of the rice seedling production line.
At present, studies are focused on the detection and evaluation of seeding performance while using one of the following methods: traditional, photoelectric, high-speed camera, and computer vision methods. The traditional method uses human eyes to evaluate the seeding performance. The workload is heavy and it is very inefficient. It is not suitable for the automation of agricultural machinery. Researchers have used photoelectric sensors to test the performance of seeders. Jia [3] used photoelectric sensors to detect the performance of an air-suction metering device. Kocher [4] used photoelectric sensors to quickly evaluate the uniformity of the seed spacing. Photoelectric sensors are widely used to detect the seeding leakage and replay precision seeders due to their low cost, but they are not suitable for detecting the performance of seeders from which a large amount of seeds continuously fall down.
With the development of computer vision and image processing technology, they are widely used in agriculture. Some studies [5,6] used machine vision to evaluate and classify the quality of seeds and rice. Leemans [7] proposed a method for guiding the precision seed drill while using machine vision. Research regarding noncontact measurement and grain counting using machine vision and image processing technology has been widely carried out. Kim [8] used machine vision technology to detect the embryonic orientation of Cucurbitaceae seeds when they were planted in a pot tray. Zhang [9] developed an ellipse-fitting algorithm to separate the touching grain kernels in images. Machine vision was also used to detect the performance of hybrid rice seeding. Qi [10] used machine vision and LabVIEW software to realize the detection of seeding cavities in hybrid rice seeding. Tan [11][12][13] used machine vision and MATLAB to detect the performance of hybrid rice seeding. Most of the studies using machine vision mentioned above were based on the Windows platform. The cost of the detection systems that were used in the research is high, and the size of the systems is large. Accordingly, they are mostly used in the laboratory and they cannot be integrated with production facilities. Additionally, they cannot be used for online detection in actual production at facilities.
With the development of embedded technology, combining machine vision technology and embedded equipment in agricultural machinery has been a growing trend. Embedded equipment has features, such as small size, low power consumption, ease of carrying, and ease of integrating into existing facilities. Embedded devices are increasingly used in agricultural machinery. Some researchers [14,15] developed systems for measuring the plant leaf area based on the Android platform while using smartphone cameras. Tu [16] developed a system for classifying pepper seeds based on the Android platform. Ma [17] developed a visual measurement and portable instrumentation method for crop seed phenotyping. Tan [18] designed a system for catching seed images and sending the images to a computer through wireless transmission while using an embedded Linux operating system (OS) and machine vision. With the improvement and development of an open source cross-platform computer vision library, it becomes more convenient and much easier to combine an embedded system with machine vision to develop complex image processing applications. These platforms and techniques provide technical support for the development of agricultural machinery toward automation and intellectualization.
A system for detecting performance of hybrid rice seeding with pot trays was developed based on embedded Linux OS and OpenCV, which is an open-source and cross-platform computer vision library, and combining an embedded system with machine vision technology and machine learning approach. A laboratory experimental was carried out. The performance of the system was evaluated in terms of accuracy and efficiency.

Device and Tools
The device that is used to detect the performance of hybrid rice seeding is installed on the 2ZSB-500 rice seedling production line at South China Agricultural University. It is located between the seeding device and the spreading soil device, as shown in Figure 1a. The detecting device, which is based on embedded machine vision technology, consists of an illuminant cabinet and an embedded system. The embedded system is composed of a microprocessor module, a high-definition camera, a keyboard, and a digital display screen. The illuminant cabinet is mainly composed of a metal box, four lighting boards, a camera fixture, and a fixture adjusting rod. Figure 1a shows the inside of the cabinet. A lighting board is installed on each wall of the metal box, which is composed of some LED beads, a light guide board, and a light leveling board. Light guide boards and light leveling boards can distribute the light that is emitted by LED beads evenly inside the illuminant cabinet. The brightness regulator can adjust the brightness of the lighting board, so that the light intensity in the cabinet can meet the needs of image acquisition. The microprocessor module is fixed on the inner side of the upper wall of the metal box, the keyboard and LED display screen are fixed on the outside of the panel above the metal box, and the UVC high-definition camera is installed on the camera fixture. Pushing or pulling the fixture adjusting rod can change the distance between the camera and pot trays. By rotating the rod, the angle of the camera on the fixture can be adjusted. There is a U-shaped dovetail groove on the camera fixture in which the camera can glide. The groove makes it possible to adjust the position of the camera precisely. Thus, the camera can be accurately fixed in positions, where it can catch images of predetermined areas of pot trays, with the fixture adjusting rod and the groove on the fixture.
The embedded system consists of a microprocessor module, UVC high-definition camera, keyboard, and LED display module, as shown in Figure 1b. A low-power microprocessor that is based on ARM CortexTM-A8 core is used as the CPU of the microprocessor module (model S5PV210AH, Samsung). There is 256 M dynamic random access memory (DRAM) and 128 MB NAND Flash, which is the program and data memory of the module. The camera that is used in the system is a high-definition webcam (model C920, Logitech). The program in the embedded system was developed with C++ programming language and it is based on an embedded Linux operating system, which is open source. It is programmed with OpenCV, which is a cross-platform computer vision library. The OpenCV library that is used in this paper is compiled on Ubuntu with arm-linux-gcc4.4.3, and its version is 3.0.

Algorithm for Seeding Performance Detection
The pot tray passes under the illuminant cabinet after the seeds are sown on a pot tray. While the pot tray is passing by, the embedded system will capture its image to detect the performance of hybrid rice seeding. Figure 2 shows the flowchart of detecting the performance of hybrid rice seeding in pot trays.

Recognition of Valid Images
There are several work steps on the rice seedling production line, such as spreading subsoil, compacting subsoil, seeding and spreading topsoil, and so on. Pot trays are transported to the positions of the work steps one by one on the conveyor belt in the production of seedlings. Both sides of the conveyor belt are installed with a track to constrain the movement of the pot trays deviating from the belt, as shown in Figure 3. While the detection device is working, it captures images of pot trays passing by continuously. Real performance of seeding cannot be obtained from images that include the beginning or end of a pot tray. Thus, an image will be regarded as invalid when it contains a beginning or end of a pot tray (shown as regions a, c, d, g, i, and k in Figure 3); otherwise, it will be regarded as a valid image (shown as regions b, e, h, and j in Figure 3). Only the first image without the ends of the tray will be regarded as valid to ensure that a pot tray will be detected only once. Therefore, region f in Figure 3 is also regarded as an invalid image. Invalid images will be discarded, and they will not be further processed. Figure 4 shows the process of recognizing the beginning or end of a pot tray. Figure 4a is an image that was captured on the seedling production line. There are beginnings and ends of pot trays in the image. In this paper, a line segment detector (LSD) was used to detect the beginning or end of a pot tray. After an image was converted to a gray image, all of the line segments in the gray image were detected with LSD, as shown in Figure 4b. Subsequently, a vertical projected length of 100 pixels was set as a threshold to filter the line segments. After the line segments were filtered, only line segments whose vertical projected length was over 100 pixels were left, as shown in Figure 4c. All of the short line segments, which were composed of the contours of seeds or soil particles, and line segments, composed of the edges of both sides of pot trays, were removed. After that, there were still line segments left, which showed that the beginning or end of a pot tray was captured.

Image Tilt Angle Detection and Correction
Images of pot trays collected on the rice seedling production line are a little tilted when compared to the horizontal direction, as shown in Figure 5a. It is necessary to correct the obliquity of the images to obtain accurate coordinates of gridlines of a pot tray. In this paper, LSD is also used to detect the horizontal line segments, which are horizontal borders of the cells on a pot tray. The degree of obliquity of an image is calculated according to the slope of the detected line segments. Figure 5 shows the process to correct the obliquity of an image.

Detection of Image Obliquity
A part instead of the whole image is selected in order to reduce the time to detect the obliquity of an image, as shown in Figure 5b. First, a region of (7,070,800,500) is selected as the region of interest (ROI) of the image, and the ROI is then converted to a gray image. LSD is used to detect all the line segments in the ROI, and then a horizontal projected length of 45 pixels is set as a threshold to filter the line segments. After being filtered, only the line segments that are part of the horizontal gridlines and longer than 45 pixels are left, as shown as the red lines in Figure 5b. The slopes of all remaining line segments are calculated while using the coordinates of the two endpoints of the line segments. The average value of all slopes of the line segments is calculated after removing the maximum and minimum values among the slopes to reduce the error of obliquity detection. The formula for calculating the slope of a line segment is as follows: where x 1 and x 2 are the x-coordinates and y 1 and y 2 are the y-coordinates of the two endpoints of the line segment, and k is the slope of the line segment; and, where n is the number of line segments, k 1 -k n are the slopes of the line segments, k max is the maximum value among k 1 -k n , k min is the minimum value among k 1 -k n , and K is the average value of the slopes. While using the average value of the slopes, the tilt angle of an image is obtained. The formula for calculating the tilt angle of an image is shown, as follows: where θ is the tilt angle of the image.

Image Tilt Correction
It is necessary to rotate the image to correct the obliquity when the tilt angle of the image is detected. After rotation, the gridlines of the pot tray are absolutely horizontal or vertical, as shown in Figure 5c. In this paper, the images are rotated through affine transformation. The center of the image is selected as the point around which the image is rotated. Its x-and y-coordinates are as follows: where width is the width of an image and height is the height of the image. The affine transformation matrix A is as follows: where θ is the tilt angle of the image.
With matrix A, the image undergoes affine transformation to complete the image rotation correction.

Segmentation of Grid and Seed Images
Analysis of Different Regions of the Image Seed and grid images of the pot tray must be segmented from the captured image in order to detect the missing rate of hybrid rice seeding in pot trays on the precision seedling production line. Image regions of seeds, grids, and soil were selected to conduct a comparative analysis of different color models (red, green, blue (RGB); hue, saturation, and lightness (HSL); Lab; YCrCb; and, LUV). A total of 20 images were selected for analysis. The seed, grid, and soil pixels were artificially obtained from each image with 300 pixels for each part. A total of 18,000 pixels were chosen to create the box plots in Figure 6.  Figure 6a, the three components values of grid and soil overlap each other in the RGB color model, as shown in the black rectangles. Therefore, it is impossible to segment the grid images from images in the RGB color model. Only seed images can be segmented while using the B component value, as shown in the blue rectangle. From Figure 6b-e, it is found that seed and grid images can both be segmented in the other color models (HSL, Lab, YCrCb, and LUV). Therefore, the captured image must be converted to a color model other than RGB in order to segment seed and grid images. The application programming interface (API) function 'cvtColor' in the library of OpenCV is used to convert RGB Images to other color models. Using different parameters, the RGB images can be convert to different color models using the same function. Table 1 shows the time to convert the RGB model to the other color models. As shown in Table 1, the time to convert images from RGB to HSL is much less than that of the other models. Therefore, the HSL color model was selected for image segmentation in order to shorten the total time for image processing as much as possible. Table 2 shows the distribution of color component values of grids, soil, and seeds in the HSL color model.  Table 2 shows that there is little overlap in the distribution of H component values of grid, soil, and seed images. A fixed threshold segmentation method can be used to segment the grid and seed images using the H color component value. Figure 7 shows the segmentation result.

Steps for Fixed Threshold Segmentation
The algorithm to segment seed and grid images from an HSL image is described, as follows: Step 1. Convert the RGB image to the HSL color model, as shown in Figure 7a.
Step 2. Set maximum and minimum thresholds for the H component value, and mark them as H_max and H_min, respectively.
Step 3. Obtain the mask image. First, a triple-channel image, which has the same size as the HSL image obtained in step 1, is created as a mask image. Afterwards, set the value of each pixel in the mask image to 0 to initialize it. Finally, the H component value of each pixel (marked as H_value) in the HSL image is compared with H_max and H_min. If the H_value is larger than H_min and smaller than H_max, the value of the corresponding pixel in the mask image is set to 1.
Step 4. Segment image. Using "and" operation between the HSL image and the mask image, the result of the operation is the segmented image.
The grid and seed images are extracted from the HSL image while using different thresholds, as shown in Figure 7b,c. Photoshop is used to segment the seed image from the rotated image and erase the noise points in the seed image, and the image is then converted to a binary image. This image can provide criteria to evaluate the algorithm of segmentation proposed in this paper. The seed image that is segmented by a fixed threshold is converted to a binary image, and its pixel sum is compared with that of the image used for the criteria. 20 images were selected to be evaluated using the same method, and the average accuracy rate for segmentation was 99.45%.

Obtaining Pixel Coordinates of Gridlines
The algorithm to get pixel coordinates of gridlines is described, as follows: Step 1. Preprocess the grid image. First the grid image is converted to a gray image, then the gray image is converted to a binary image with the Otsu method [19]. Finally, the noise pixels in the binary image are removed with the morphology noise reduction method. Thus, a relatively pure binary image of the grid was obtained, as shown in Figure 8a.
Step 2. Get the pixel sum of every row and every column of the binary image. Add the values of pixels in a row to get the pixel sum of the row, and record the row number and pixel sum as a pair of data. Assuming that there are m columns and n rows in the binary image, and then n pairs of data can be obtained. Figure 8b shows a histogram of row numbers and their pixel sums. In the histogram of the row pixel sum, a regulation is found that the pixel sums of the rows in which there are horizontal gridlines are much bigger than those of rows in which there is no horizontal gridline. A histogram of column numbers and their pixel sums is drawn while using the same method, as shown in Figure 8c.
Step 3. Obtain the pixel coordinates of gridlines. Divide the n pairs of data (row numbers and pixel sums) into 11 groups by average, being shown as the dashed red lines in Figure 8b. Subsequently, query the maximum value of the pixel sum in every group and obtain its corresponding row number. The row number is regarded as the pixel coordinate of a horizontal gridline. Pixel coordinates of vertical gridlines can be obtained with the same method.

ROI Selection of Seed Images
Drawing row and column lines using their pixel coordinates on the grid image, as shown in Figure 9a. It shows that the blue grids that are drawn coincide with the grids in the grid image. A region including 10 rows and 13 columns is selected as the ROI of the seed image because there is always a region that includes a complete 10 rows and 13 columns of cells in the shooting area of the camera, shown as the red rectangle in Figure 9b.

Preprocessing the ROI
First, the ROI of a seed image is processed in the same way as the grid image is preprocessed described above. Subsequently, the image of the ROI is divided into 130 pieces according to the gridline coordinates. Each piece of the image corresponds to a hole on the pot tray. Figure 10 shows parts of the pieces. After noise reduction, the small noises are removed, but there are still many bigger noise points, composed of soil particles or impurities in the soil, shown in Figure 10d,e. Figure 10. Pieces of seed image being split according to grids: (a-c) pieces with seeds; (d,e) pieces with noise pixels; and, (f) piece without seeds.

Detection of the Missing Rate
Step 1. Scan the contours in each piece of the image. Figure 11 shows parts of contours. If there is no seed in a piece of the image, there will not be any contours in it, as shown in Figure 11f. The steps for detecting the missing rate of hybrid rice seeding is described as follows: Step 2. Filter small contours in some pieces of images. It is necessary to remove the small contours or they will be mistaken for seeds because there are small contours that are composed of soil particles or impurities in the soil, as shown in Figure 11d,e. Check the area of every contour in a piece of image. The area of every contour is obtained using the API function 'contourArea' in the library of OpenCV. The normal size of a seed contour is larger than 30 pixels and the area of an overwhelming majority of impurity contours are smaller than 30 pixels. Therefore, an area of 30 pixels is set as a threshold to filter the contour of impurities. The contour will be removed if the area of a contour is smaller than 30 pixels.
Step 3. Count the number of pieces in which there are no contours to get the number of cells in which there are no seeds, and calculate the missing rate, as follows: where m is the number of empty cells and N is the total number of cells.

Detection of the Seed Number
Machine learning approaches are used to detect seed number in the ROI. The algorithm to detect the seed number is described, as follows: Step 1. Generating a BP (back propagation) neural network. A software tool that was developed with Visual Studio 2012 and OpenCV3.0 establishes a BP neural network. The BP neural network has an input layer, a hidden layer, and an output layer. The input layer has three nodes, the hidden layer has six nodes, and the output layer has one node. The activation function of the BP neural network is as follows: Step 2. Training and saving the BP neural network. The area, perimeter, and shape factor of a contour are chosen as the node parameters of the input layer. The seed number in a contour is chosen as the node parameter of the output layer. The perimeter of contours can be obtained while using API function 'arclength' in OpenCV library. The formula for calculating the shape factor is as follows: where F is shape factor of seed contours, C is perimeter of seed contours, and A is area of seed contours. Select some contours as training samples. Using area, perimeter, and shape factor of the contours as input parameters and seed number in the contours as the output result to train the BP neural network. Table 3 shows the number of the training samples, where Type 1 represents that there is one seed in each contour sample, Type 2 represents that there are two seeds in each contour sample, Type 3 represents that there are three seeds in each contour sample, Type 4 represents that there are four seeds in each contour sample, and Type 5 represents there are more than four seeds in each contour sample. After the BP neural network is trained and produced, it is saved in XML (extensible markup language) format in the embedded detection system.
Step 3. Prediction of seed number. The BP neural network is loaded when the embedded detection system is started. The area, perimeter, and shape factor of each contour are obtained and inputted into the BP neural network to predict the seed number in each contour. Add seed number in each contour together, the total seed number in the ROI can be obtained.

Results and Discussions
The test was done on a rice seedling production line. The hybrid rice species used in the test was WuYou 1179 and its thousand grain weight was 25 g. The seedling tray used in the test was a soft pot tray, with a size of about 581 × 284 mm (length × width). There were 29 rows and 24 columns on a pot tray and a total of 406 cells. The productivity of the rice seedling production line was set at 500 trays per hour. The system's camera can capture an image that includes 10 rows and 13 columns of a pot tray, with a resolution of 960 × 720 pixels.
The images of pot trays were captured when the conveyor belt is in motion. The speed of the conveyor belt is about 0.081 m/s. The images that were captured without the strong light of the illuminant cabinet are not clear. Accordingly, the illuminant cabinet is indispensable for the detection system. Clear photos of pot trays were obtained with the assisting of the illuminant cabinet. The illuminance of the light in the illuminant cabinet was about 3920 LUX.

Performance of Missing Rate Detection
An image of every pot tray passing under the illuminant cabinet was collected, and an ROI, including 10 rows and 13 columns (130 cells), was selected as a detection object. The cells at the top and bottom of the images may be incomplete, because they are not in the complete view of the camera. Therefore, the cells at the top and bottom of the images are not selected as ROI, and the selected ROI is representative.
The number of empty cells in each detection was recorded. The total cells in three detections was 390, which is close to the total number of cells on a pot tray (406 cells). Thus, we could calculate the missing rate every three successive detections to evaluate the seeding performance. Table 4 shows twenty consecutive statistical results.  Table 4 shows that the average accuracy of detection of missing rate of hybrid rice seeding is 94.67%. The formula for calculating the relative error of detection is shown, as follows: where δ is the relative error of detection, v ' is the average value of system measurement, and v is the average value of manual measurement.

Performance of Seed Number Detection
BP neural network was used to detect seed number in ROI. The seed numbers in every three consecutive images were added together, and the result is regarded as detection. The relative error of twenty detections is calculated while using formula 11. The average accuracy of detection of seed number is 95.68%.

Discussion
By analyzing the images, we found reasons for error detection, as follows: (1) There were some mildewed seeds in the experiment, and their color was very similar to the soil on the background. This made it difficult to use the fixed segment algorithm to completely segment the mildewed seeds from the image. Only small partial images of mildewed seeds could be segmented. The contour area of partial seeds was very small. The contour was eventually removed due to its small size when filtering. This resulted in the detected number of holes without the seeds being larger than that of a real situation. (2) There were big soil particles in the cells and the particles covered parts of seeds in the cells.
Only small parts of seeds that were not covered by soil particles were captured by the camera. The contour area of these parts was so small that it was removed when the contours were filtered, which resulted in the number of empty cells being larger than it should be. (3) There were very few impurities in the subsoil, whose color is similar to that of the seeds.
Some were big enough to be mistaken as parts of seeds, which decreased the number of empty cells, and resulted in a smaller missing rate.
It is necessary to pick out the mildewed seeds and the soil should be sieved with a fine sieve to decrease the detection error and ensure the quality of seedlings. It is not easy to completely extract seed if the color of the background is similar to the seed color. Therefore, further study should be carried out while using deep learning approaches to detect the performance of seeding.

Conclusions
The conclusions of this study are as follows: (1) An embedded seeding performance detection system was developed while using the embedded technology and machine vision technique. The proposed system can be integrated into the rice seedling nursery production line to evaluate the seeding performance on the go. (2) The component values of different parts of the image were analyses using different color models.
A fixed threshold segmentation method was proposed based on the HSL model. The grid and seed images were extracted while using the proposed method with an average segmentation accuracy of 99.45%. (3) An algorithm was developed for calculating the missing rate of the seedling production line.
The detection accuracy was 93.33% with an average processing time of 4.863 s, which was lower than the tray passing time of 7.2 s at a production rate of 500 trays per hour. This enabled the detection to be a real-time operation. (4) The number of seeds was also measured while using a machine learning approach and the average accuracy was 95.68%.


Don’t Just Scratch the Surface: Enhancing Word Representations for Korean with Hanja

We propose a simple yet effective approach for improving Korean word representations using additional linguistic annotation (i.e. Hanja). We employ cross-lingual transfer learning in training word representations by leveraging the fact that Hanja is closely related to Chinese. We evaluate the intrinsic quality of representations learned through our approach using the word analogy and similarity tests. In addition, we demonstrate their effectiveness on several downstream tasks, including a novel Korean news headline generation task.

Introduction
There is a strong connection between the Korean and Chinese languages due to cultural and historical reasons (Lee and Ramsey, 2011). Specifically, a set of logograms with very similar forms to the Chinese characters, called Hanja 1 , served in the past as the only medium for written Korean until Hangul, the Korean alphabet, and Jamo came into existence in 1443 (Sohn, 2001). Considering this etymological background, a substantial portion of Korean words are classified as Sino-Korean, a set of Korean words that had originated from Chinese and can be expressed in both Hanja and Hangul (Taylor, 1997), with the latter becoming commonplace in modern Korean.
Based on these facts, we assume the introduction of Hanja-level information will aid in grounding better representation for the meaning of Korean words (e.g. see Fig. 1). To validate our hypothesis, we propose a simple yet effective approach to training Korean word representations, named Hanja-level SISG (Hanja-level Subword * Equal contribution. 1 Hanja and traditional Chinese characters are very similar but not completely identical. Some differences in strokes and language-exclusive characters exist. Information Skip-Gram), for capturing the semantics of Hanja and subword structures of Korean and introducing them into the vector space. Note that it is also quite intuitive for native Koreans to resolve the ambiguity of (Sino-)Korean words with the aid of Hanja. We conjecture this heuristic is attributed to the fact that Hanja characters are logograms, each of which contains more lexical meaning when compared against its counterpart, the Hangul character, which is a phonogram. Accordingly, in this work, we focus on exploiting the rich extra information from Hanja as a means of constructing better Korean word embeddings. Furthermore, our approach enables us to empirically investigate the potential of character-level cross-lingual knowledge transfer with a case study of Chinese and Hanja.
To sum up, our contributions are threefold: • We introduce a novel way of training Korean word embeddings with an expanded Korean alphabet vocabulary using Hanja in addition to the existing Korean characters, Hangul.
• We also explore the possibility of character-level knowledge transfer between two languages by initializing Hanja embeddings with Chinese character embeddings before training skip-gram.
• We prove the effectiveness of our method in two ways, one of which is intrinsic evaluation (the word analogy and similarity tests), and the other being two downstream tasks including a newly proposed Korean news headline generation task.
2 Model Description Given a corpus as a sequence of words (w 1 , w 2 , . . . , w T ), the goal of a skip-gram model (Mikolov et al., 2013) is to maximize the logprobabilities of context words given a target word where C returns a set of context word indices given a word index. The usual choice for training the parameterized probability function p (w c |w) is to reframe the problem as a set of binary classification tasks of the target context word c and other negative samples chosen from the entire dictionary (negative sampling). The objective is thus where L (x) = log (1 + e −x ), the binary logistic loss. N returns a set of negative sample indices given target word and context indices. In the vanilla SG model, the scoring function s is the dot product between the two word vectors: v w and v c .

Subword Information SG (SISG) and Jamo-level SISG
In Bojanowski et al. (2017), the scoring function incorporates subword information. Specifically, given all possible n-gram character sets G = {g 1 , . . . , g G } in the corpus and that the n-gram set of a particular word w is G w ⊂ G, the scoring function is thus the sum of dot products between all n-gram vectors z and the context vector v c : However, due to the deconstructible structure of Korean characters and the agglutinative nature of the language, the model proposed by Bojanowski et al. (2017) comes short in capturing sub-character and inter-character information specific to Korean understanding. As a remedy, the model proposed by Park et al. (2018) introduces jamo-level n-grams g (j) , whose vectors can be associated with the target context as well. Given that a Korean word w can be split into a set of jamo n-grams G is the set of all possible jamo n-grams in the corpus, the updated scoring function for jamolevel skip-gram s (j) is thus (4)

Hanja-level SISG 2
Another semantic level in Korean lies in Hanja logograms. Hanja characters can be mapped to Hangul phonograms, hence Hanja annotations are sufficient but not necessary in conveying meanings ( Fig. 1). As each Hanja character is associated with semantics, their presence could provide meaningful aid in capturing word-level semantics in the vector space. We propose incorporating Hanja n-grams in the learning of word representations by allowing the scoring function to associate each Hanja n-gram with the target context word. Concretely, given that a Korean word w contains a set of Hanja sequences H w = (h w,1 , . . . , h w,Hw ) (e.g. for the example in Fig. 1 h w,1 = "社會" and h w 2 = "型") and that I h is the set of Hanja n-grams for a Hanja sequence h (e.g. I h w,2 = { "<boh>型", "型", "型<eoh>"}), all Hanja n-grams G (h) w for word w are the union of Hanja n-grams of Hanja sequences present in w: h∈Hw I h . The length of Hanja n-grams in I h is a hyperparameter. Then the new score function for Hanja-level SISG is where z h is the n-gram vector for a Hanja sequence h.

Character-level Knowledge Transfer
Since Hanja characters essentially share deep roots with Chinese characters, many of them can be mapped by one-to-one correspondence. By converting Korean characters into simplified Chinese characters or vice versa, it is possible to utilize pre-trained Chinese embeddings in the process of training Hanja-level SISG. In our case, we propose leveraging advances in Chinese word embeddings from the Chinese community by initializing Hanja n-grams vectors z h with the state-ofthe-art Chinese embeddings (Li et al., 2018) and training with the score function in Equation 5.

Korean Corpus
For learning word representations, we utilize the corpus prepared by Park et al. (2018) with small modifications. We perform additional data cleansing (e.g. removing non-Korean sentences in the corpus and unifying number tags) to obtain a cleaner version of the corpus. All of our comparative studies are based on this corpus. For training Hanja-level SISG, we use Hanjaro 3 tagger to automatically annotate all of our datasets with Hanja. It is the state-of-the-art Hanja tagger available to the public to the best of our knowledge.

Models
We compare our approach with three other baselines. Skip-Gram (SG) model (Mikolov et al., 2013) does not incorporate any n-gram information in the training loss. Subword Information Skip-Gram (SISG(c)) (Bojanowski et al., 2017) uses character-level n-gram information to enrich word representations. For the Korean language, character-level n-grams correspond to syllable n-grams. Jamo-level SISG (SISG(cj)) (Park et al., 2018) uses jamo-level n-grams in addition to character-level n-grams. Our ablation studies confirm that the hyperparameter settings (character n-grams ranging from 1 to 6 and jamo n-grams ranging from 3 to 5) proposed by the authors are indeed optimal, hence our subsequent studies all employ the same settings. Our approach is denoted by SISG(cjh)). As for the specific hyperparameter settings of our approach, SISG(cjh3) denotes Hanja n-grams ranging 3 http://hanjaro.juntong.or.kr/  Table 1: Word analogy and similarity evaluation results. For word analogy test, the table shows cosine distances averaged over semantic and syntactic word pairs (lower is better). For word similarity test, we report on Pearson and Spearman correlations between predictions and ground truth scores. We observe that our approach (SISG(cjh)) shows significant improvements in the analogy test but some deterioration in the similarity test. Note that the evaluation results reported by the original authors ( †) are largely different from our results. This might be due to differences in implementation details, hence we report and compare with the results of the authors' embeddings run on our test script ( ‡). from 1 to 3 while SISG(cjh4) denotes Hanja n-grams ranging from 1 to 4. SISG(cjhr) is a special version of our approach, where Hanja ngrams are randomly initialized as opposed to being pre-trained (Section 2.4). The details of our ablation studies and the model implementation are included in the supplementary material.

Word Analogy Test
Following the experimental protocol of Park et al. (2018), given an analogy pair a : b ↔ c : d, we compute the cosine distance between the word vectors v a + v b − v c and v d using the following equation: 1 − cos(x, y), where cos is the cosine similarity. The Korean word analogy dataset (Park et al., 2018) consists of 10,000 quadruples, designed with a set of semantic and syntactic features specific to the Korean. We report our findings in Table 1. We observe that our approach improves significantly compared to the previous state-of-the-art models in both semantic and syntactic word analogy detection.

Word Similarity Test
The word similarity test aims to evaluate the correlation between word vector distances and human-annotated scores. We use the Korean WS353 dataset provided by Park et al. (2018). Our results are shown in Table 1. Although our approaches do not outperform the jamo-level baseline (SISG(cj)), we observe that Hanjalevel information provides some advantage compared to just using pure character-level n-grams (SISG(c)). Also note that WS353 is a relatively small dataset, which could be prone to statistical bias.

Analysis
How much of the improvement can be explained by transfer learning from Chinese? Word analogy test results show that word representations trained with pre-trained Chinese n-grams perform better than those trained without (SISG(cjhr)), supporting our claim that our approach is able to transfer relevant knowledge from the Chinese language for detecting analogical relationships. However, for the word similarity test, word vectors trained without Chinese embeddings perform better, suggesting that there are some trade-offs.

Downstream Tasks
In this section, we try to demonstrate the effectiveness of our approach to downstream tasks with two specific cases.

Korean News Headline Generation
To show that our approach helps supervised models in gaining deeper understanding of Korean texts, we devise a new task using news articles, which requires an understanding of the semantics of Korean texts. We collected Korean news articles published from 2017 January to February. The dataset covers balanced categories (e.g. politics, sports, world, etc.) and contains the headline title as the annotation, akin to the CNN/Daily Mail Dataset (Hermann et al., 2015). The dataset is relatively large -containing 840,205 news article and title pairs We use the encoder-decoder architecture supported by OpenNMT (Klein et al., 2017) framework for the task, where the encoder is a bidirectional LSTM cell and the decoder is an LSTM cell (the hidden size is 512 for both) with a bridging feed-forward layer between the two RNNs. We employ soft attention (Bahdanau et al., 2014) to generate news headlines given the first three sentences of an article body. We tokenize each head-  line using a Korean morpheme tokenizer 4 such that decoder tokens are relatively dense. The copy mechanism (Gu et al., 2016), a popular technique of sequence-to-sequence models for translation and summarization, cannot be applied directly to our model, as the encoder tokens (space tokenized) and the decoder tokens (morpheme tokenized) do not share the same token space. Word vectors obtained from both baselines and our approach are used to initialize the encoder embeddings before the training begins. The dataset is split into training, validation, and test sets (8:1:1). We report performances on the test set after validating our training models on the validation set. We evaluate the titles generated by our models with the BLEU (Papineni et al., 2002) 5 . We also report per-word perplexity obtained from the models.
As shown in Table 2, models trained with our embeddings perform better and have better language modeling capability than those trained with the previous state-of-the-art embeddings. This improvement can be partially explained by the fact that formal Korean texts, such as news articles, are more likely to contain Sino-Korean words, allowing models with awareness of Chinese to gain an edge in Korean understanding.

Sentiment Analysis
To estimate the performance of our approach on a different task then the previous experiment, we conduct an experiment on Naver Sentiment Movie Corpus (NSMC) 6 . This dataset consists of 200K movie reviews, each of which is labeled with its sentiment, i.e. positive or negative. We split the corpus into training (100K), validation (50K), and test sets (50K). It is worth noting that this 3532  Table 3: Naver Sentiment Movie Corpus results. We report accuracy (Acc.), precision (P), recall (R), and F1-score (F1) following Park et al. (2018). Each reported result is the average of several runs initialized with different random seeds.
case study is designed to figure out to what extent our embeddings are generally applicable for even cases, where most of the sentences in the dataset consist of spoken words rather than written words and often do not contain Sino-Korean words.
We utilize a basic LSTM (Hochreiter and Schmidhuber, 1997) module as a sentence encoder to exclude possible exceptional gains from sophisticated encoders, concentrating on the usefulness of input word embeddings. Likewise the previous experiment, word vectors obtained from both baselines and our approach are used as input for the encoder. We regard the last hidden state of the LSTM as the sentence representation, which is consumed by a feed-forward network followed by a softmax classifier. The dimension of the LSTM cells is fixed as 300. Each result from the baselines and our models is the average of 3 independent runs initialized with different random seeds, and the outcome of each run is chosen by the performance (F1-score) on the validation set.
From Table 3, we confirm our approach is comparable to the best previous one and general enough to be employed in most of the downstream tasks, even though the performance of our approach is somewhat unsatisfactory. While not strictly proven, we conjecture one possible reason for the unsatisfying performance is the low reliability of the Hanja tagger we leveraged, which is not guaranteed to work well with spoken language. Specifically, we have manually inspected the tagging results and observed that there are some errors which can lead to performance degradation. This observation points out a limitation of our current approach, that is, the dependence on external taggers, encouraging us to develop an integrated approach, leaving as future work not resorting to the taggers.

Related Work
Although the word is usually regarded as the smallest and basic unit for most NLP pipelines, there is a recent trend of utilizing subword information for enriching word representations (Sennrich et al. 2016;Bojanowski et al. 2017, to name a few), or considering subwords themselves as input directly for NLP models (Zhang et al., 2015;Kim et al., 2016;Peters et al., 2018;Devlin et al., 2018).
As Korean is agglutinative (Song, 2006), the current literature in Korean word representations mainly focus on subword structures such as morphemes (Edmiston and Stratos, 2018), syllables (Choi et al., 2017) and Jamo (Choi et al., 2016;Stratos, 2017;Park et al., 2018). We here move forward one step further by incorporating Hanja information explicitly together with the aforementioned subword information.
On the other hand, cross-lingual representations is a trending topic in literature Lample and Conneau 2019, to name a few). Nevertheless, to the best of our knowledge, our work is the first to introduce character-level cross-lingual transfer learning based on etymological grounds. Furthermore, the novelty of our work lies of the fact that we use separated vocabulary instead of shared vocabulary such as Byte Pair Encoding (BPE) (Sennrich et al., 2016).

Conclusion
We have presented a method of training Korean word representations with Hanja. In our extensive experiments, we have demonstrated that our approach is effective in infusing more semantics into Korean word embeddings. One potential issue with our method, as already mentioned, is that it relies on external Hanja annotation, even though this can be mitigated to some extent by off-theshelf taggers, as in this work. Thus, it would be an attractive direction to take as future work developing an end-to-end system.