text stringlengths 128 2.05k |
|---|
Danskin ( 1981 which states that fictitious play converges in continuous zero-sum games. Intuitively, fictitious play, like PNM, in each iteration only ever touches a finite subset of strategies, and one can show that the value of such subgames converges. While this result gives some theoretical underpinning to Fictiti... |
Bounded rationality. The proposed notion of RB-NE is one of bounded rationality (Simon, 1955 Over the years a number of different such notions have been proposed, e.g., see Russell ( 1997 ); Zilberstein ( 2011 Some of these also target agents in games. Perhaps the most well-known such a concept is the quantal response ... |
(McKelvey and Palfrey, 1995 . Other concepts take into account an explicit cost of computation (Rubinstein, 1986 ; Halpern et al., 2014 , or explicitly limit the allowed strategy, for instance by limiting the size of finite-state machines that might be employed (Halpern et al., 2014 However, these notions are motivated... |
Conclusions We introduce finite GANGs—Generative Adversarial Network Games—a novel framework for representing adversarial networks by formulating them as finite zero-sum games. By tackling them with techniques working in mixed strategies we can avoid getting stuck in local Nash equilibria (LNE). As finite GANGs have ex... |
Additionally, GANGs can draw on a rich set of methods for solving zero-sum games (Fudenberg and Levine, 1998 ; Rakhlin and Sridharan, 2013b ; Foster et al., 2016 ; Oliehoek et al., 2006 In this paper, we build on PNM and prove that the resulting method monotonically converges to an RB-NE. We empirically demonstrate tha... |
Future work We presented a framework that can have many instantiations and modifications. For example, one direction is to employ different learning algorithms. Another direction could focus on modifications of PNM, such as to allow discarding “stale” pure strategies, which would allow the process to run for longer wit... |
Acknowledgments This research made use of a GPU donated by NVIDIA. F.A.O. is funded by EPSRC First Grant EP/R001227/1, and ERC Starting Grant #758824—INFLUENCE. |
Appendix A The zero-sum formulation of GANs and GANGs In contrast to much of the GAN-literature, we explicitly formulate GANGs as being zero-sum games. GANs [Goodfellow et al., 2014 |
formulate the payoff of the generator as a function of the fake data only: [MATH] However, it turns out that this difference typically has no implications for the sought solutions. We clarify this with the following theorem, and investigate particular instantiations below. In game theory, two games are called strategic... |
Fact 1 Consider a game [MATH] [MATH] Fix a pure strategy [MATH] Define [MATH] as identical to [MATH] except that [MATH] for all [MATH] and some constant [MATH] We have that [MATH] and |
[MATH] [MATH] are strategically equivalent. Theorem 4 Let [MATH] , and [MATH] be arbitrary functions, then any finite (non-zero-sum) two-player game between [MATH] and [MATH] with payoffs of the following form: |
[EQUATION] [EQUATION] is strategically equivalent to a zero-sum game where [MATH] has instead payoff [MATH] Proof. By adding [MATH] to [MATH] ’s utility function, for each pure strategy [MATH] of [MATH] |
we add a different constant to all utilities of [MATH] against [MATH] . Thus, by applying Fact iteratively for all [MATH] we see that we produce a strategically equivalent game. |
Next, we formally specify the conversion of existing GAN models to GANGs. We consider the general measure function that covers GANs ( [MATH] ) and WGANs ( [MATH] ). In these models, the payoffs are specified as |
[EQUATION] [EQUATION] These can be re-written using [MATH] and [MATH] This means that we can employ Theorem and equivalently define a GANG with zero-sum payoffs that preserves the NEs. |
In practice, most work on GANs uses a different objective, introduced by Goodfellow et al. . They say that [formulas altered]: “Rather than training [MATH] to minimize [MATH] we can train [MATH] to maximize [MATH] . This objective function results in the same fixed point of the dynamics of [MATH] and [MATH] but provide... |
This means that they redefine [MATH] which still can be written as [MATH] , which means that it is candidate for transformation to [MATH] Now, as long as the classifier’s payoff is also adapted |
we can still write the payoff functions in the form of Theorem That is, the trick is compatible with a zero-sum formulation, as long as it is also applied to the classifier. This then yields: |
[EQUATION] Appendix B Experimental setup Table summarizes the settings for GAN and PNM training. As suggested by [Chintala, 2016 , we use leaky ReLU as inner activation for our GAN implementation to avoid sparse gradients. Generators have linear output layers. Classifiers use sigmoids for the final layer. Both classifi... |
B.1 Using uniform fake data to regularize classifier best responses Plain application of PNM. In GANGs, [MATH] informs [MATH] about what good strategies are and vice versa. However, as we will make clear here, this [MATH] |
has limited incentive to provide the best possible training signal to [MATH] This is illustrated in Figure The left two figures show the same best response by [MATH] : zoomed in on the data and zoomed out to cover some fake outliers. Clearly, [MATH] needs to find creative solutions to try and both remove the faraway po... |
This phenomenon is nicely illustrated by the remaining three plots (that are from a different training run, but illustrate it well): the middle plot shows an NE that targets one beam, this is exploited by [MATH] in its next best response (fourth image, note the different scales on the axes, the ‘beam’ is the same). The... |
[MATH] will need to find mixtures of all these type of complex counter measures (rightmost plot). This process can take a long time. |
PNM with added uniform fake data. The GANG formalism allows us to incorporate a simple way to resolve this issue and make training more effective. In each iteration, we look at the total span (i.e., bounding box) of the real and fake data combined, and we add some uniformly sampled fake data in this bounded box (we use... |
achieve against the RBBRs computed against them (so this is a measure of security), as well as the ‘payoff for tests’ ( [MATH] ). Clearly, adding uniform fake data leads to much faster convergence. As such, we perform our main comparison to GANs with this uniform fake data component added in. |
B.2 A measure of exploitability GANGs are guaranteed to converge to an RB-NE, while GANs (in the best case) only converge to a local NE (LNE). Therefore we hypothesize that GANGs, given sufficient computational power, yield better solutions that are ‘closer to a Nash equilibrium’. This is important, even in settings wh... |
by formulating the problem as a game (GAN or GANG), we have committed to approach the problem by trying to find an NE (even if that is computationally intractable). |
Here we propose a measure to test how far from a Nash equilibrium we might be by measuring to what extent the found solution is exploitable by adversaries of some complexity. While this is far from a perfect measure, ourselves only being equipped with bounded computational resources, this might be the best we can do. |
In particular, recall that at an NE, we realize the value of the game: [EQUATION] In other words, for an equilibrium [MATH] we have that: |
[EQUATION] [EQUATION] which means that [MATH] It also means that if we would know [MATH] , we would be able to say ‘how far away’ some found [MATH] is from an equilibrium strategy [MATH] (in terms of value) by looking at the best-response exploitability |
[EQUATION] where the inequality holds assuming we can find the actual best response. Similarly for a [MATH] we can have a look at |
[EQUATION] I.e., if [MATH] is an equilibrium strategy [MATH] but if [MATH] is less robust, the minimum is going to be lower leading to a negative value of the expression (again assuming perfect best response [MATH] ). Since negative numbers are unnatural to interpret as a distance, we define (again, assuming perfect be... |
[EQUATION] Note that, expanding the payoff function, and realizing that the maximum will be attained at a deterministic strategy [MATH] |
[EQUATION] which means this exploitability corresponds “to optimizing the divergence and distance metrics that were used to train the GANs” [Im et al., 2018 offset by [MATH] |
In the theoretical non-parametric setting (with infinite capacity densities as the strategies) this is directly useful, because then we know that the generator is able to exactly match the density, and that [MATH] (for the [MATH] measuring function, which leads to a correspondence to the Jensen-Shannon divergence [Good... |
However, this may not be a score that is attainable in finite GANG or GANs: First, there might not be a (mixture of) neural networks in the considered class that will match the data density, second there might not be classifier strategies that perfectly classify this discrepancy between the true and generated fake data... |
[MATH] , will still give a way to compare generators (and it does), but it does not tell how far from equilibrium one is. However, even though we do not know [MATH] in the case where we can compute perfect best responses , we can compute a notion of distance of a tuple [MATH] |
to equilibrium by looking at the sum: [EQUATION] So by reasoning about the tuple [MATH] rather than only [MATH] , we are able to eliminate the factor of uncertainty: [MATH] |
We therefore propose to take this approach, also in the case where we cannot guarantee computing best responses (the second factor of uncertainty). However, note that in ( ), since both terms are guaranteed to be larger than 0, we do not need to worry about cancellations of terms and the measure will never underestimat... |
[EQUATION] It does not eliminate the second source of uncertainty, but neither does approximating [MATH] . This is a perfectly useful tool (a lower bound to be precise) to get some information about the distance to an equilibrium, as long as we are careful with its interpretation. In particular, since either or both of... |
and [MATH] as long as we use the same computational resources to compute approximate best responses against them. Negative values of [MATH] |
should be interpreted as “robust up to our computational resources to attack it”. Appendix C Additional empirical results C.1 Low generator learning rate |
Figure shows the results of a lower learning rate for the generator for all 9 mode tasks. The general picture is the same as for the random 9 modes task treated in the main paper: the modes are better covered by fake data, but in places we see that this is at the expense of accuracy. |
C.2 Exploitability results MGAN Hoang et al. proposes a setup with a mixture of [MATH] generators, a classifier, and a discriminator. In their setting, the generator mixture aims to create samples which match the training data distribution, while the discriminator distinguishes real and generated samples, and the class... |
Goodfellow et al. , MGAN presents a theoretical analysis assuming infinite capacity densities. We use MGAN as a state-of-the art baseline that was explicitly designed to overcome the problem of mode collapse. |
Figure shows the results of MGAN on the mixture of Gaussian tasks. MGAN results were obtained with an architecture and hyperparameters which exactly match those proposed by Hoang et al. for a similar task. This means that the MGAN models shown use many more parameters (approx. 310,000) than the GAN and GANG models (app... |
Looking at Figure , we see that MGAN results do seem qualitatively quite good, even though there is one missed mode (and thus also one mode covered by 2 generators) on the randomly located components task (right column). |
Figure shows our exploitability results for all three tasks with nine modes. We observe roughly the same trend across the three tasks. The left column plots show the exploitability of GANG after different numbers of iterations (with respect to an attacker of fixed complexity: 453 parameters for the attacking G and C to... |
The middle column shows how exploitable GAN, MGAN and PNM-GANG models of different complexities are: the x-axis indicates the total number of parameters, while the y-axis shows the exploitability. The PNM results are the same points also shown in the left column, but repositioned at the appropriate place on the x-axis.... |
Additionally, we investigate the exploitability of the trained models presented in Figure 1 when attacked by neural networks of varying complexity. These results are shown in the right column of Figure Clearly shown is that the PNM-GANG is robust with near-zero exploitability even when attacked with high-complexity att... |
As stated in the main paper, the variance of the exploitability depends critically on the solution that is attacked. The top row of Figure 10 shows the results of three different attacks of the [MATH] against the [MATH] found by the GAN (top), and PNM-GANG (bottom). We see that in the top row, due to the shape of [MATH... |
These results demonstrate that PNM-GANGs can provide more robust solutions than GANs/MGANs with the same number of parameters, suggesting that they are closer to a Nash equilibrium and provide better generative models. |
Appendix D Interleaved training for faster convergence In order to speed up convergence of PNM-GANG, it is possible to train best responses of [MATH] and [MATH] in parallel, giving [MATH] access to the intermediate results of |
[MATH] . The resulting algorithm is shown in Algorithm In this case, the loss with which [MATH] is trained depends not only on the scores given by the current mixture of classifiers, [MATH] , but also on the classification scores given by [MATH] . Formally, the new proposed loss for [MATH] is a weighted sum of the loss... |
[MATH] , respectively. Clearly, the best response computation presented in the paper corresponds to the case in which the weight of the loss coming from [MATH] |
is zero. Intuitively, this gives the generator player the chance to be one-step ahead of the discriminator in discovering modes that are not being currently covered by [MATH] |
Algorithm 2 Interleaved Training PNM for GANGs 1: [MATH] 2: [MATH] [MATH] set initial mixtures 3: while True do 4: while Training do |
5: [MATH] 6: [MATH] 7: end while 8: // Expected payoffs of these ‘tests’ against mixture: 9: [MATH] 10: if [MATH] then 11: break |
12: end if 13: [MATH] 14: [MATH] 15: end while 16: return [MATH] This technique may interfere with the convergence guarantees provided above. It might not be the case that we are in fact computing a resource-bounded best-response for [MATH] anymore. However, in practice it performs very well: it reduces the number of n... |
# Source: arxiv 1806.07336 # Title: Neural Code Comprehension: A Learnable Representation of Code Semantics # Sections: all # Downloaded: 2026-03-03T02:31:04.921263+00:00 |
Neural Code Comprehension: A Learnable Representation of Code Semantics Abstract With the recent success of embeddings in natural language processing, research has been conducted into applying similar methods to code analysis. Most works attempt to process the code directly or use a syntactic tree representation, treat... |
Introduction The emergence of the “Big Data era” manifests in the form of a dramatic increase in accessible code. In the year 2017 alone, GitHub reports |
approximately 1 billion git commits (code modification uploads) written in 337 different programming languages. Sifting through, categorizing, and understanding code thus becomes an essential task for a variety of fields. Applications include identifying code duplication, performance prediction, algorithm detection for... |
In order to mechanize code comprehension, the research community typically employs reinforcement learning and stochastic compilation for super-optimization |
; or borrows concepts from Natural Language Processing (NLP) for human-authored code, relying on the following hypothesis: The naturalness hypothesis |
Software is a form of human communication; software corpora have similar statistical properties to natural language corpora; and these properties can be exploited to build better software engineering tools. |
For NLP-based approaches, input code is usually processed into tokens (e.g., keywords, braces) or other representations , and optionally undergoes embedding in a continuous lower-dimensional space. In the spirit of the successful word2vec model |
, the mapping to the embedding space is learned by pairing a token with its surrounding tokens. Following this process, RNNs are trained on sequences of such tokens. This model has been successfully used for NLP-like tasks, such as summarization |
, function name prediction , and algorithm classification Although the results for stochastic code optimization and NLP embeddings are promising, two issues arise. Firstly, in prior works, the source programming language (or machine code for optimization) is fixed, which does not reflect the plethora of languages, nor ... |
This paper presents Neural Code Comprehension : a general-purpose processing pipeline geared towards representing code semantics in a robust and learnable manner. The pipeline, depicted in Fig. , accepts code in various source languages and converts it to statements in an Intermediate Representation (IR), using the LLV... |
. The LLVM IR, which is explained in detail in Section , is then processed to a robust representation that we call conteXtual Flow Graphs (XFGs) . XFGs are constructed from both the data- and control-flow of the code, thus inherently supporting loops and function calls. In turn, the XFG structure is used to train an em... |
Neural Code Comprehension is evaluated on multiple levels, using clustering and analogies for inst2vec , as well as three different code comprehension tasks for XFGs: algorithm classification; heterogeneous compute device (e.g., CPU, GPU) mapping; and optimal thread coarsening factor prediction, which model the runtime... |
We formulate a robust distributional hypothesis for code, from which we draw a novel distributed representation of code statements based on contextual flow and LLVM IR. |
We detail the construction of the XFG, the first representation designed specifically for statement embeddings that combines data and control flow |
We evaluate the representation using clustering, analogies, semantic tests, and three fundamentally different high-level code learning tasks. |
Using one simple LSTM architecture and fixed pre-trained embeddings, we match or surpass the best-performing approaches in each task, including specialized DNN architectures. |
Related Work Distributed representations of code were first suggested by Allamanis et al. , followed by several works leveraging embeddings to apply NLP techniques to programming languages |
Code Representation Previous research focuses on embedding high-level programming languages such as Java , C , or OpenCL in the form of tokens or statements, as well as lower level representations such as object code |
. To the best of our knowledge, however, no attempt has been made to train embeddings for compiler IRs prior to this work. As for representing the context of a token, which is necessary for training embeddings, some works rely on lexicographical locality |
, whereas others exploit the structural nature of code, using Data Flow Graphs , Control Flow Graphs , Abstract Syntax Trees (ASTs) |
, paths in the AST , or an augmented AST, for instance with additional edges connecting different uses and updates of syntax tokens corresponding to variables |
. We differ from all previous approaches by introducing contextual flow, a graph representation that captures both data and control dependencies. In compiler research, similar graphs exist but have not been successfully exploited for machine learning. Examples include the Program Dependence Graph (PDG) |
and the IR known as Sea of Nodes . Unlike these representations, our graphs are not designed to be optimized by a compiler nor translated to machine code, which allows us to introduce ambiguity (e.g., ignoring parameter order) in favor of preserving context. Other works applying Machine Learning techniques to PDGs exis... |
use PDGs to compute n-gram models for program analysis, and Wang et al. use them for detecting copy direction among programs using Extreme Learning Machines. However, our work is the first to leverage a hybrid of control and data flow for the training of embeddings. |
Automated Tasks on Code Learned representations of code are commonly used for two types of tasks: uncovering program semantics or optimizing programs. For the former task, code embeddings have been used to perform function or variable naming |
, clone detection , code completion summarization , and algorithm classification As for program optimization, research has been conducted on automatic feature generation for code |
; and Cummins et al. notably leverage embeddings of OpenCL code to predict optimal device mapping and thread coarsening factors. Their work differs from ours in that the method is restricted to the OpenCL language, and that they process programs in a sequential order, which does not capture complex code structures. Fur... |
uses surrogate performance models and active learning, and does not take code semantics into account. Embedding Evaluation Previous works that use code embeddings do not evaluate the quality of the trained space on its own merit, but rather through the performance of subsequent (downstream) tasks. One exception is Alla... |
, who present empirical evidence of vector similarities for similar method names. To the best of our knowledge, we are the first to quantify the quality of a code embedding space itself in the form of clustering, syntactic analogies, semantic analogies, and categorical distance tests. |
A Robust Distributional Hypothesis of Code The linguistic Distributional Hypothesis is given by: Words that occur in the same contexts tend to have similar meanings . We stipulate that code, which describes a sequence of operations to a processor, behaves similarly, and paraphrase this hypothesis to: |
Statements that occur in the same contexts tend to have similar semantics However, the above wording is vague, due to the possible meanings of the highlighted elements. Below we attempt to provide adequate definitions, upon which we build a learnable code representation. |
Statements To choose the right abstraction for statements, we take two concerns into account: universality and uniformity. As stated above, source code comes in many languages and thus fixating on a single one would hinder universality. At the other extreme, machine code (assembly) is target-specific, containing specia... |
Context The definition of a context for code statements should also be carefully considered. We define context as statements whose execution directly depends on each other . Learning from consecutive statements in code does not necessarily fulfill this definition, as, for example, a programmer may use a variable in the... |
), which can be used to complement dataflow. In our representation, context is the union of data dependence and execution dependence, thereby capturing both relations. |
Similarity To define similarity, one first needs to define the semantics of a statement. We draw the definition of semantics from Operational Semantics in programming language theory, which refers to the effects (e.g., preconditions, postconditions) of each computational step in a given program. In this paper, we speci... |
Contextual Flow Processing The aforementioned statements and contexts cannot be directly extracted from source code, but rather require processing akin to partial compilation (e.g., dataflow extraction). In this section, we briefly describe a popular compilation pipeline and proposed modifications to create a learnable... |
4.1 Compilation, Static Single Assignment, and LLVM IR Major contemporary compilers, such as GCC and LLVM, support multiple programming languages and hardware targets. To avoid duplication in code optimization techniques, they enforce a strict separation between the source language (frontend), an Intermediate Represent... |
supports various architectures (e.g., GPUs), and can represent optimized code (e.g., using vector registers) inherently. Figures 2(a) and 2(b) depict an example code and its LLVM IR equivalent, and the structure of an LLVM IR statement is shown in Fig. |
In the LLVM infrastructure, the IR is given in Static Single Assignment (SSA) form . Briefly, an SSA IR ensures that every variable is assigned only once, which makes it easy to track dataflow between IR statements, as shown in Fig. To overcome analysis issues resulting from control-flow, such as loops, SSA defines [MA... |
4.2 Contextual Flow Graphs To analyze dataflow for optimization, LLVM divides the IR statements into “basic blocks”, which contain no control-flow divergence, illustrated in Fig. 2(c) . Within a basic block, statements naturally create traceable dataflow as SSA lists data dependencies in the form of input identifiers (... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.