Skip to content
This repository was archived by the owner on Jan 22, 2024. It is now read-only.

Commit 56c57cb

Browse files
committed
Add a prediction visualization script.
Work in-progress.
1 parent 25015e9 commit 56c57cb

File tree

6 files changed

+553
-2
lines changed

6 files changed

+553
-2
lines changed

core/data/data_io.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def get_padded_shapes(max_tokens, max_num_nodes, max_num_edges, include_strings=
147147
'problem_id': [1],
148148
'submission_id': [1],
149149
})
150-
150+
151151
return shapes
152152

153153

core/lib/metrics.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ def make_figure(*,
128128
fig = plt.figure()
129129
ax = fig.add_subplot(111)
130130
ax.set_title(title)
131-
plt.imshow(data, interpolation=interpolation, **kwargs)
131+
# plt.imshow(data, interpolation=interpolation, **kwargs)
132+
plt.imshow(data, cmap='Greys', interpolation=interpolation, **kwargs)
132133
ax.set_aspect('equal')
133134
ax.set_xlabel(xlabel)
134135
ax.set_ylabel(ylabel)
File renamed without changes.
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
% Model names
2+
\newcommand{\codernn}{Line-by-Line RNN\xspace}
3+
\newcommand{\tracernn}{Trace RNN\xspace}
4+
\newcommand{\hardipagnn}{Hard IP-RNN\xspace}
5+
6+
\newcommand{\ipagnn}{IPA-GNN\xspace}
7+
\newcommand{\nocontrol}{NoControl\xspace}
8+
\newcommand{\noexecute}{NoExecute\xspace}
9+
\newcommand{\gat}{R-GAT\xspace}
10+
\newcommand{\ggnn}{GGNN\xspace}
11+
12+
\newcommand{\ipagnnfullname}
13+
{Instruction Pointer Attention Graph Neural Network\xspace}
14+
\newcommand{\ggnnfullname}{Gated Graph Neural Network\xspace}
15+
16+
% Math
17+
\newcommand{\Dtrain}{D_\text{train}}
18+
\newcommand{\Dtest}{D_\text{test}}
19+
\newcommand{\ctrain}{c_\text{train}}
20+
\newcommand{\ctest}{c_\text{test}}
21+
\newcommand{\Cmax}{C_{\max}}
22+
\DeclareMathOperator*{\trace}{trace}
23+
24+
\DeclareMathOperator*{\Softmax}{softmax}
25+
\DeclareMathOperator*{\Hardmax}{hardmax}
26+
\DeclareMathOperator*{\argmax}{argmax}
27+
\newcommand{\init}{\text{init}}
28+
\newcommand{\fRNN}{f_\text{RNN}}
29+
\newcommand{\fembed}{\Embed}
30+
\newcommand{\incomingneighborsX}{N_\text{in}}
31+
\newcommand{\outgoingneighborsX}{N_\text{out}}
32+
\newcommand{\neighborsX}{N_\text{all}}
33+
\newcommand{\eqstart}{&=} % & or &=
34+
\newcommand{\separator}{}
35+
36+
\newcommand{\startnode}{\text{start-node}}
37+
\newcommand{\othernodes}{\text{other-nodes}}
38+
\newcommand{\outgoingneighbors}{\text{outgoing-neighbors}}
39+
\newcommand{\incomingneighbors}{\text{incoming-neighbors}}
40+
\newcommand{\neighbor}{\text{neighbor}}
41+
\newcommand{\neighbors}{\text{neighbors}}
42+
\newcommand{\node}{\text{node}}
43+
\newcommand{\embed}{\text{embed}}
44+
\DeclareMathOperator*{\Embed}{Embed}
45+
\DeclareMathOperator*{\RNN}{RNN}
46+
\DeclareMathOperator*{\LSTM}{LSTM}
47+
\DeclareMathOperator*{\GRU}{GRU}
48+
\newcommand{\Oracle}{\text{Oracle}}
49+
\DeclareMathOperator*{\Dense}{Dense}
50+
\newcommand{\codeX}{x}
51+
\newcommand{\inputs}{\text{input}}
52+
\newcommand{\htilde}{\tilde{h}}
53+
\newcommand{\identity}{\text{identity}}
54+
\newcommand{\otherwise}{\text{o/w}}
55+
56+
\newtheorem{theorem}{Theorem}[section]
57+
\newtheorem{corollary}{Corollary}[theorem]
58+
\newtheorem{lemma}[theorem]{Lemma}
59+
60+
% Formatting
61+
% For program-representations.tex:
62+
\newcommand{\code}[1]{\texttt{#1}}
63+
% For grammar.tex:
64+
\newcommand{\OR}{\; | \;}
65+
\newcommand{\T}[1]{\texttt{#1}}
66+
67+
% Colors
68+
% Color Palette #1955:
69+
\definecolor{burgundy-1955}{RGB}{155, 66, 58}
70+
\definecolor{orange-1955}{RGB}{220, 145, 60}
71+
\definecolor{lightorange-1955}{RGB}{248, 239, 220}
72+
\definecolor{lightblue-1955}{RGB}{84, 147, 175}
73+
\definecolor{blue-1955}{RGB}{26, 37, 76}
74+
% Custom colors:
75+
\definecolor{darkblue}{rgb}{0.0, 0.0, 0.55}
76+
\definecolor{lightblue}{rgb}{0.67, 0.84, 0.9}
77+
\definecolor{newtextcolor}{rgb}{.45, 0.45, 0.45}
78+
% Semantic colors:
79+
\newcommand{\ipagnncolor}[1]{{\color{blue}{#1}}}
80+
\newcommand{\ggnncolor}[1]{{\color{orange}{#1}}}
81+
82+
% Drafting
83+
\newcommand{\todo}[1]{{\color{red}TODO: {#1}}}
84+
\newcommand{\nb}[2]{
85+
\fbox{\bfseries\sffamily\scriptsize#1}
86+
{\sf\small$\blacktriangleright$\textit{#2}$\blacktriangleleft$}
87+
}
88+
\newcommand\HUGO[1]{\textcolor{lightblue}{\nb{Hugo}{#1}}}
89+
\newcommand\HUGOHIDDEN[1]{}
90+
\newcommand\cas[1]{\textcolor{Plum}{\nb{Charles}{#1}}}
91+
\newcommand\casHIDDEN[1]{}
92+
\newcommand\DANNY[1]{\textcolor{blue}{\nb{Danny}{#1}}}
93+
\newcommand\DANNYHIDDEN[1]{}
94+
\newcommand\DAVID[1]{\textcolor{darkblue}{\nb{David}{#1}}}
95+
\newcommand\DAVIDHIDDEN[1]{}
96+
\newcommand\DANIEL[1]{\textcolor{orange}{\nb{Daniel}{#1}}}
97+
\newcommand\DANIELHIDDEN[1]{}
98+
\newcommand{\new}[1]{{\color{newtextcolor}{#1}}}
99+
\newcommand{\old}[1]{}
100+
101+
% Uncategorized
102+
\setitemize{leftmargin=*,topsep=0pt,itemsep=0pt}
103+
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
% BEGIN PRELUDE
2+
3+
\documentclass{article}
4+
5+
% if you need to pass options to natbib, use, e.g.:
6+
\PassOptionsToPackage{numbers, compress}{natbib}
7+
% before loading neurips_2020
8+
9+
% ready for submission
10+
% \usepackage{neurips_2020}
11+
12+
% to compile a preprint version, e.g., for submission to arXiv, add add the
13+
% [preprint] option:
14+
% \usepackage[preprint]{neurips_2020}
15+
16+
% to compile a camera-ready version, add the [final] option, e.g.:
17+
% \usepackage[final,nonatbib]{neurips_2020}
18+
19+
% to avoid loading the natbib package, add option nonatbib:
20+
% \usepackage[nonatbib]{neurips_2020}
21+
22+
% \usepackage[nonatbib]{neurips_2020}
23+
24+
\usepackage[utf8]{inputenc} % allow utf-8 input
25+
\usepackage[T1]{fontenc} % use 8-bit T1 fonts
26+
\usepackage{hyperref} % hyperlinks
27+
\usepackage{url} % simple URL typesetting
28+
\usepackage{booktabs} % professional-quality tables
29+
\usepackage{amsfonts} % blackboard math symbols
30+
\usepackage{nicefrac} % compact symbols for 1/2, etc.
31+
\usepackage{microtype} % microtypography
32+
33+
\usepackage{wrapfig} % wrap text around figure
34+
35+
\usepackage{graphicx} % textwidth
36+
\usepackage{arydshln} % dashlinedash
37+
\usepackage{float} % figure positioning
38+
39+
% [start] Custom header
40+
\usepackage[numbers,sort]{natbib}
41+
42+
% \input{packages.tex}
43+
\usepackage{amsmath}
44+
\usepackage{xcolor}
45+
\usepackage{enumitem}
46+
\usepackage{graphicx}
47+
\usepackage{multirow}
48+
49+
\input{scripts/visualization_template/commands.tex}
50+
51+
% END PRELUDE
52+
53+
\begin{document}
54+
55+
\setlength\dashlinedash{.5pt}
56+
\setlength\dashlinegap{6pt}
57+
\setlength\arrayrulewidth{0.3pt}
58+
59+
\begin{verbatim}
60+
{{ source_code }}
61+
\end{verbatim}
62+
63+
\textbf{Program source code.}
64+
65+
\begin{figure}[H]
66+
\centering
67+
\resizebox{\textwidth}{!}
68+
{
69+
\begin{tabular}{cl|cccc|ccc}
70+
\toprule
71+
$n$ & Spans & Exception node contribution \\
72+
\midrule
73+
{{ table_contents }}
74+
\bottomrule
75+
\end{tabular}
76+
}
77+
\caption{
78+
\textbf{Exception node contributions.} Program lines are associated with spans of nodes. This figures shows the contribution to the exception node of each span.
79+
}
80+
\label{fig:program-representations}
81+
\end{figure}
82+
83+
\includegraphics{viz-instruction-pointer.png}
84+
\textbf{Instruction pointer intensity plot.}
85+
86+
\end{document}

0 commit comments

Comments
 (0)