Semi-Supervised Learning using Differentiable Reasoning
Emile van Krieken, Erman Acar, Frank van Harmelen
Introduction
Semi-supervised learning is a common class of methods for machine learning tasks where we consider not just labeled data, but also make use of unlabeled data . This can be very beneficial for training in tasks where labeled data is much harder to acquire than unlabeled data.
One such task is Semantic Image Interpretation (SII) in which the goal is to generate a semantic description of the objects on an image . This description is represented as a labeled directed graph, which is known as a scene graph . An example of a labeled dataset for this problem is VisualGenome which contains 108,077 images to train 156,722 different unary and binary predicates. The binary relations in particular make this dataset very sparse, as there are many different pairs of objects that could be related. However, a far larger, though unfortunately unlabeled, dataset like ImageNet contains over 14 million different pictures. Because it is so much larger, it will have many examples of interactions that are not present in VisualGenome. We show that it is possible to improve the performance of a simple classifier on the SII task significantly by adding the satisfaction of a first-order logic (FOL) knowledge base to the supervised loss function. The computation of this satisfaction uses an unlabeled dataset as its domain.
For this purpose, we introduce a statistical relational learning framework called Differentiable Reasoning (DR) in Section 2, as our primary contribution. DR uses simple logical formulas to deduce new training examples in an unlabeled dataset. This is done by adding a differentiable loss term that evaluates the truth value of the formulas.
In the experimental analysis, we find that the gradient updates using the Modus Ponens (MP) and Modus Tollens (MT) rules are disproportionate. That is, MT often strongly dominates MP in the learning process. Such behavior suggests that our approach is highly sensitive to the Raven Paradox . It refers to the phenomenon that the observations obtained from “All ravens are black” are dominated by its logically equivalent “All non-black things are non-ravens”. Indeed, this is closely related to the material implication which caused a lot of discussion throughout the history of logic and philosophy . Our second main contribution relies on its investigation in Section 2.4, and our proposal to cope with it. Finally, we show results on a simple dataset in Section 3 and analyze the behavior of the Raven Paradox in Section 4. Related works and conclusion closes the paper.
Differentiable Reasoning
Next, we define a Bernouilli distribution function over worlds as follows
where (similarly, ) refers to the exponent. Given some world , the valuation function is 1 if is true in that world, that is, , and 0 otherwise.
Next, we explain the domain we use in this article. We have a dataset partitioned into two parts: a labeled dataset and an unlabeled dataset where both and are sets of finite domains , and is a set containing the correct world for all pictures .
In Figure 1 we illustrate the Bayesian network associated with this problem. The left plate denotes the usual supervised data likelihood and the right plates denote the probabilities of the truth values of the formulas using .
It is important to note that the true worlds of the unlabeled dataset are not known, that is, they are latent variables and they have to be marginalized over. The formulas in knowledge base are all assumed to be true. We can now obtain the optimization problem that we can solve using gradient descent as
where in the last step we take the and minimize with respect to the negative value. The optimization problem in Equation LABEL:eq:optim consists of two terms. The first is the cross-entropy loss for supervised labeled data. The second can be understood as follows: A world entails a (full) knowledge base (i.e., ) if holds for all (that is, the product of their valuations is 1). For each domain , we then find the sum of the probabilities of worlds that entail the knowledge base. This is an example of what we call the differentiable reasoning loss. The general differentiable reasoning objective is given as
2 Differentiable Reasoning Using Product Real Logic
The marginalization over all possible worlds requires combinations, so it is exponential in the size of the Herbrand base. Therefore, the problem of finding the sum of the probabilities for all worlds that entail the knowledge base is #P-complete Instead, we shall perform a much simpler computation defined over logical formulas and the parameters as follows:
The loss term associated with the formula is computed as follows:
Say contains the picture in Figure 2 whose domain is and the model predicts the following distribution over worlds:
The model returns high values for and but it is not confident of , even though it is clearly higher than . We can decrease simply by increasing , since is a differentiable function with respect to .
This example shows that we can find a new instance of the cushion predicate using reasoning on an unlabeled dataset. This process uses both statistical reasoning and symbolic rules. As more data improves generalization, those additional examples could help reducing the sparsity of the SII problem. Furthermore, showed that it is also possible to correct wrong labels due to noisy data when these do not satisfy the formulas.
Figure 3 shows the Bayesian Network for this formula on the picture from Figure 2, illustrating the computation path. We treat each subformula as a binary random variable of which the conditional probabilities are given by truth tables. Because the graph is not acyclic, we can use loopy belief propagation which is empirically shown to often be a good approximation of the correct probability . In fact, Product Real Logic can be seen as performing a single iteration of belief propagation. However, this can be problematic. For example, the degree of truth of the ground formula would be computed using instead of the probability of this statement, . We show in Appendix A that Product Real Logic computes the correct probability for a corpus under the strong assumption that, after grounding, each ground atom is used at most once.
An interesting and useful property of our approach is that it can perform multi-hop reasoning in an iterative, yet extremely noisy, manner. In one iteration it might, for instance, increase . And since will return higher values in future iterations, it can be used to prove that the probability of other ground atoms that occur in formulas with should also be increased or decreased.
A convenient property of the SII task is that we consider just binary relations between objects appearing on the same pictures. The Herbrand base then contains ground atoms, which is feasible as there are often not more than a few dozen objects on an image. This property also holds in natural language to some degree in the following way: only the words appearing in the same paragraph can be related. This is in contrast to the knowledge base completion task where we have a single graph with many objects and predicates .
3 Implementation
We optimize the negative logarithm of the likelihood function given in Equation LABEL:eq:optim. In particular, we use minibatch gradient descent to decrease the computation time both for the supervised part of the loss and the unsupervised part. We turn the unsupervised loss into minibatch gradient descent by approximating the computation of the quantifier: instead of summing over all -tuples and all domains, we randomly sample from these -tuples independently from the domain it belongs to.
4 The Material Implication
To provide a better understanding of the inner machinery of our approach, we will elaborate on some interesting partial derivatives. Say, we have a formula of the form , where is the antecedent and the consequent of . First, we write out the partial derivative of with respect to the consequent, where we make use of the chain rule:
Next, we show how these quantities are used in the updating of the parameters using backpropagation and act as mixing components on the gradient updates:
5 The Raven Paradox
In our experiments, we have found that this approach is very sensitive to the raven paradox . It is stated as follows: Assuming that observing an example of a statement is evidence for that statement (i.e., the degree of belief in that statement increases), and that evidence for a sentence also is evidence for all the other logically equivalent sentences, then our belief in “ravens are black” increases when we observe non-black non-raven, by the contrapositive “non-ravens are non-black”. Equation 17 shows however that the gradient is equally determined by positive evidence (observing black ravens) as by contrapositive evidence (observing non-black non-ravens). Because in the real world there are far more ravens than non-black objects, optimizing amounts to recognizing that something is not a raven when it is not black. However, Machine Learning models tend to be biased when the class distribution is unbalanced during training .
We analyze a naive way of dealing with this phenomenon. We normalize the contribution to the total gradient of MP and MT reasoning by replacing the loss function of rules of the form as follows:
where is a hyperparameter that assigns the relative importance of Modus Ponens with respect to Modus Tollens updates. We are then able to control how much either contributes to the training process. We experiment with different values of and report our findings in the next section.
Experiments
We carried out simple experiments on the PASCAL-Part dataset in which the task is to predict the type of the object in a bounding box and the partOf relation which expresses that some bounding box is a part of another. For example, a tail can be a part of a cat. Like in , the output softmax layer over the 64 object classes of a Fast R-CNN detector is used for the bounding box features. Note that this makes the problem of recognizing types very easy as the features correlate strongly with the true output types. Therefore, to get a more realistic estimate, we randomly split the dataset into only 7 labeled pictures for and 2128 unlabeled pictures for . Additionally, we only consider 11 (related) types out of 64 due to computational constraints. As there is a large amount of variance associated with randomly splitting in this way, we do all our experiments on 20 random splits of the dataset. The results are evaluated on a held-out validation set of 200 images. We compare the accuracy of prediction of the type of the bounding box and the AUC (area under curve) for the partOf relationship.
We model using a single Logic Tensor Network (LTN) layer of width 10 followed by a softmax output layer to ensure mutual exclusivity of types. The term is modeled using an LTN layer of width 2 and a sigmoid output layer. The loss function is then optimized using RMSProp over 6000 iterations. We use the same relational background knowledge as which are rules like the following:
We compare three methods. In the first one we train without any rules, which forms the supervised baseline. In the second, unnormalized, we add the rules to the unlabeled data. This does not use any technique for dealing with the raven paradox. In the last one called normalized, we normalize MP and MT reasoning using Equation 18 for several different values of . The results in Table 1 are statistically significant when using a paired t-test.
Analysis
Our experiments show that we can significantly improve on the classification of the types of objects for this problem. The normalized method in particular outperforms the unnormalized method, suggesting that explicitly dealing with the raven paradox is essential in this problem.
Related work
Our work follows the recent works on Real Logic , and the method we use is a special case of Real Logic with some additional changes. A particular difference is that the logic we employ has no function symbols, which was due to simplicity purposes. Injecting background knowledge into vector embeddings of entities and relations has been studied in . In particular, has some similarities with Real Logic and our method. However, this method is developed for regularizing vector embeddings instead of any parameterized model. In this sense, it can also be seen as a special case of Real Logic. Semantic Loss is a very similar semi-supervised learning method. This loss is essentially Equation LABEL:eq:optim, which makes it more accurate than Product Real Logic, but also exponential in runtime. To deal with this, they compile SDD’s to make the computation tractable. A recent direction is DeepProbLog , a probabilistic version of Prolog with neural predicates that also uses SDD’s. also injects rules into a general model with a framework that transfers the logic rules using a so-called teacher network. This model is significantly different from the aforementioned ones, as it does not add a loss for each rule.
2 Semi-Supervised Learning
There is a large body of literature on semi-supervised methods . In particular, recent research on graph-based semi-supervised learning relates unlabeled and labeled data through a graph structure. However, they do not use logically structured background knowledge. It is generally used for entity classification, although in it is also used on link prediction. introduced the surprisingly effective method Pseudo-Label that first trains a model using the labeled dataset, then labels the unlabeled dataset using this model and continues training on this newly labeled dataset. Our approach has a similar intuition in that we use the current model to get an estimation about the correct labels of the labeled dataset, and then use those labels to predict remaining labels, but the difference is that we use background knowledge to choose these labels.
Conclusion and Future Work
We proposed a novel semi-supervised learning technique and showed that it is possible to find labels for samples in an unlabeled dataset by evaluating them on relational background knowledge. Since implication is at the core of logical reasoning, we analyzed this by inspecting the gradients with respect to the antecedent and the consequent. Surprisingly, we discovered a strong imbalance between the contributions of updates from MP and MT in the induction process. It turned out that our approach is highly sensitive to the Raven paradox requiring us to handle positive and contrapositive reasoning separately. Normalizing these different types of reasoning yields the largest improvements to the supervised baseline. Since it is quite general, we suspect that issues with this imbalance could occur in many systems that perform inductive reasoning.
We would like to investigate this phenomenon with different background knowledge and different datasets such as VisualGenome and ImageNet. In particular, we are interested in other approaches for modelling the implication like different Fuzzy Implications or by taking inspiration from Bayesian treatments of the Raven paradox . Furthermore, it could be applied to natural language understanding tasks like semantic parsing.
References
Appendix A Conditional Optimality of Product Real Logic
For each formula , we have the set of ground atoms appearing in the instantiations of . Likewise, the assignment of truth values of is , which is a subset of the world . We can now express the joint probability, using Equation 1 and the valuation function defined in Section 2.1:
We will first show that Product Real Logic is equal to this probability with two strong assumptions. The first is that the sets of ground atoms are disjoint for all formulas in the corpus, i.e. if
The second is that the set of ground atoms used in two children (a direct subformula) of some subformula of a formula in are disjoint. If returns the parent of and returns the root of (the formula highest up the tree), then
First, we marginalize over the different possible worlds:
where we make use of Equation 22 to join the summations, the independence of the probabilities of atoms from Equation 1 and marginalization of the atoms other than those in .
We denote the set of instantiations of by , and a particular instance by . then is the set of ground atoms in (and respectively for . Next we show that . As the formulas are in prenex normal form, . We find that, using Equation 23 and the same procedure as in Equations 24-27
Then, it suffices to show that . This is done using recursion. For brevity, we will only proof it for the and connectives, as we can proof the others using those.
Assume that . Then if is the binary random variable of the ground atom under the instantiation ,
Marginalize out all variables but . is 1 if is, and 0 otherwise.
Finally, assume . Then
Using this result and equations 27 and 29, we find that