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

Commit 56e80db

Browse files
committed
Add a prediction visualization script.
Work in-progress.
1 parent 09c690f commit 56e80db

File tree

6 files changed

+710
-2
lines changed

6 files changed

+710
-2
lines changed

core/data/data_io.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def get_padded_shapes(max_tokens, max_num_nodes, max_num_edges, include_strings=
164164
'problem_id': [1],
165165
'submission_id': [1],
166166
})
167-
167+
168168
return shapes
169169

170170

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: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
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+
\usepackage[font=small]{caption}
33+
34+
\usepackage{wrapfig} % wrap text around figure
35+
36+
\usepackage{graphicx} % textwidth
37+
\usepackage{arydshln} % dashlinedash
38+
\usepackage{float} % figure positioning
39+
40+
% [start] Custom header
41+
\usepackage[numbers,sort]{natbib}
42+
43+
% \input{packages.tex}
44+
\usepackage{amsmath}
45+
\usepackage{xcolor}
46+
\usepackage{enumitem}
47+
\usepackage{graphicx}
48+
\usepackage{multirow}
49+
50+
\input{scripts/visualization_template/commands.tex}
51+
52+
% END PRELUDE
53+
54+
\begin{document}
55+
56+
\setlength\dashlinedash{.5pt}
57+
\setlength\dashlinegap{6pt}
58+
\setlength\arrayrulewidth{0.3pt}
59+
60+
\begin{verbatim}
61+
{{ source_code }}
62+
\end{verbatim}
63+
64+
\textbf{Program source code.}
65+
66+
\begin{figure}[H]
67+
\centering
68+
\resizebox{\textwidth}{!}
69+
{
70+
\begin{tabular}{c|c}
71+
\toprule
72+
Target & {{ model_class }} \\
73+
\midrule
74+
{{ target }} ({{ target_error }}) & {{ prediction }} ({{ prediction_error }}) \\
75+
\bottomrule
76+
\end{tabular}
77+
}
78+
\caption{
79+
\textbf{Error class prediction.}
80+
}
81+
\label{fig:program-representations}
82+
\end{figure}
83+
84+
\begin{figure}[H]
85+
\centering
86+
\resizebox{\textwidth}{!}
87+
{
88+
\begin{tabular}{cl|cccc|ccc}
89+
\toprule
90+
$n$ & Spans & Exception node contribution \\
91+
\midrule
92+
{{ table_contents }}
93+
\bottomrule
94+
\end{tabular}
95+
}
96+
\caption{
97+
\textbf{Exception node contributions.} Program lines are associated with spans of nodes. This figures shows the contribution to the exception node of each span.
98+
}
99+
\label{fig:program-representations}
100+
\end{figure}
101+
102+
\begin{figure}[H]
103+
\includegraphics{viz-instruction-pointer.png}
104+
\caption{
105+
\textbf{Instruction pointer intensity plot.}
106+
}
107+
\end{figure}
108+
109+
\end{document}

0 commit comments

Comments
 (0)