Fix infinite loop when no citations were present

This commit is contained in:
Ludwig Schubert
2017-08-10 11:19:32 -07:00
parent a1800ca2b3
commit 8f4722173a
4 changed files with 211 additions and 12 deletions
+188
View File
@@ -0,0 +1,188 @@
<!doctype html>
<head>
<meta charset="utf8">
<script src="../dist/components.js"></script>
<d-front-matter>
<script type="text/yml">
title: Demo Title Attention and Augmented Recurrent Neural Networks
published: Jan 10, 2017
authors:
- Chris Olah:
- Shan Carter: http://shancarter.com
affiliations:
- Google Brain
- Google Brain: http://g.co/brain
</script>
</d-front-matter>
</head>
<body>
<d-article>
<d-title>
<h1>Attention and Augmented Recurrent Neural Networks</h1>
<!-- <h2>Some people want a deck</h2> -->
<d-byline></d-byline>
</d-title>
<d-abstract>
<p>This is the first paragraph of the article. Test a long&thinsp;&mdash;&thinsp;dash -- here it is.</p>
</d-abstract>
<p>This is the first paragraph of the article. Test a long&thinsp;&mdash;&thinsp;dash -- here it is.</p>
<p>Test for owner's possessive. Test for "quoting a passage." And another sentence. Or two. Some flopping fins; for diving.</p>
<hr>
<div style="max-width: 800px; background-color: red; height: 100px; border-radius: 50px;"></div>
<p>Here's a test of an inline equation <d-math>c = a^2 + b^2</d-math>. And then there's a block equation:</p>
<d-math block>
c = \pm \sqrt{ \sum_{i=0}^{n}{a^{222} + b^2}}
</d-math>
<table>
<thead>
<tr><th>First</th><th>Second</th><th>Third</th></tr>
</thead>
<tbody>
<tr><td>23</td><td>654</td><td>23</td></tr>
<tr><td>14</td><td>54</td><td>34</td></tr>
<tr><td>234</td><td>54</td><td>23</td></tr>
</tbody>
</table>
<h2>Displaying code snippets</h2>
<p>Some inline javascript:<d-code language="javascript">var x = 25;</d-code></p>
<p>Here's a javascript code block.</p>
<d-code block language="javascript">
var x = 25;
function(x){
return x * x;
}
</d-code>
<p>We also support python.</p>
<d-code block language="python">
# Python 3: Fibonacci series up to n
def fib(n):
a, b = 0, 1
while a < n:
print(a, end=' ')
a, b = b, a+b
</d-code>
<p>That's it for the example article!</p>
<aside>Some text.</aside>
</d-article>
<d-appendix>
<d-acknowledgements>
<h3>Contributions</h3>
<p>Some text describing who did what.</p>
<h4>Reviewers</h4>
<p>Some text with links describing who reviewed the article.</p>
</d-acknowledgements>
<d-footnote-list></d-footnote-list>
<d-bibliography><script type="text/bibtex">
@article{gregor2015draw,
title={DRAW: A recurrent neural network for image generation},
author={Gregor, Karol and Danihelka, Ivo and Graves, Alex and Rezende, Danilo Jimenez and Wierstra, Daan},
journal={arXiv preprint arXiv:1502.04623},
year={2015},
url ={https://arxiv.org/pdf/1502.04623.pdf}
}
@article{mercier2011humans,
title={Why do humans reason? Arguments for an argumentative theory},
author={Mercier, Hugo and Sperber, Dan},
journal={Behavioral and brain sciences},
volume={34},
number={02},
pages={57--74},
year={2011},
publisher={Cambridge Univ Press},
doi={10.1017/S0140525X10000968}
}
@article{dong2014image,
title={Image super-resolution using deep convolutional networks},
author={Dong, Chao and Loy, Chen Change and He, Kaiming and Tang, Xiaoou},
journal={arXiv preprint arXiv:1501.00092},
year={2014},
url={https://arxiv.org/pdf/1501.00092.pdf}
}
@article{dumoulin2016adversarially,
title={Adversarially Learned Inference},
author={Dumoulin, Vincent and Belghazi, Ishmael and Poole, Ben and Lamb, Alex and Arjovsky, Martin and Mastropietro, Olivier and Courville, Aaron},
journal={arXiv preprint arXiv:1606.00704},
year={2016},
url={https://arxiv.org/pdf/1606.00704.pdf}
}
@article{dumoulin2016guide,
title={A guide to convolution arithmetic for deep learning},
author={Dumoulin, Vincent and Visin, Francesco},
journal={arXiv preprint arXiv:1603.07285},
year={2016},
url={https://arxiv.org/pdf/1603.07285.pdf}
}
@article{gauthier2014conditional,
title={Conditional generative adversarial nets for convolutional face generation},
author={Gauthier, Jon},
journal={Class Project for Stanford CS231N: Convolutional Neural Networks for Visual Recognition, Winter semester},
volume={2014},
year={2014},
url={http://www.foldl.me/uploads/papers/tr-cgans.pdf}
}
@article{johnson2016perceptual,
title={Perceptual losses for real-time style transfer and super-resolution},
author={Johnson, Justin and Alahi, Alexandre and Fei-Fei, Li},
journal={arXiv preprint arXiv:1603.08155},
year={2016},
url={https://arxiv.org/pdf/1603.08155.pdf}
}
@article{mordvintsev2015inceptionism,
title={Inceptionism: Going deeper into neural networks},
author={Mordvintsev, Alexander and Olah, Christopher and Tyka, Mike},
journal={Google Research Blog},
year={2015},
url={https://research.googleblog.com/2015/06/inceptionism-going-deeper-into-neural.html}
}
@misc{mordvintsev2016deepdreaming,
title={DeepDreaming with TensorFlow},
author={Mordvintsev, Alexander},
year={2016},
url={https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/tutorials/deepdream/deepdream.ipynb},
}
@article{radford2015unsupervised,
title={Unsupervised representation learning with deep convolutional generative adversarial networks},
author={Radford, Alec and Metz, Luke and Chintala, Soumith},
journal={arXiv preprint arXiv:1511.06434},
year={2015},
url={https://arxiv.org/pdf/1511.06434.pdf}
}
@inproceedings{salimans2016improved,
title={Improved techniques for training gans},
author={Salimans, Tim and Goodfellow, Ian and Zaremba, Wojciech and Cheung, Vicki and Radford, Alec and Chen, Xi},
booktitle={Advances in Neural Information Processing Systems},
pages={2226--2234},
year={2016},
url={https://arxiv.org/pdf/1606.03498.pdf}
}
@article{shi2016deconvolution,
title={Is the deconvolution layer the same as a convolutional layer?},
author={Shi, Wenzhe and Caballero, Jose and Theis, Lucas and Huszar, Ferenc and Aitken, Andrew and Ledig, Christian and Wang, Zehan},
journal={arXiv preprint arXiv:1609.07009},
year={2016},
url={https://arxiv.org/pdf/1609.07009.pdf}
}
</script></d-bibliography>
<distill-appendix> </distill-appendix>
</d-appendix>
</body>
+6
View File
@@ -72,6 +72,12 @@ export class Cite extends T(HTMLElement) {
}
disconnectedCallback() {
const options = { detail: [this, this.keys], bubbles: true };
const event = new CustomEvent('onCiteKeyRemoved', options);
document.dispatchEvent(event);
}
/* Observed Attributes */
// renderCitationNumbers(citations) {
+15 -11
View File
@@ -17,14 +17,14 @@ export const Controller = {
const [citeTag, keys] = event.detail;
// ensure we have citations
if (frontMatter.citations.length === 0) {
if (!frontMatter.citationsCollected) {
// console.debug('onCiteKeyCreated, but unresolved dependency ("citations"). Enqueing.');
Controller.waitingOn.citations.push(() => Controller.listeners.onCiteKeyCreated(event));
return;
}
// ensure we have a loaded bibliography
if (frontMatter.bibliography.size === 0) {
if (!frontMatter.bibliographyParsed) {
// console.debug('onCiteKeyCreated, but unresolved dependency ("bibliography"). Enqueing.');
Controller.waitingOn.bibliography.push(() => Controller.listeners.onCiteKeyCreated(event));
return;
@@ -37,11 +37,12 @@ export const Controller = {
},
onCiteKeyChanged(event) {
const [citeTag, keys] = event.detail;
// const [citeTag, keys] = event.detail;
// update citations
frontMatter.citations = collectCitations();
for (const waitingCallback of Controller.waitingOn.citations) {
frontMatter.citationsCollected = true;
for (const waitingCallback of Controller.waitingOn.citations.slice()) {
waitingCallback();
}
@@ -61,10 +62,10 @@ export const Controller = {
citeTag.entries = entries;
}
const numbers = keys.map( key => frontMatter.citations.indexOf(key) );
citeTag.numbers = numbers;
const entries = keys.map( key => frontMatter.bibliography.get(key) );
citeTag.entries = entries;
},
onCiteKeyRemoved(event) {
Controller.listeners.onCiteKeyChanged(event);
},
onBibliographyChanged(event) {
@@ -72,12 +73,13 @@ export const Controller = {
const bibliography = event.detail;
frontMatter.bibliography = bibliography;
for (const waitingCallback of Controller.waitingOn.bibliography) {
frontMatter.bibliographyParsed = true;
for (const waitingCallback of Controller.waitingOn.bibliography.slice()) {
waitingCallback();
}
// ensure we have citations
if (frontMatter.citations.length === 0) {
if (!frontMatter.citationsCollected) {
Controller.waitingOn.citations.push( function() {
Controller.listeners.onBibliographyChanged({target: event.target, detail: event.detail});
});
@@ -87,6 +89,7 @@ export const Controller = {
const entries = new Map(frontMatter.citations.map( citationKey => {
return [citationKey, frontMatter.bibliography.get(citationKey)];
}));
bibliographyTag.entries = entries;
},
@@ -122,7 +125,8 @@ export const Controller = {
// console.debug('Resolving "citations" dependency due to initial DOM load.');
frontMatter.citations = collectCitations();
for (const waitingCallback of Controller.waitingOn.citations) {
frontMatter.citationsCollected = true;
for (const waitingCallback of Controller.waitingOn.citations.slice()) {
waitingCallback();
}
+2 -1
View File
@@ -33,6 +33,7 @@ export class FrontMatter {
this.authors = []; // Array of Author(s)
this.bibliography = new Map();
this.bibliographyParsed = false;
// {
// "gregor2015draw": {
// "title": "DRAW: A recurrent neural network for image generation",
@@ -47,7 +48,7 @@ export class FrontMatter {
// Citation keys should be listed in the order that they are appear in the document.
// Each key refers to a key in the bibliography dictionary.
this.citations = []; // [ "gregor2015draw", "mercier2011humans" ]
this.citationsCollected = false;
//
// Assigned from posts.csv