update on cnn
@@ -1,219 +0,0 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
(https://github.com/hplgit/doconce/)
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="generator" content="DocOnce: https://github.com/hplgit/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Convolutional Neural Networks">
|
||||
|
||||
<title>Convolutional Neural Networks</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
content:"";
|
||||
display:block;
|
||||
height:50px; /* fixed header height for style bootstrap */
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
{'highest level': 2,
|
||||
'sections': [('Convolutional Neural Networks (recognizing images)',
|
||||
2,
|
||||
None,
|
||||
'___sec0'),
|
||||
('Regular NNs don’t scale well to full images',
|
||||
2,
|
||||
None,
|
||||
'___sec1'),
|
||||
('3D volumes of neurons', 2, None, '___sec2'),
|
||||
('Layers used to build CNNs', 2, None, '___sec3'),
|
||||
('Transforming images', 2, None, '___sec4'),
|
||||
('CNNs in brief', 2, None, '___sec5'),
|
||||
('CNNs in more detail, building convolutional neural networks in '
|
||||
'Tensorflow and Keras',
|
||||
2,
|
||||
None,
|
||||
'___sec6'),
|
||||
('Setting it up', 2, None, '___sec7'),
|
||||
('The MNIST dataset again', 2, None, '___sec8'),
|
||||
('Strong correlations', 2, None, '___sec9'),
|
||||
('Layers of a CNN', 2, None, '___sec10'),
|
||||
('Systematic reduction', 2, None, '___sec11'),
|
||||
('Prerequisites: Collect and pre-process data',
|
||||
2,
|
||||
None,
|
||||
'___sec12'),
|
||||
('Importing Keras and Tensorflow', 2, None, '___sec13'),
|
||||
('Using TensorFlow backend', 2, None, '___sec14'),
|
||||
('Train the model', 2, None, '___sec15'),
|
||||
('Visualizing the results', 2, None, '___sec16'),
|
||||
('Running with Keras', 2, None, '___sec17'),
|
||||
('Final part', 2, None, '___sec18'),
|
||||
('Final visualization', 2, None, '___sec19'),
|
||||
('Fun links', 2, None, '___sec20')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
|
||||
|
||||
|
||||
<script type="text/x-mathjax-config">
|
||||
MathJax.Hub.Config({
|
||||
TeX: {
|
||||
equationNumbers: { autoNumber: "none" },
|
||||
extensions: ["AMSmath.js", "AMSsymbols.js", "autobold.js", "color.js"]
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<script type="text/javascript" async
|
||||
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-responsive-collapse">
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="cnn-bs.html">Convolutional Neural Networks</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Contents <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
<!-- navigation toc: --> <li><a href="._cnn-bs001.html#___sec0" style="font-size: 80%;">Convolutional Neural Networks (recognizing images)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._cnn-bs002.html#___sec1" style="font-size: 80%;">Regular NNs don’t scale well to full images</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._cnn-bs003.html#___sec2" style="font-size: 80%;">3D volumes of neurons</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._cnn-bs004.html#___sec3" style="font-size: 80%;">Layers used to build CNNs</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._cnn-bs005.html#___sec4" style="font-size: 80%;">Transforming images</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._cnn-bs006.html#___sec5" style="font-size: 80%;">CNNs in brief</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._cnn-bs007.html#___sec6" style="font-size: 80%;">CNNs in more detail, building convolutional neural networks in Tensorflow and Keras</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._cnn-bs008.html#___sec7" style="font-size: 80%;">Setting it up</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._cnn-bs009.html#___sec8" style="font-size: 80%;">The MNIST dataset again</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._cnn-bs010.html#___sec9" style="font-size: 80%;">Strong correlations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._cnn-bs011.html#___sec10" style="font-size: 80%;">Layers of a CNN</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._cnn-bs012.html#___sec11" style="font-size: 80%;">Systematic reduction</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._cnn-bs013.html#___sec12" style="font-size: 80%;">Prerequisites: Collect and pre-process data</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._cnn-bs014.html#___sec13" style="font-size: 80%;">Importing Keras and Tensorflow</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._cnn-bs015.html#___sec14" style="font-size: 80%;">Using TensorFlow backend</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._cnn-bs016.html#___sec15" style="font-size: 80%;">Train the model</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._cnn-bs017.html#___sec16" style="font-size: 80%;">Visualizing the results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._cnn-bs018.html#___sec17" style="font-size: 80%;">Running with Keras</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._cnn-bs019.html#___sec18" style="font-size: 80%;">Final part</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._cnn-bs020.html#___sec19" style="font-size: 80%;">Final visualization</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._cnn-bs021.html#___sec20" style="font-size: 80%;">Fun links</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0000"></a>
|
||||
<!-- ------------------- main content ---------------------- -->
|
||||
|
||||
|
||||
|
||||
<div class="jumbotron">
|
||||
<center><h1>Convolutional Neural Networks</h1></center> <!-- document title -->
|
||||
|
||||
<p>
|
||||
<!-- author(s): Morten Hjorth-Jensen -->
|
||||
|
||||
<center>
|
||||
<b>Morten Hjorth-Jensen</b> [1, 2]
|
||||
</center>
|
||||
|
||||
<p>
|
||||
<!-- institution(s) -->
|
||||
|
||||
<center>[1] <b>Department of Physics, University of Oslo</b></center>
|
||||
<center>[2] <b>Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University</b></center>
|
||||
<br>
|
||||
<p>
|
||||
<center><h4>Oct 3, 2019</h4></center> <!-- date -->
|
||||
<br>
|
||||
<p>
|
||||
|
||||
|
||||
<p><a href="._cnn-bs001.html" class="btn btn-primary btn-lg">Read »</a></p>
|
||||
|
||||
|
||||
</div> <!-- end jumbotron -->
|
||||
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
<li class="active"><a href="._cnn-bs000.html">1</a></li>
|
||||
<li><a href="._cnn-bs001.html">2</a></li>
|
||||
<li><a href="._cnn-bs002.html">3</a></li>
|
||||
<li><a href="._cnn-bs003.html">4</a></li>
|
||||
<li><a href="._cnn-bs004.html">5</a></li>
|
||||
<li><a href="._cnn-bs005.html">6</a></li>
|
||||
<li><a href="._cnn-bs006.html">7</a></li>
|
||||
<li><a href="._cnn-bs007.html">8</a></li>
|
||||
<li><a href="._cnn-bs008.html">9</a></li>
|
||||
<li><a href="._cnn-bs009.html">10</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._cnn-bs021.html">22</a></li>
|
||||
<li><a href="._cnn-bs001.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="http://..."><img width="250" align=right src="http://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright --> © 1999-2019, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
@@ -1,781 +0,0 @@
|
||||
%%
|
||||
%% Automatically generated file from DocOnce source
|
||||
%% (https://github.com/hplgit/doconce/)
|
||||
%%
|
||||
%%
|
||||
|
||||
|
||||
%-------------------- begin preamble ----------------------
|
||||
|
||||
\documentclass[%
|
||||
oneside, % oneside: electronic viewing, twoside: printing
|
||||
final, % draft: marks overfull hboxes, figures with paths
|
||||
10pt]{article}
|
||||
|
||||
\listfiles % print all files needed to compile this document
|
||||
|
||||
\usepackage{relsize,makeidx,color,setspace,amsmath,amsfonts,amssymb}
|
||||
\usepackage[table]{xcolor}
|
||||
\usepackage{bm,ltablex,microtype}
|
||||
|
||||
\usepackage[pdftex]{graphicx}
|
||||
|
||||
\usepackage{fancyvrb} % packages needed for verbatim environments
|
||||
\usepackage{minted}
|
||||
\usemintedstyle{default}
|
||||
|
||||
\usepackage[T1]{fontenc}
|
||||
%\usepackage[latin1]{inputenc}
|
||||
\usepackage{ucs}
|
||||
\usepackage[utf8x]{inputenc}
|
||||
|
||||
\usepackage{lmodern} % Latin Modern fonts derived from Computer Modern
|
||||
|
||||
% Hyperlinks in PDF:
|
||||
\definecolor{linkcolor}{rgb}{0,0,0.4}
|
||||
\usepackage{hyperref}
|
||||
\hypersetup{
|
||||
breaklinks=true,
|
||||
colorlinks=true,
|
||||
linkcolor=linkcolor,
|
||||
urlcolor=linkcolor,
|
||||
citecolor=black,
|
||||
filecolor=black,
|
||||
%filecolor=blue,
|
||||
pdfmenubar=true,
|
||||
pdftoolbar=true,
|
||||
bookmarksdepth=3 % Uncomment (and tweak) for PDF bookmarks with more levels than the TOC
|
||||
}
|
||||
%\hyperbaseurl{} % hyperlinks are relative to this root
|
||||
|
||||
\setcounter{tocdepth}{2} % levels in table of contents
|
||||
|
||||
% Tricks for having figures close to where they are defined:
|
||||
% 1. define less restrictive rules for where to put figures
|
||||
\setcounter{topnumber}{2}
|
||||
\setcounter{bottomnumber}{2}
|
||||
\setcounter{totalnumber}{4}
|
||||
\renewcommand{\topfraction}{0.95}
|
||||
\renewcommand{\bottomfraction}{0.95}
|
||||
\renewcommand{\textfraction}{0}
|
||||
\renewcommand{\floatpagefraction}{0.75}
|
||||
% floatpagefraction must always be less than topfraction!
|
||||
% 2. ensure all figures are flushed before next section
|
||||
\usepackage[section]{placeins}
|
||||
% 3. enable begin{figure}[H] (often leads to ugly pagebreaks)
|
||||
%\usepackage{float}\restylefloat{figure}
|
||||
|
||||
% --- fancyhdr package for fancy headers ---
|
||||
\usepackage{fancyhdr}
|
||||
\fancyhf{} % sets both header and footer to nothing
|
||||
\renewcommand{\headrulewidth}{0pt}
|
||||
\fancyfoot[LE,RO]{\thepage}
|
||||
% Ensure copyright on titlepage (article style) and chapter pages (book style)
|
||||
\fancypagestyle{plain}{
|
||||
\fancyhf{}
|
||||
\fancyfoot[C]{{\footnotesize \copyright\ 1999-2019, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license}}
|
||||
% \renewcommand{\footrulewidth}{0mm}
|
||||
\renewcommand{\headrulewidth}{0mm}
|
||||
}
|
||||
% Ensure copyright on titlepages with \thispagestyle{empty}
|
||||
\fancypagestyle{empty}{
|
||||
\fancyhf{}
|
||||
\fancyfoot[C]{{\footnotesize \copyright\ 1999-2019, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license}}
|
||||
\renewcommand{\footrulewidth}{0mm}
|
||||
\renewcommand{\headrulewidth}{0mm}
|
||||
}
|
||||
|
||||
\pagestyle{fancy}
|
||||
|
||||
|
||||
% prevent orhpans and widows
|
||||
\clubpenalty = 10000
|
||||
\widowpenalty = 10000
|
||||
|
||||
% --- end of standard preamble for documents ---
|
||||
|
||||
|
||||
% insert custom LaTeX commands...
|
||||
|
||||
\raggedbottom
|
||||
\makeindex
|
||||
\usepackage[totoc]{idxlayout} % for index in the toc
|
||||
\usepackage[nottoc]{tocbibind} % for references/bibliography in the toc
|
||||
|
||||
%-------------------- end preamble ----------------------
|
||||
|
||||
\begin{document}
|
||||
|
||||
% matching end for #ifdef PREAMBLE
|
||||
|
||||
\newcommand{\exercisesection}[1]{\subsection*{#1}}
|
||||
|
||||
|
||||
% ------------------- main content ----------------------
|
||||
|
||||
|
||||
|
||||
% ----------------- title -------------------------
|
||||
|
||||
\thispagestyle{empty}
|
||||
|
||||
\begin{center}
|
||||
{\LARGE\bf
|
||||
\begin{spacing}{1.25}
|
||||
Convolutional Neural Networks
|
||||
\end{spacing}
|
||||
}
|
||||
\end{center}
|
||||
|
||||
% ----------------- author(s) -------------------------
|
||||
|
||||
\begin{center}
|
||||
{\bf Morten Hjorth-Jensen${}^{1, 2}$} \\ [0mm]
|
||||
\end{center}
|
||||
|
||||
\begin{center}
|
||||
% List of all institutions:
|
||||
\centerline{{\small ${}^1$Department of Physics, University of Oslo}}
|
||||
\centerline{{\small ${}^2$Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University}}
|
||||
\end{center}
|
||||
|
||||
% ----------------- end author(s) -------------------------
|
||||
|
||||
% --- begin date ---
|
||||
\begin{center}
|
||||
Oct 3, 2019
|
||||
\end{center}
|
||||
% --- end date ---
|
||||
|
||||
\vspace{1cm}
|
||||
|
||||
|
||||
% !split
|
||||
\subsection*{Convolutional Neural Networks (recognizing images)}
|
||||
|
||||
Convolutional Neural Networks (CNN) are very similar to ordinary Neural Networks.
|
||||
|
||||
They are made up of neurons that have learnable weights and
|
||||
biases. Each neuron receives some inputs, performs a dot product and
|
||||
optionally follows it with a non-linearity. The whole network still
|
||||
expresses a single differentiable score function: from the raw image
|
||||
pixels on one end to class scores at the other. And they still have a
|
||||
loss function (for example Softmax) on the last (fully-connected) layer
|
||||
and all the tips/tricks we developed for learning regular Neural
|
||||
Networks still apply (back propagation, gradient descent etc etc).
|
||||
|
||||
What is the difference? \textbf{CNN architectures make the explicit assumption that
|
||||
the inputs are images, which allows us to encode certain properties
|
||||
into the architecture. These then make the forward function more
|
||||
efficient to implement and vastly reduce the amount of parameters in
|
||||
the network.}
|
||||
|
||||
Here we provide only a superficial overview, for the more interested, we recommend highly the course
|
||||
\href{{https://www.uio.no/studier/emner/matnat/ifi/IN5400/index-eng.html}}{IN5400 – Machine Learning for Image Analysis}
|
||||
and the slides of \href{{http://cs231n.github.io/convolutional-networks/}}{CS231}.
|
||||
|
||||
% !split
|
||||
\subsection*{Regular NNs don’t scale well to full images}
|
||||
|
||||
As an example, consider
|
||||
an image of size $32\times 32\times 3$ (32 wide, 32 high, 3 color channels), so a
|
||||
single fully-connected neuron in a first hidden layer of a regular
|
||||
Neural Network would have $32\times 32\times 3 = 3072$ weights. This amount still
|
||||
seems manageable, but clearly this fully-connected structure does not
|
||||
scale to larger images. For example, an image of more respectable
|
||||
size, say $200\times 200\times 3$, would lead to neurons that have
|
||||
$200\times 200\times 3 = 120,000$ weights.
|
||||
|
||||
We could have
|
||||
several such neurons, and the parameters would add up quickly! Clearly,
|
||||
this full connectivity is wasteful and the huge number of parameters
|
||||
would quickly lead to possible overfitting.
|
||||
|
||||
|
||||
\begin{figure}[!ht] %
|
||||
\centerline{\includegraphics[width=0.6\linewidth]{figslides/nn.jpeg}}
|
||||
\caption{
|
||||
A regular 3-layer Neural Network.
|
||||
}
|
||||
\end{figure}
|
||||
%\clearpage % flush figures
|
||||
|
||||
|
||||
% !split
|
||||
\subsection*{3D volumes of neurons}
|
||||
|
||||
Convolutional Neural Networks take advantage of the fact that the
|
||||
input consists of images and they constrain the architecture in a more
|
||||
sensible way.
|
||||
|
||||
In particular, unlike a regular Neural Network, the
|
||||
layers of a CNN have neurons arranged in 3 dimensions: width,
|
||||
height, depth. (Note that the word depth here refers to the third
|
||||
dimension of an activation volume, not to the depth of a full Neural
|
||||
Network, which can refer to the total number of layers in a network.)
|
||||
|
||||
To understand it better, the above example of an image
|
||||
with an input volume of
|
||||
activations has dimensions $32\times 32\times 3$ (width, height,
|
||||
depth respectively).
|
||||
|
||||
The neurons in a layer will
|
||||
only be connected to a small region of the layer before it, instead of
|
||||
all of the neurons in a fully-connected manner. Moreover, the final
|
||||
output layer could for this specific image have dimensions $1\times 1 \times 10$,
|
||||
because by the
|
||||
end of the CNN architecture we will reduce the full image into a
|
||||
single vector of class scores, arranged along the depth
|
||||
dimension.
|
||||
|
||||
|
||||
\begin{figure}[!ht] %
|
||||
\centerline{\includegraphics[width=0.6\linewidth]{figslides/cnn.jpeg}}
|
||||
\caption{
|
||||
A CNN arranges its neurons in three dimensions (width, height, depth), as visualized in one of the layers. Every layer of a CNN transforms the 3D input volume to a 3D output volume of neuron activations. In this example, the red input layer holds the image, so its width and height would be the dimensions of the image, and the depth would be 3 (Red, Green, Blue channels).
|
||||
}
|
||||
\end{figure}
|
||||
%\clearpage % flush figures
|
||||
|
||||
|
||||
|
||||
|
||||
% !split
|
||||
\subsection*{Layers used to build CNNs}
|
||||
|
||||
|
||||
A simple CNN is a sequence of layers, and every layer of a CNN
|
||||
transforms one volume of activations to another through a
|
||||
differentiable function. We use three main types of layers to build
|
||||
CNN architectures: Convolutional Layer, Pooling Layer, and
|
||||
Fully-Connected Layer (exactly as seen in regular Neural Networks). We
|
||||
will stack these layers to form a full CNN architecture.
|
||||
|
||||
A simple CNN for image classification could have the architecture:
|
||||
|
||||
\begin{itemize}
|
||||
\item \textbf{INPUT} ($32\times 32 \times 3$) will hold the raw pixel values of the image, in this case an image of width 32, height 32, and with three color channels R,G,B.
|
||||
|
||||
\item \textbf{CONV} (convolutional )layer will compute the output of neurons that are connected to local regions in the input, each computing a dot product between their weights and a small region they are connected to in the input volume. This may result in volume such as $[32\times 32\times 12]$ if we decided to use 12 filters.
|
||||
|
||||
\item \textbf{RELU} layer will apply an elementwise activation function, such as the $max(0,x)$ thresholding at zero. This leaves the size of the volume unchanged ($[32\times 32\times 12]$).
|
||||
|
||||
\item \textbf{POOL} (pooling) layer will perform a downsampling operation along the spatial dimensions (width, height), resulting in volume such as $[16\times 16\times 12]$.
|
||||
|
||||
\item \textbf{FC} (i.e.~fully-connected) layer will compute the class scores, resulting in volume of size $[1\times 1\times 10]$, where each of the 10 numbers correspond to a class score, such as among the 10 categories of the MNIST images we considered above . As with ordinary Neural Networks and as the name implies, each neuron in this layer will be connected to all the numbers in the previous volume.
|
||||
\end{itemize}
|
||||
|
||||
\noindent
|
||||
% !split
|
||||
\subsection*{Transforming images}
|
||||
|
||||
CNNs transform the original image layer by layer from the original
|
||||
pixel values to the final class scores.
|
||||
|
||||
Observe that some layers contain
|
||||
parameters and other don’t. In particular, the CNN layers perform
|
||||
transformations that are a function of not only the activations in the
|
||||
input volume, but also of the parameters (the weights and biases of
|
||||
the neurons). On the other hand, the RELU/POOL layers will implement a
|
||||
fixed function. The parameters in the CONV/FC layers will be trained
|
||||
with gradient descent so that the class scores that the CNN computes
|
||||
are consistent with the labels in the training set for each image.
|
||||
|
||||
|
||||
% !split
|
||||
\subsection*{CNNs in brief}
|
||||
|
||||
In summary:
|
||||
|
||||
\begin{itemize}
|
||||
\item A CNN architecture is in the simplest case a list of Layers that transform the image volume into an output volume (e.g.~holding the class scores)
|
||||
|
||||
\item There are a few distinct types of Layers (e.g.~CONV/FC/RELU/POOL are by far the most popular)
|
||||
|
||||
\item Each Layer accepts an input 3D volume and transforms it to an output 3D volume through a differentiable function
|
||||
|
||||
\item Each Layer may or may not have parameters (e.g.~CONV/FC do, RELU/POOL don’t)
|
||||
|
||||
\item Each Layer may or may not have additional hyperparameters (e.g.~CONV/FC/POOL do, RELU doesn’t)
|
||||
\end{itemize}
|
||||
|
||||
\noindent
|
||||
For more material on convolutional networks, we strongly recommend
|
||||
the course
|
||||
\href{{https://www.uio.no/studier/emner/matnat/ifi/IN5400/index-eng.html}}{IN5400 – Machine Learning for Image Analysis}
|
||||
and the slides of \href{{http://cs231n.github.io/convolutional-networks/}}{CS231} which is taught at Stanford University (consistently ranked as one of the top computer science programs in the world). \href{{http://neuralnetworksanddeeplearning.com/chap6.html}}{Michael Nielsen's book is a must read, in particular chapter 6 which deals with CNNs}.
|
||||
|
||||
|
||||
% !split
|
||||
\subsection*{CNNs in more detail, building convolutional neural networks in Tensorflow and Keras}
|
||||
|
||||
|
||||
As discussed above, CNNs are neural networks built from the assumption that the inputs
|
||||
to the network are 2D images. This is important because the number of features or pixels in images
|
||||
grows very fast with the image size, and an enormous number of weights and biases are needed in order to build an accurate network.
|
||||
|
||||
As before, we still have our input, a hidden layer and an output. What's novel about convolutional networks
|
||||
are the \textbf{convolutional} and \textbf{pooling} layers stacked in pairs between the input and the hidden layer.
|
||||
In addition, the data is no longer represented as a 2D feature matrix, instead each input is a number of 2D
|
||||
matrices, typically 1 for each color dimension (Red, Green, Blue).
|
||||
|
||||
|
||||
% !split
|
||||
\subsection*{Setting it up}
|
||||
|
||||
It means that to represent the entire
|
||||
dataset of images, we require a 4D matrix or \textbf{tensor}. This tensor has the dimensions:
|
||||
\[
|
||||
(n_{inputs},\, n_{pixels, width},\, n_{pixels, height},\, depth) .
|
||||
\]
|
||||
|
||||
% !split
|
||||
\subsection*{The MNIST dataset again}
|
||||
|
||||
The MNIST dataset consists of grayscale images with a pixel size of
|
||||
$28\times 28$, meaning we require $28 \times 28 = 724$ weights to each
|
||||
neuron in the first hidden layer.
|
||||
|
||||
If we were to analyze images of size $128\times 128$ we would require
|
||||
$128 \times 128 = 16384$ weights to each neuron. Even worse if we were
|
||||
dealing with color images, as most images are, we have an image matrix
|
||||
of size $128\times 128$ for each color dimension (Red, Green, Blue),
|
||||
meaning 3 times the number of weights $= 49152$ are required for every
|
||||
single neuron in the first hidden layer.
|
||||
|
||||
|
||||
% !split
|
||||
\subsection*{Strong correlations}
|
||||
Images typically have strong local correlations, meaning that a small
|
||||
part of the image varies little from its neighboring regions. If for
|
||||
example we have an image of a blue car, we can roughly assume that a
|
||||
small blue part of the image is surrounded by other blue regions.
|
||||
|
||||
Therefore, instead of connecting every single pixel to a neuron in the
|
||||
first hidden layer, as we have previously done with deep neural
|
||||
networks, we can instead connect each neuron to a small part of the
|
||||
image (in all 3 RGB depth dimensions). The size of each small area is
|
||||
fixed, and known as a \href{{https://en.wikipedia.org/wiki/Receptive_field}}{receptive}.
|
||||
|
||||
|
||||
% !split
|
||||
\subsection*{Layers of a CNN}
|
||||
The layers of a convolutional neural network arrange neurons in 3D: width, height and depth.
|
||||
The input image is typically a square matrix of depth 3.
|
||||
|
||||
A \textbf{convolution} is performed on the image which outputs
|
||||
a 3D volume of neurons. The weights to the input are arranged in a number of 2D matrices, known as \textbf{filters}.
|
||||
|
||||
|
||||
Each filter slides along the input image, taking the dot product
|
||||
between each small part of the image and the filter, in all depth
|
||||
dimensions. This is then passed through a non-linear function,
|
||||
typically the \textbf{Rectified Linear (ReLu)} function, which serves as the
|
||||
activation of the neurons in the first convolutional layer. This is
|
||||
further passed through a \textbf{pooling layer}, which reduces the size of the
|
||||
convolutional layer, e.g.~by taking the maximum or average across some
|
||||
small regions, and this serves as input to the next convolutional
|
||||
layer.
|
||||
|
||||
|
||||
% !split
|
||||
\subsection*{Systematic reduction}
|
||||
|
||||
By systematically reducing the size of the input volume, through
|
||||
convolution and pooling, the network should create representations of
|
||||
small parts of the input, and then from them assemble representations
|
||||
of larger areas. The final pooling layer is flattened to serve as
|
||||
input to a hidden layer, such that each neuron in the final pooling
|
||||
layer is connected to every single neuron in the hidden layer. This
|
||||
then serves as input to the output layer, e.g.~a softmax output for
|
||||
classification.
|
||||
|
||||
|
||||
% !split
|
||||
\subsection*{Prerequisites: Collect and pre-process data}
|
||||
\begin{minted}[fontsize=\fontsize{9pt}{9pt},linenos=false,mathescape,baselinestretch=1.0,fontfamily=tt,xleftmargin=7mm]{python}
|
||||
# import necessary packages
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
from sklearn import datasets
|
||||
|
||||
|
||||
# ensure the same random numbers appear every time
|
||||
np.random.seed(0)
|
||||
|
||||
# display images in notebook
|
||||
%matplotlib inline
|
||||
plt.rcParams['figure.figsize'] = (12,12)
|
||||
|
||||
|
||||
# download MNIST dataset
|
||||
digits = datasets.load_digits()
|
||||
|
||||
# define inputs and labels
|
||||
inputs = digits.images
|
||||
labels = digits.target
|
||||
|
||||
# RGB images have a depth of 3
|
||||
# our images are grayscale so they should have a depth of 1
|
||||
inputs = inputs[:,:,:,np.newaxis]
|
||||
|
||||
print("inputs = (n_inputs, pixel_width, pixel_height, depth) = " + str(inputs.shape))
|
||||
print("labels = (n_inputs) = " + str(labels.shape))
|
||||
|
||||
|
||||
# choose some random images to display
|
||||
n_inputs = len(inputs)
|
||||
indices = np.arange(n_inputs)
|
||||
random_indices = np.random.choice(indices, size=5)
|
||||
|
||||
for i, image in enumerate(digits.images[random_indices]):
|
||||
plt.subplot(1, 5, i+1)
|
||||
plt.axis('off')
|
||||
plt.imshow(image, cmap=plt.cm.gray_r, interpolation='nearest')
|
||||
plt.title("Label: %d" % digits.target[random_indices[i]])
|
||||
plt.show()
|
||||
\end{minted}
|
||||
|
||||
|
||||
% !split
|
||||
\subsection*{Importing Keras and Tensorflow}
|
||||
\begin{minted}[fontsize=\fontsize{9pt}{9pt},linenos=false,mathescape,baselinestretch=1.0,fontfamily=tt,xleftmargin=7mm]{python}
|
||||
from keras.utils import to_categorical
|
||||
from sklearn.model_selection import train_test_split
|
||||
|
||||
# representation of labels
|
||||
labels = to_categorical(labels)
|
||||
|
||||
# split into train and test data
|
||||
# one-liner from scikit-learn library
|
||||
train_size = 0.8
|
||||
test_size = 1 - train_size
|
||||
X_train, X_test, Y_train, Y_test = train_test_split(inputs, labels, train_size=train_size,
|
||||
test_size=test_size)
|
||||
\end{minted}
|
||||
|
||||
% !split
|
||||
\subsection*{Using TensorFlow backend}
|
||||
|
||||
We need to define model and architecture and choose cost function and optmizer.
|
||||
\begin{Verbatim}[numbers=none,fontsize=\fontsize{9pt}{9pt},baselinestretch=0.95]
|
||||
|
||||
import tensorflow as tf
|
||||
|
||||
class ConvolutionalNeuralNetworkTensorflow:
|
||||
def __init__(
|
||||
self,
|
||||
X_train,
|
||||
Y_train,
|
||||
X_test,
|
||||
Y_test,
|
||||
n_filters=10,
|
||||
n_neurons_connected=50,
|
||||
n_categories=10,
|
||||
receptive_field=3,
|
||||
stride=1,
|
||||
padding=1,
|
||||
epochs=10,
|
||||
batch_size=100,
|
||||
eta=0.1,
|
||||
lmbd=0.0):
|
||||
|
||||
self.global_step = tf.Variable(0, dtype=tf.int32, trainable=False, name='global_step')
|
||||
|
||||
self.X_train = X_train
|
||||
self.Y_train = Y_train
|
||||
self.X_test = X_test
|
||||
self.Y_test = Y_test
|
||||
|
||||
self.n_inputs, self.input_width, self.input_height, self.depth = X_train.shape
|
||||
|
||||
self.n_filters = n_filters
|
||||
self.n_downsampled = int(self.input_width*self.input_height*n_filters / 4)
|
||||
self.n_neurons_connected = n_neurons_connected
|
||||
self.n_categories = n_categories
|
||||
|
||||
self.receptive_field = receptive_field
|
||||
self.stride = stride
|
||||
self.strides = [stride, stride, stride, stride]
|
||||
self.padding = padding
|
||||
|
||||
self.epochs = epochs
|
||||
self.batch_size = batch_size
|
||||
self.iterations = self.n_inputs // self.batch_size
|
||||
self.eta = eta
|
||||
self.lmbd = lmbd
|
||||
|
||||
self.create_placeholders()
|
||||
self.create_CNN()
|
||||
self.create_loss()
|
||||
self.create_optimiser()
|
||||
self.create_accuracy()
|
||||
|
||||
def create_placeholders(self):
|
||||
with tf.name_scope('data'):
|
||||
self.X = tf.placeholder(tf.float32, shape=(None, self.input_width, self.input_height, self.depth), name='X_data')
|
||||
self.Y = tf.placeholder(tf.float32, shape=(None, self.n_categories), name='Y_data')
|
||||
|
||||
def create_CNN(self):
|
||||
with tf.name_scope('CNN'):
|
||||
|
||||
# Convolutional layer
|
||||
self.W_conv = self.weight_variable([self.receptive_field, self.receptive_field, self.depth, self.n_filters], name='conv', dtype=tf.float32)
|
||||
b_conv = self.weight_variable([self.n_filters], name='conv', dtype=tf.float32)
|
||||
z_conv = tf.nn.conv2d(self.X, self.W_conv, self.strides, padding='SAME', name='conv') + b_conv
|
||||
a_conv = tf.nn.relu(z_conv)
|
||||
|
||||
# 2x2 max pooling
|
||||
a_pool = tf.nn.max_pool(a_conv, [1, 2, 2, 1], [1, 2, 2, 1], padding='SAME', name='pool')
|
||||
|
||||
# Fully connected layer
|
||||
a_pool_flat = tf.reshape(a_pool, [-1, self.n_downsampled])
|
||||
self.W_fc = self.weight_variable([self.n_downsampled, self.n_neurons_connected], name='fc', dtype=tf.float32)
|
||||
b_fc = self.bias_variable([self.n_neurons_connected], name='fc', dtype=tf.float32)
|
||||
a_fc = tf.nn.relu(tf.matmul(a_pool_flat, self.W_fc) + b_fc)
|
||||
|
||||
# Output layer
|
||||
self.W_out = self.weight_variable([self.n_neurons_connected, self.n_categories], name='out', dtype=tf.float32)
|
||||
b_out = self.bias_variable([self.n_categories], name='out', dtype=tf.float32)
|
||||
self.z_out = tf.matmul(a_fc, self.W_out) + b_out
|
||||
|
||||
def create_loss(self):
|
||||
with tf.name_scope('loss'):
|
||||
softmax_loss = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits_v2(labels=self.Y, logits=self.z_out))
|
||||
|
||||
regularizer_loss_conv = tf.nn.l2_loss(self.W_conv)
|
||||
regularizer_loss_fc = tf.nn.l2_loss(self.W_fc)
|
||||
regularizer_loss_out = tf.nn.l2_loss(self.W_out)
|
||||
regularizer_loss = self.lmbd*(regularizer_loss_conv + regularizer_loss_fc + regularizer_loss_out)
|
||||
|
||||
self.loss = softmax_loss + regularizer_loss
|
||||
|
||||
def create_accuracy(self):
|
||||
with tf.name_scope('accuracy'):
|
||||
probabilities = tf.nn.softmax(self.z_out)
|
||||
predictions = tf.argmax(probabilities, 1)
|
||||
labels = tf.argmax(self.Y, 1)
|
||||
|
||||
correct_predictions = tf.equal(predictions, labels)
|
||||
correct_predictions = tf.cast(correct_predictions, tf.float32)
|
||||
self.accuracy = tf.reduce_mean(correct_predictions)
|
||||
|
||||
def create_optimiser(self):
|
||||
with tf.name_scope('optimizer'):
|
||||
self.optimizer = tf.train.GradientDescentOptimizer(learning_rate=self.eta).minimize(self.loss, global_step=self.global_step)
|
||||
|
||||
def weight_variable(self, shape, name='', dtype=tf.float32):
|
||||
initial = tf.truncated_normal(shape, stddev=0.1)
|
||||
return tf.Variable(initial, name=name, dtype=dtype)
|
||||
|
||||
def bias_variable(self, shape, name='', dtype=tf.float32):
|
||||
initial = tf.constant(0.1, shape=shape)
|
||||
return tf.Variable(initial, name=name, dtype=dtype)
|
||||
|
||||
def fit(self):
|
||||
data_indices = np.arange(self.n_inputs)
|
||||
|
||||
with tf.Session() as sess:
|
||||
sess.run(tf.global_variables_initializer())
|
||||
for i in range(self.epochs):
|
||||
for j in range(self.iterations):
|
||||
chosen_datapoints = np.random.choice(data_indices, size=self.batch_size, replace=False)
|
||||
batch_X, batch_Y = self.X_train[chosen_datapoints], self.Y_train[chosen_datapoints]
|
||||
|
||||
sess.run([CNN.loss, CNN.optimizer],
|
||||
feed_dict={CNN.X: batch_X,
|
||||
CNN.Y: batch_Y})
|
||||
accuracy = sess.run(CNN.accuracy,
|
||||
feed_dict={CNN.X: batch_X,
|
||||
CNN.Y: batch_Y})
|
||||
step = sess.run(CNN.global_step)
|
||||
|
||||
self.train_loss, self.train_accuracy = sess.run([CNN.loss, CNN.accuracy],
|
||||
feed_dict={CNN.X: self.X_train,
|
||||
CNN.Y: self.Y_train})
|
||||
|
||||
self.test_loss, self.test_accuracy = sess.run([CNN.loss, CNN.accuracy],
|
||||
feed_dict={CNN.X: self.X_test,
|
||||
CNN.Y: self.Y_test})
|
||||
\end{Verbatim}
|
||||
|
||||
% !split
|
||||
\subsection*{Train the model}
|
||||
|
||||
We need now to train the model, evaluate it and test its performance on test data, and eventually include hyperparameters.
|
||||
\begin{minted}[fontsize=\fontsize{9pt}{9pt},linenos=false,mathescape,baselinestretch=1.0,fontfamily=tt,xleftmargin=7mm]{python}
|
||||
epochs = 100
|
||||
batch_size = 100
|
||||
n_filters = 10
|
||||
n_neurons_connected = 50
|
||||
n_categories = 10
|
||||
|
||||
eta_vals = np.logspace(-5, 1, 7)
|
||||
lmbd_vals = np.logspace(-5, 1, 7)
|
||||
CNN_tf = np.zeros((len(eta_vals), len(lmbd_vals)), dtype=object)
|
||||
|
||||
for i, eta in enumerate(eta_vals):
|
||||
for j, lmbd in enumerate(lmbd_vals):
|
||||
CNN = ConvolutionalNeuralNetworkTensorflow(X_train, Y_train, X_test, Y_test,
|
||||
n_filters=n_filters, n_neurons_connected=n_neurons_connected,
|
||||
n_categories=n_categories, epochs=epochs, batch_size=batch_size,
|
||||
eta=eta, lmbd=lmbd)
|
||||
CNN.fit()
|
||||
|
||||
print("Learning rate = ", eta)
|
||||
print("Lambda = ", lmbd)
|
||||
print("Test accuracy: %.3f" % CNN.test_accuracy)
|
||||
print()
|
||||
|
||||
CNN_tf[i][j] = CNN
|
||||
\end{minted}
|
||||
|
||||
% !split
|
||||
\subsection*{Visualizing the results}
|
||||
|
||||
\begin{minted}[fontsize=\fontsize{9pt}{9pt},linenos=false,mathescape,baselinestretch=1.0,fontfamily=tt,xleftmargin=7mm]{python}
|
||||
# visual representation of grid search
|
||||
# uses seaborn heatmap, could probably do this in matplotlib
|
||||
import seaborn as sns
|
||||
|
||||
sns.set()
|
||||
|
||||
train_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))
|
||||
test_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))
|
||||
|
||||
for i in range(len(eta_vals)):
|
||||
for j in range(len(lmbd_vals)):
|
||||
CNN = CNN_tf[i][j]
|
||||
|
||||
train_accuracy[i][j] = CNN.train_accuracy
|
||||
test_accuracy[i][j] = CNN.test_accuracy
|
||||
|
||||
|
||||
fig, ax = plt.subplots(figsize = (10, 10))
|
||||
sns.heatmap(train_accuracy, annot=True, ax=ax, cmap="viridis")
|
||||
ax.set_title("Training Accuracy")
|
||||
ax.set_ylabel("$\eta$")
|
||||
ax.set_xlabel("$\lambda$")
|
||||
plt.show()
|
||||
|
||||
fig, ax = plt.subplots(figsize = (10, 10))
|
||||
sns.heatmap(test_accuracy, annot=True, ax=ax, cmap="viridis")
|
||||
ax.set_title("Test Accuracy")
|
||||
ax.set_ylabel("$\eta$")
|
||||
ax.set_xlabel("$\lambda$")
|
||||
plt.show()
|
||||
\end{minted}
|
||||
|
||||
% !split
|
||||
\subsection*{Running with Keras}
|
||||
|
||||
\begin{minted}[fontsize=\fontsize{9pt}{9pt},linenos=false,mathescape,baselinestretch=1.0,fontfamily=tt,xleftmargin=7mm]{python}
|
||||
from keras.models import Sequential
|
||||
from keras.layers.convolutional import Conv2D
|
||||
from keras.layers.convolutional import MaxPooling2D
|
||||
from keras.layers import Flatten
|
||||
from keras.layers import Dense
|
||||
from keras.regularizers import l2
|
||||
from keras.optimizers import SGD
|
||||
|
||||
def create_convolutional_neural_network_keras(input_shape, receptive_field,
|
||||
n_filters, n_neurons_connected, n_categories,
|
||||
eta, lmbd):
|
||||
model = Sequential()
|
||||
model.add(Conv2D(n_filters, (receptive_field, receptive_field), input_shape=input_shape, padding='same',
|
||||
activation='relu', kernel_regularizer=l2(lmbd)))
|
||||
model.add(MaxPooling2D(pool_size=(2, 2)))
|
||||
model.add(Flatten())
|
||||
model.add(Dense(n_neurons_connected, activation='relu', kernel_regularizer=l2(lmbd)))
|
||||
model.add(Dense(n_categories, activation='softmax', kernel_regularizer=l2(lmbd)))
|
||||
|
||||
sgd = SGD(lr=eta)
|
||||
model.compile(loss='categorical_crossentropy', optimizer=sgd, metrics=['accuracy'])
|
||||
|
||||
return model
|
||||
|
||||
epochs = 100
|
||||
batch_size = 100
|
||||
input_shape = X_train.shape[1:4]
|
||||
receptive_field = 3
|
||||
n_filters = 10
|
||||
n_neurons_connected = 50
|
||||
n_categories = 10
|
||||
|
||||
eta_vals = np.logspace(-5, 1, 7)
|
||||
lmbd_vals = np.logspace(-5, 1, 7)
|
||||
\end{minted}
|
||||
|
||||
% !split
|
||||
\subsection*{Final part}
|
||||
|
||||
\begin{minted}[fontsize=\fontsize{9pt}{9pt},linenos=false,mathescape,baselinestretch=1.0,fontfamily=tt,xleftmargin=7mm]{python}
|
||||
CNN_keras = np.zeros((len(eta_vals), len(lmbd_vals)), dtype=object)
|
||||
|
||||
for i, eta in enumerate(eta_vals):
|
||||
for j, lmbd in enumerate(lmbd_vals):
|
||||
CNN = create_convolutional_neural_network_keras(input_shape, receptive_field,
|
||||
n_filters, n_neurons_connected, n_categories,
|
||||
eta, lmbd)
|
||||
CNN.fit(X_train, Y_train, epochs=epochs, batch_size=batch_size, verbose=0)
|
||||
scores = CNN.evaluate(X_test, Y_test)
|
||||
|
||||
CNN_keras[i][j] = CNN
|
||||
|
||||
print("Learning rate = ", eta)
|
||||
print("Lambda = ", lmbd)
|
||||
print("Test accuracy: %.3f" % scores[1])
|
||||
print()
|
||||
\end{minted}
|
||||
|
||||
% !split
|
||||
\subsection*{Final visualization}
|
||||
|
||||
\begin{Verbatim}[numbers=none,fontsize=\fontsize{9pt}{9pt},baselinestretch=0.95]
|
||||
# visual representation of grid search
|
||||
# uses seaborn heatmap, could probably do this in matplotlib
|
||||
import seaborn as sns
|
||||
|
||||
sns.set()
|
||||
|
||||
train_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))
|
||||
test_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))
|
||||
|
||||
for i in range(len(eta_vals)):
|
||||
for j in range(len(lmbd_vals)):
|
||||
CNN = CNN_keras[i][j]
|
||||
|
||||
train_accuracy[i][j] = CNN.evaluate(X_train, Y_train)[1]
|
||||
test_accuracy[i][j] = CNN.evaluate(X_test, Y_test)[1]
|
||||
|
||||
|
||||
fig, ax = plt.subplots(figsize = (10, 10))
|
||||
sns.heatmap(train_accuracy, annot=True, ax=ax, cmap="viridis")
|
||||
ax.set_title("Training Accuracy")
|
||||
ax.set_ylabel("$\eta$")
|
||||
ax.set_xlabel("$\lambda$")
|
||||
plt.show()
|
||||
|
||||
fig, ax = plt.subplots(figsize = (10, 10))
|
||||
sns.heatmap(test_accuracy, annot=True, ax=ax, cmap="viridis")
|
||||
ax.set_title("Test Accuracy")
|
||||
ax.set_ylabel("$\eta$")
|
||||
ax.set_xlabel("$\lambda$")
|
||||
plt.show()
|
||||
\end{Verbatim}
|
||||
|
||||
% !split
|
||||
\subsection*{Fun links}
|
||||
|
||||
\begin{enumerate}
|
||||
\item \href{{https://arxiv.org/abs/1604.07316}}{Self-Driving cars using a convolutional neural network}
|
||||
|
||||
\item \href{{https://deepdreamgenerator.com/}}{Abstract art using convolutional neural networks}
|
||||
\end{enumerate}
|
||||
|
||||
\noindent
|
||||
|
||||
% ------------------- end of main content ---------------
|
||||
|
||||
\end{document}
|
||||
|
||||
@@ -1,984 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="generator" content="DocOnce: https://github.com/hplgit/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Convolutional Neural Networks">
|
||||
|
||||
<title>Convolutional Neural Networks</title>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- reveal.js: http://lab.hakim.se/reveal-js/ -->
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
|
||||
|
||||
<link rel="stylesheet" href="reveal.js/css/reveal.css">
|
||||
<link rel="stylesheet" href="reveal.js/css/theme/beige.css" id="theme">
|
||||
<!--
|
||||
<link rel="stylesheet" href="reveal.js/css/reveal.css">
|
||||
<link rel="stylesheet" href="reveal.js/css/theme/beige.css" id="theme">
|
||||
<link rel="stylesheet" href="reveal.js/css/theme/beigesmall.css" id="theme">
|
||||
<link rel="stylesheet" href="reveal.js/css/theme/solarized.css" id="theme">
|
||||
<link rel="stylesheet" href="reveal.js/css/theme/serif.css" id="theme">
|
||||
<link rel="stylesheet" href="reveal.js/css/theme/night.css" id="theme">
|
||||
<link rel="stylesheet" href="reveal.js/css/theme/moon.css" id="theme">
|
||||
<link rel="stylesheet" href="reveal.js/css/theme/simple.css" id="theme">
|
||||
<link rel="stylesheet" href="reveal.js/css/theme/sky.css" id="theme">
|
||||
<link rel="stylesheet" href="reveal.js/css/theme/darkgray.css" id="theme">
|
||||
<link rel="stylesheet" href="reveal.js/css/theme/default.css" id="theme">
|
||||
<link rel="stylesheet" href="reveal.js/css/theme/cbc.css" id="theme">
|
||||
<link rel="stylesheet" href="reveal.js/css/theme/simula.css" id="theme">
|
||||
<link rel="stylesheet" href="reveal.js/css/theme/black.css" id="theme">
|
||||
<link rel="stylesheet" href="reveal.js/css/theme/white.css" id="theme">
|
||||
<link rel="stylesheet" href="reveal.js/css/theme/league.css" id="theme">
|
||||
-->
|
||||
|
||||
<!-- For syntax highlighting -->
|
||||
<link rel="stylesheet" href="reveal.js/lib/css/zenburn.css">
|
||||
|
||||
<!-- Printing and PDF exports -->
|
||||
<script>
|
||||
var link = document.createElement( 'link' );
|
||||
link.rel = 'stylesheet';
|
||||
link.type = 'text/css';
|
||||
link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css';
|
||||
document.getElementsByTagName( 'head' )[0].appendChild( link );
|
||||
</script>
|
||||
|
||||
<style type="text/css">
|
||||
hr { border: 0; width: 80%; border-bottom: 1px solid #aaa}
|
||||
p.caption { width: 80%; font-size: 60%; font-style: italic; text-align: left; }
|
||||
hr.figure { border: 0; width: 80%; border-bottom: 1px solid #aaa}
|
||||
.reveal .alert-text-small { font-size: 80%; }
|
||||
.reveal .alert-text-large { font-size: 130%; }
|
||||
.reveal .alert-text-normal { font-size: 90%; }
|
||||
.reveal .alert {
|
||||
padding:8px 35px 8px 14px; margin-bottom:18px;
|
||||
text-shadow:0 1px 0 rgba(255,255,255,0.5);
|
||||
border:5px solid #bababa;
|
||||
-webkit-border-radius: 14px; -moz-border-radius: 14px;
|
||||
border-radius:14px;
|
||||
background-position: 10px 10px;
|
||||
background-repeat: no-repeat;
|
||||
background-size: 38px;
|
||||
padding-left: 30px; /* 55px; if icon */
|
||||
}
|
||||
.reveal .alert-block {padding-top:14px; padding-bottom:14px}
|
||||
.reveal .alert-block > p, .alert-block > ul {margin-bottom:1em}
|
||||
/*.reveal .alert li {margin-top: 1em}*/
|
||||
.reveal .alert-block p+p {margin-top:5px}
|
||||
/*.reveal .alert-notice { background-image: url(http://hplgit.github.io/doconce/bundled/html_images/small_gray_notice.png); }
|
||||
.reveal .alert-summary { background-image:url(http://hplgit.github.io/doconce/bundled/html_images/small_gray_summary.png); }
|
||||
.reveal .alert-warning { background-image: url(http://hplgit.github.io/doconce/bundled/html_images/small_gray_warning.png); }
|
||||
.reveal .alert-question {background-image:url(http://hplgit.github.io/doconce/bundled/html_images/small_gray_question.png); } */
|
||||
|
||||
</style>
|
||||
|
||||
|
||||
|
||||
<!-- Styles for table layout of slides -->
|
||||
<style type="text/css">
|
||||
td.padding {
|
||||
padding-top:20px;
|
||||
padding-bottom:20px;
|
||||
padding-right:50px;
|
||||
padding-left:50px;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="reveal">
|
||||
|
||||
<!-- Any section element inside the <div class="slides"> container
|
||||
is displayed as a slide -->
|
||||
|
||||
<div class="slides">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/x-mathjax-config">
|
||||
MathJax.Hub.Config({
|
||||
TeX: {
|
||||
equationNumbers: { autoNumber: "none" },
|
||||
extensions: ["AMSmath.js", "AMSsymbols.js", "autobold.js", "color.js"]
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<script type="text/javascript" async
|
||||
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<!-- ------------------- main content ---------------------- -->
|
||||
|
||||
|
||||
|
||||
<center><h1 style="text-align: center;">Convolutional Neural Networks</h1></center> <!-- document title -->
|
||||
|
||||
<p>
|
||||
<!-- author(s): Morten Hjorth-Jensen -->
|
||||
|
||||
<center>
|
||||
<b>Morten Hjorth-Jensen</b> [1, 2]
|
||||
</center>
|
||||
|
||||
<p> <br>
|
||||
<!-- institution(s) -->
|
||||
|
||||
<center>[1] <b>Department of Physics, University of Oslo</b></center>
|
||||
<center>[2] <b>Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University</b></center>
|
||||
<br>
|
||||
<p> <br>
|
||||
<center><h4>Oct 3, 2019</h4></center> <!-- date -->
|
||||
<br>
|
||||
<p>
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright --> © 1999-2019, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license
|
||||
</center>
|
||||
</section>
|
||||
|
||||
|
||||
<section>
|
||||
<h2 id="___sec0">Convolutional Neural Networks (recognizing images) </h2>
|
||||
|
||||
<p>
|
||||
Convolutional Neural Networks (CNN) are very similar to ordinary Neural Networks.
|
||||
|
||||
<p>
|
||||
They are made up of neurons that have learnable weights and
|
||||
biases. Each neuron receives some inputs, performs a dot product and
|
||||
optionally follows it with a non-linearity. The whole network still
|
||||
expresses a single differentiable score function: from the raw image
|
||||
pixels on one end to class scores at the other. And they still have a
|
||||
loss function (for example Softmax) on the last (fully-connected) layer
|
||||
and all the tips/tricks we developed for learning regular Neural
|
||||
Networks still apply (back propagation, gradient descent etc etc).
|
||||
|
||||
<p>
|
||||
What is the difference? <b>CNN architectures make the explicit assumption that
|
||||
the inputs are images, which allows us to encode certain properties
|
||||
into the architecture. These then make the forward function more
|
||||
efficient to implement and vastly reduce the amount of parameters in
|
||||
the network.</b>
|
||||
|
||||
<p>
|
||||
Here we provide only a superficial overview, for the more interested, we recommend highly the course
|
||||
<a href="https://www.uio.no/studier/emner/matnat/ifi/IN5400/index-eng.html" target="_blank">IN5400 – Machine Learning for Image Analysis</a>
|
||||
and the slides of <a href="http://cs231n.github.io/convolutional-networks/" target="_blank">CS231</a>.
|
||||
</section>
|
||||
|
||||
|
||||
<section>
|
||||
<h2 id="___sec1">Regular NNs don’t scale well to full images </h2>
|
||||
|
||||
<p>
|
||||
As an example, consider
|
||||
an image of size \( 32\times 32\times 3 \) (32 wide, 32 high, 3 color channels), so a
|
||||
single fully-connected neuron in a first hidden layer of a regular
|
||||
Neural Network would have \( 32\times 32\times 3 = 3072 \) weights. This amount still
|
||||
seems manageable, but clearly this fully-connected structure does not
|
||||
scale to larger images. For example, an image of more respectable
|
||||
size, say \( 200\times 200\times 3 \), would lead to neurons that have
|
||||
\( 200\times 200\times 3 = 120,000 \) weights.
|
||||
|
||||
<p>
|
||||
We could have
|
||||
several such neurons, and the parameters would add up quickly! Clearly,
|
||||
this full connectivity is wasteful and the huge number of parameters
|
||||
would quickly lead to possible overfitting.
|
||||
|
||||
<p>
|
||||
<center> <!-- FIGURE -->
|
||||
<hr class="figure">
|
||||
<center><p class="caption">Figure 1: A regular 3-layer Neural Network. </p></center>
|
||||
<p><img src="figslides/nn.jpeg" align="bottom" width=500></p>
|
||||
</center>
|
||||
</section>
|
||||
|
||||
|
||||
<section>
|
||||
<h2 id="___sec2">3D volumes of neurons </h2>
|
||||
|
||||
<p>
|
||||
Convolutional Neural Networks take advantage of the fact that the
|
||||
input consists of images and they constrain the architecture in a more
|
||||
sensible way.
|
||||
|
||||
<p>
|
||||
In particular, unlike a regular Neural Network, the
|
||||
layers of a CNN have neurons arranged in 3 dimensions: width,
|
||||
height, depth. (Note that the word depth here refers to the third
|
||||
dimension of an activation volume, not to the depth of a full Neural
|
||||
Network, which can refer to the total number of layers in a network.)
|
||||
|
||||
<p>
|
||||
To understand it better, the above example of an image
|
||||
with an input volume of
|
||||
activations has dimensions \( 32\times 32\times 3 \) (width, height,
|
||||
depth respectively).
|
||||
|
||||
<p>
|
||||
The neurons in a layer will
|
||||
only be connected to a small region of the layer before it, instead of
|
||||
all of the neurons in a fully-connected manner. Moreover, the final
|
||||
output layer could for this specific image have dimensions \( 1\times 1 \times 10 \),
|
||||
because by the
|
||||
end of the CNN architecture we will reduce the full image into a
|
||||
single vector of class scores, arranged along the depth
|
||||
dimension.
|
||||
|
||||
<p>
|
||||
<center> <!-- FIGURE -->
|
||||
<hr class="figure">
|
||||
<center><p class="caption">Figure 2: A CNN arranges its neurons in three dimensions (width, height, depth), as visualized in one of the layers. Every layer of a CNN transforms the 3D input volume to a 3D output volume of neuron activations. In this example, the red input layer holds the image, so its width and height would be the dimensions of the image, and the depth would be 3 (Red, Green, Blue channels). </p></center>
|
||||
<p><img src="figslides/cnn.jpeg" align="bottom" width=500></p>
|
||||
</center>
|
||||
</section>
|
||||
|
||||
|
||||
<section>
|
||||
<h2 id="___sec3">Layers used to build CNNs </h2>
|
||||
|
||||
<p>
|
||||
A simple CNN is a sequence of layers, and every layer of a CNN
|
||||
transforms one volume of activations to another through a
|
||||
differentiable function. We use three main types of layers to build
|
||||
CNN architectures: Convolutional Layer, Pooling Layer, and
|
||||
Fully-Connected Layer (exactly as seen in regular Neural Networks). We
|
||||
will stack these layers to form a full CNN architecture.
|
||||
|
||||
<p>
|
||||
A simple CNN for image classification could have the architecture:
|
||||
|
||||
<ul>
|
||||
<p><li> <b>INPUT</b> (\( 32\times 32 \times 3 \)) will hold the raw pixel values of the image, in this case an image of width 32, height 32, and with three color channels R,G,B.</li>
|
||||
<p><li> <b>CONV</b> (convolutional )layer will compute the output of neurons that are connected to local regions in the input, each computing a dot product between their weights and a small region they are connected to in the input volume. This may result in volume such as \( [32\times 32\times 12] \) if we decided to use 12 filters.</li>
|
||||
<p><li> <b>RELU</b> layer will apply an elementwise activation function, such as the \( max(0,x) \) thresholding at zero. This leaves the size of the volume unchanged (\( [32\times 32\times 12] \)).</li>
|
||||
<p><li> <b>POOL</b> (pooling) layer will perform a downsampling operation along the spatial dimensions (width, height), resulting in volume such as \( [16\times 16\times 12] \).</li>
|
||||
<p><li> <b>FC</b> (i.e. fully-connected) layer will compute the class scores, resulting in volume of size \( [1\times 1\times 10] \), where each of the 10 numbers correspond to a class score, such as among the 10 categories of the MNIST images we considered above . As with ordinary Neural Networks and as the name implies, each neuron in this layer will be connected to all the numbers in the previous volume.</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
|
||||
<section>
|
||||
<h2 id="___sec4">Transforming images </h2>
|
||||
|
||||
<p>
|
||||
CNNs transform the original image layer by layer from the original
|
||||
pixel values to the final class scores.
|
||||
|
||||
<p>
|
||||
Observe that some layers contain
|
||||
parameters and other don’t. In particular, the CNN layers perform
|
||||
transformations that are a function of not only the activations in the
|
||||
input volume, but also of the parameters (the weights and biases of
|
||||
the neurons). On the other hand, the RELU/POOL layers will implement a
|
||||
fixed function. The parameters in the CONV/FC layers will be trained
|
||||
with gradient descent so that the class scores that the CNN computes
|
||||
are consistent with the labels in the training set for each image.
|
||||
</section>
|
||||
|
||||
|
||||
<section>
|
||||
<h2 id="___sec5">CNNs in brief </h2>
|
||||
|
||||
<p>
|
||||
In summary:
|
||||
|
||||
<ul>
|
||||
<p><li> A CNN architecture is in the simplest case a list of Layers that transform the image volume into an output volume (e.g. holding the class scores)</li>
|
||||
<p><li> There are a few distinct types of Layers (e.g. CONV/FC/RELU/POOL are by far the most popular)</li>
|
||||
<p><li> Each Layer accepts an input 3D volume and transforms it to an output 3D volume through a differentiable function</li>
|
||||
<p><li> Each Layer may or may not have parameters (e.g. CONV/FC do, RELU/POOL don’t)</li>
|
||||
<p><li> Each Layer may or may not have additional hyperparameters (e.g. CONV/FC/POOL do, RELU doesn’t)</li>
|
||||
</ul>
|
||||
<p>
|
||||
|
||||
For more material on convolutional networks, we strongly recommend
|
||||
the course
|
||||
<a href="https://www.uio.no/studier/emner/matnat/ifi/IN5400/index-eng.html" target="_blank">IN5400 – Machine Learning for Image Analysis</a>
|
||||
and the slides of <a href="http://cs231n.github.io/convolutional-networks/" target="_blank">CS231</a> which is taught at Stanford University (consistently ranked as one of the top computer science programs in the world). <a href="http://neuralnetworksanddeeplearning.com/chap6.html" target="_blank">Michael Nielsen's book is a must read, in particular chapter 6 which deals with CNNs</a>.
|
||||
</section>
|
||||
|
||||
|
||||
<section>
|
||||
<h2 id="___sec6">CNNs in more detail, building convolutional neural networks in Tensorflow and Keras </h2>
|
||||
|
||||
<p>
|
||||
As discussed above, CNNs are neural networks built from the assumption that the inputs
|
||||
to the network are 2D images. This is important because the number of features or pixels in images
|
||||
grows very fast with the image size, and an enormous number of weights and biases are needed in order to build an accurate network.
|
||||
|
||||
<p>
|
||||
As before, we still have our input, a hidden layer and an output. What's novel about convolutional networks
|
||||
are the <b>convolutional</b> and <b>pooling</b> layers stacked in pairs between the input and the hidden layer.
|
||||
In addition, the data is no longer represented as a 2D feature matrix, instead each input is a number of 2D
|
||||
matrices, typically 1 for each color dimension (Red, Green, Blue).
|
||||
</section>
|
||||
|
||||
|
||||
<section>
|
||||
<h2 id="___sec7">Setting it up </h2>
|
||||
|
||||
<p>
|
||||
It means that to represent the entire
|
||||
dataset of images, we require a 4D matrix or <b>tensor</b>. This tensor has the dimensions:
|
||||
|
||||
<p> <br>
|
||||
$$
|
||||
(n_{inputs},\, n_{pixels, width},\, n_{pixels, height},\, depth) .
|
||||
$$
|
||||
<p> <br>
|
||||
</section>
|
||||
|
||||
|
||||
<section>
|
||||
<h2 id="___sec8">The MNIST dataset again </h2>
|
||||
|
||||
<p>
|
||||
The MNIST dataset consists of grayscale images with a pixel size of
|
||||
\( 28\times 28 \), meaning we require \( 28 \times 28 = 724 \) weights to each
|
||||
neuron in the first hidden layer.
|
||||
|
||||
<p>
|
||||
If we were to analyze images of size \( 128\times 128 \) we would require
|
||||
\( 128 \times 128 = 16384 \) weights to each neuron. Even worse if we were
|
||||
dealing with color images, as most images are, we have an image matrix
|
||||
of size \( 128\times 128 \) for each color dimension (Red, Green, Blue),
|
||||
meaning 3 times the number of weights \( = 49152 \) are required for every
|
||||
single neuron in the first hidden layer.
|
||||
</section>
|
||||
|
||||
|
||||
<section>
|
||||
<h2 id="___sec9">Strong correlations </h2>
|
||||
Images typically have strong local correlations, meaning that a small
|
||||
part of the image varies little from its neighboring regions. If for
|
||||
example we have an image of a blue car, we can roughly assume that a
|
||||
small blue part of the image is surrounded by other blue regions.
|
||||
|
||||
<p>
|
||||
Therefore, instead of connecting every single pixel to a neuron in the
|
||||
first hidden layer, as we have previously done with deep neural
|
||||
networks, we can instead connect each neuron to a small part of the
|
||||
image (in all 3 RGB depth dimensions). The size of each small area is
|
||||
fixed, and known as a <a href="https://en.wikipedia.org/wiki/Receptive_field" target="_blank">receptive</a>.
|
||||
</section>
|
||||
|
||||
|
||||
<section>
|
||||
<h2 id="___sec10">Layers of a CNN </h2>
|
||||
The layers of a convolutional neural network arrange neurons in 3D: width, height and depth.
|
||||
The input image is typically a square matrix of depth 3.
|
||||
|
||||
<p>
|
||||
A <b>convolution</b> is performed on the image which outputs
|
||||
a 3D volume of neurons. The weights to the input are arranged in a number of 2D matrices, known as <b>filters</b>.
|
||||
|
||||
<p>
|
||||
Each filter slides along the input image, taking the dot product
|
||||
between each small part of the image and the filter, in all depth
|
||||
dimensions. This is then passed through a non-linear function,
|
||||
typically the <b>Rectified Linear (ReLu)</b> function, which serves as the
|
||||
activation of the neurons in the first convolutional layer. This is
|
||||
further passed through a <b>pooling layer</b>, which reduces the size of the
|
||||
convolutional layer, e.g. by taking the maximum or average across some
|
||||
small regions, and this serves as input to the next convolutional
|
||||
layer.
|
||||
</section>
|
||||
|
||||
|
||||
<section>
|
||||
<h2 id="___sec11">Systematic reduction </h2>
|
||||
|
||||
<p>
|
||||
By systematically reducing the size of the input volume, through
|
||||
convolution and pooling, the network should create representations of
|
||||
small parts of the input, and then from them assemble representations
|
||||
of larger areas. The final pooling layer is flattened to serve as
|
||||
input to a hidden layer, such that each neuron in the final pooling
|
||||
layer is connected to every single neuron in the hidden layer. This
|
||||
then serves as input to the output layer, e.g. a softmax output for
|
||||
classification.
|
||||
</section>
|
||||
|
||||
|
||||
<section>
|
||||
<h2 id="___sec12">Prerequisites: Collect and pre-process data </h2>
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
|
||||
<div class="highlight" style="background: #eeeedd"><pre style="font-size: 80%; line-height: 125%"><span></span><span style="color: #228B22"># import necessary packages</span>
|
||||
<span style="color: #8B008B; font-weight: bold">import</span> <span style="color: #008b45; text-decoration: underline">numpy</span> <span style="color: #8B008B; font-weight: bold">as</span> <span style="color: #008b45; text-decoration: underline">np</span>
|
||||
<span style="color: #8B008B; font-weight: bold">import</span> <span style="color: #008b45; text-decoration: underline">matplotlib.pyplot</span> <span style="color: #8B008B; font-weight: bold">as</span> <span style="color: #008b45; text-decoration: underline">plt</span>
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn</span> <span style="color: #8B008B; font-weight: bold">import</span> datasets
|
||||
|
||||
|
||||
<span style="color: #228B22"># ensure the same random numbers appear every time</span>
|
||||
np.random.seed(<span style="color: #B452CD">0</span>)
|
||||
|
||||
<span style="color: #228B22"># display images in notebook</span>
|
||||
%matplotlib inline
|
||||
plt.rcParams[<span style="color: #CD5555">'figure.figsize'</span>] = (<span style="color: #B452CD">12</span>,<span style="color: #B452CD">12</span>)
|
||||
|
||||
|
||||
<span style="color: #228B22"># download MNIST dataset</span>
|
||||
digits = datasets.load_digits()
|
||||
|
||||
<span style="color: #228B22"># define inputs and labels</span>
|
||||
inputs = digits.images
|
||||
labels = digits.target
|
||||
|
||||
<span style="color: #228B22"># RGB images have a depth of 3</span>
|
||||
<span style="color: #228B22"># our images are grayscale so they should have a depth of 1</span>
|
||||
inputs = inputs[:,:,:,np.newaxis]
|
||||
|
||||
<span style="color: #8B008B; font-weight: bold">print</span>(<span style="color: #CD5555">"inputs = (n_inputs, pixel_width, pixel_height, depth) = "</span> + <span style="color: #658b00">str</span>(inputs.shape))
|
||||
<span style="color: #8B008B; font-weight: bold">print</span>(<span style="color: #CD5555">"labels = (n_inputs) = "</span> + <span style="color: #658b00">str</span>(labels.shape))
|
||||
|
||||
|
||||
<span style="color: #228B22"># choose some random images to display</span>
|
||||
n_inputs = <span style="color: #658b00">len</span>(inputs)
|
||||
indices = np.arange(n_inputs)
|
||||
random_indices = np.random.choice(indices, size=<span style="color: #B452CD">5</span>)
|
||||
|
||||
<span style="color: #8B008B; font-weight: bold">for</span> i, image <span style="color: #8B008B">in</span> <span style="color: #658b00">enumerate</span>(digits.images[random_indices]):
|
||||
plt.subplot(<span style="color: #B452CD">1</span>, <span style="color: #B452CD">5</span>, i+<span style="color: #B452CD">1</span>)
|
||||
plt.axis(<span style="color: #CD5555">'off'</span>)
|
||||
plt.imshow(image, cmap=plt.cm.gray_r, interpolation=<span style="color: #CD5555">'nearest'</span>)
|
||||
plt.title(<span style="color: #CD5555">"Label: %d"</span> % digits.target[random_indices[i]])
|
||||
plt.show()
|
||||
</pre></div>
|
||||
</section>
|
||||
|
||||
|
||||
<section>
|
||||
<h2 id="___sec13">Importing Keras and Tensorflow </h2>
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
|
||||
<div class="highlight" style="background: #eeeedd"><pre style="font-size: 80%; line-height: 125%"><span></span><span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">keras.utils</span> <span style="color: #8B008B; font-weight: bold">import</span> to_categorical
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.model_selection</span> <span style="color: #8B008B; font-weight: bold">import</span> train_test_split
|
||||
|
||||
<span style="color: #228B22"># representation of labels</span>
|
||||
labels = to_categorical(labels)
|
||||
|
||||
<span style="color: #228B22"># split into train and test data</span>
|
||||
<span style="color: #228B22"># one-liner from scikit-learn library</span>
|
||||
train_size = <span style="color: #B452CD">0.8</span>
|
||||
test_size = <span style="color: #B452CD">1</span> - train_size
|
||||
X_train, X_test, Y_train, Y_test = train_test_split(inputs, labels, train_size=train_size,
|
||||
test_size=test_size)
|
||||
</pre></div>
|
||||
</section>
|
||||
|
||||
|
||||
<section>
|
||||
<h2 id="___sec14">Using TensorFlow backend </h2>
|
||||
|
||||
<p>
|
||||
We need to define model and architecture and choose cost function and optmizer.
|
||||
<p>
|
||||
|
||||
<!-- code=text (!bc pycid) typeset with pygments style "perldoc" -->
|
||||
<div class="highlight" style="background: #eeeedd"><pre style="font-size: 80%; line-height: 125%"><span></span>import tensorflow as tf
|
||||
|
||||
class ConvolutionalNeuralNetworkTensorflow:
|
||||
def __init__(
|
||||
self,
|
||||
X_train,
|
||||
Y_train,
|
||||
X_test,
|
||||
Y_test,
|
||||
n_filters=10,
|
||||
n_neurons_connected=50,
|
||||
n_categories=10,
|
||||
receptive_field=3,
|
||||
stride=1,
|
||||
padding=1,
|
||||
epochs=10,
|
||||
batch_size=100,
|
||||
eta=0.1,
|
||||
lmbd=0.0):
|
||||
|
||||
self.global_step = tf.Variable(0, dtype=tf.int32, trainable=False, name='global_step')
|
||||
|
||||
self.X_train = X_train
|
||||
self.Y_train = Y_train
|
||||
self.X_test = X_test
|
||||
self.Y_test = Y_test
|
||||
|
||||
self.n_inputs, self.input_width, self.input_height, self.depth = X_train.shape
|
||||
|
||||
self.n_filters = n_filters
|
||||
self.n_downsampled = int(self.input_width*self.input_height*n_filters / 4)
|
||||
self.n_neurons_connected = n_neurons_connected
|
||||
self.n_categories = n_categories
|
||||
|
||||
self.receptive_field = receptive_field
|
||||
self.stride = stride
|
||||
self.strides = [stride, stride, stride, stride]
|
||||
self.padding = padding
|
||||
|
||||
self.epochs = epochs
|
||||
self.batch_size = batch_size
|
||||
self.iterations = self.n_inputs // self.batch_size
|
||||
self.eta = eta
|
||||
self.lmbd = lmbd
|
||||
|
||||
self.create_placeholders()
|
||||
self.create_CNN()
|
||||
self.create_loss()
|
||||
self.create_optimiser()
|
||||
self.create_accuracy()
|
||||
|
||||
def create_placeholders(self):
|
||||
with tf.name_scope('data'):
|
||||
self.X = tf.placeholder(tf.float32, shape=(None, self.input_width, self.input_height, self.depth), name='X_data')
|
||||
self.Y = tf.placeholder(tf.float32, shape=(None, self.n_categories), name='Y_data')
|
||||
|
||||
def create_CNN(self):
|
||||
with tf.name_scope('CNN'):
|
||||
|
||||
# Convolutional layer
|
||||
self.W_conv = self.weight_variable([self.receptive_field, self.receptive_field, self.depth, self.n_filters], name='conv', dtype=tf.float32)
|
||||
b_conv = self.weight_variable([self.n_filters], name='conv', dtype=tf.float32)
|
||||
z_conv = tf.nn.conv2d(self.X, self.W_conv, self.strides, padding='SAME', name='conv') + b_conv
|
||||
a_conv = tf.nn.relu(z_conv)
|
||||
|
||||
# 2x2 max pooling
|
||||
a_pool = tf.nn.max_pool(a_conv, [1, 2, 2, 1], [1, 2, 2, 1], padding='SAME', name='pool')
|
||||
|
||||
# Fully connected layer
|
||||
a_pool_flat = tf.reshape(a_pool, [-1, self.n_downsampled])
|
||||
self.W_fc = self.weight_variable([self.n_downsampled, self.n_neurons_connected], name='fc', dtype=tf.float32)
|
||||
b_fc = self.bias_variable([self.n_neurons_connected], name='fc', dtype=tf.float32)
|
||||
a_fc = tf.nn.relu(tf.matmul(a_pool_flat, self.W_fc) + b_fc)
|
||||
|
||||
# Output layer
|
||||
self.W_out = self.weight_variable([self.n_neurons_connected, self.n_categories], name='out', dtype=tf.float32)
|
||||
b_out = self.bias_variable([self.n_categories], name='out', dtype=tf.float32)
|
||||
self.z_out = tf.matmul(a_fc, self.W_out) + b_out
|
||||
|
||||
def create_loss(self):
|
||||
with tf.name_scope('loss'):
|
||||
softmax_loss = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits_v2(labels=self.Y, logits=self.z_out))
|
||||
|
||||
regularizer_loss_conv = tf.nn.l2_loss(self.W_conv)
|
||||
regularizer_loss_fc = tf.nn.l2_loss(self.W_fc)
|
||||
regularizer_loss_out = tf.nn.l2_loss(self.W_out)
|
||||
regularizer_loss = self.lmbd*(regularizer_loss_conv + regularizer_loss_fc + regularizer_loss_out)
|
||||
|
||||
self.loss = softmax_loss + regularizer_loss
|
||||
|
||||
def create_accuracy(self):
|
||||
with tf.name_scope('accuracy'):
|
||||
probabilities = tf.nn.softmax(self.z_out)
|
||||
predictions = tf.argmax(probabilities, 1)
|
||||
labels = tf.argmax(self.Y, 1)
|
||||
|
||||
correct_predictions = tf.equal(predictions, labels)
|
||||
correct_predictions = tf.cast(correct_predictions, tf.float32)
|
||||
self.accuracy = tf.reduce_mean(correct_predictions)
|
||||
|
||||
def create_optimiser(self):
|
||||
with tf.name_scope('optimizer'):
|
||||
self.optimizer = tf.train.GradientDescentOptimizer(learning_rate=self.eta).minimize(self.loss, global_step=self.global_step)
|
||||
|
||||
def weight_variable(self, shape, name='', dtype=tf.float32):
|
||||
initial = tf.truncated_normal(shape, stddev=0.1)
|
||||
return tf.Variable(initial, name=name, dtype=dtype)
|
||||
|
||||
def bias_variable(self, shape, name='', dtype=tf.float32):
|
||||
initial = tf.constant(0.1, shape=shape)
|
||||
return tf.Variable(initial, name=name, dtype=dtype)
|
||||
|
||||
def fit(self):
|
||||
data_indices = np.arange(self.n_inputs)
|
||||
|
||||
with tf.Session() as sess:
|
||||
sess.run(tf.global_variables_initializer())
|
||||
for i in range(self.epochs):
|
||||
for j in range(self.iterations):
|
||||
chosen_datapoints = np.random.choice(data_indices, size=self.batch_size, replace=False)
|
||||
batch_X, batch_Y = self.X_train[chosen_datapoints], self.Y_train[chosen_datapoints]
|
||||
|
||||
sess.run([CNN.loss, CNN.optimizer],
|
||||
feed_dict={CNN.X: batch_X,
|
||||
CNN.Y: batch_Y})
|
||||
accuracy = sess.run(CNN.accuracy,
|
||||
feed_dict={CNN.X: batch_X,
|
||||
CNN.Y: batch_Y})
|
||||
step = sess.run(CNN.global_step)
|
||||
|
||||
self.train_loss, self.train_accuracy = sess.run([CNN.loss, CNN.accuracy],
|
||||
feed_dict={CNN.X: self.X_train,
|
||||
CNN.Y: self.Y_train})
|
||||
|
||||
self.test_loss, self.test_accuracy = sess.run([CNN.loss, CNN.accuracy],
|
||||
feed_dict={CNN.X: self.X_test,
|
||||
CNN.Y: self.Y_test})
|
||||
</pre></div>
|
||||
</section>
|
||||
|
||||
|
||||
<section>
|
||||
<h2 id="___sec15">Train the model </h2>
|
||||
|
||||
<p>
|
||||
We need now to train the model, evaluate it and test its performance on test data, and eventually include hyperparameters.
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
|
||||
<div class="highlight" style="background: #eeeedd"><pre style="font-size: 80%; line-height: 125%"><span></span>epochs = <span style="color: #B452CD">100</span>
|
||||
batch_size = <span style="color: #B452CD">100</span>
|
||||
n_filters = <span style="color: #B452CD">10</span>
|
||||
n_neurons_connected = <span style="color: #B452CD">50</span>
|
||||
n_categories = <span style="color: #B452CD">10</span>
|
||||
|
||||
eta_vals = np.logspace(-<span style="color: #B452CD">5</span>, <span style="color: #B452CD">1</span>, <span style="color: #B452CD">7</span>)
|
||||
lmbd_vals = np.logspace(-<span style="color: #B452CD">5</span>, <span style="color: #B452CD">1</span>, <span style="color: #B452CD">7</span>)
|
||||
CNN_tf = np.zeros((<span style="color: #658b00">len</span>(eta_vals), <span style="color: #658b00">len</span>(lmbd_vals)), dtype=<span style="color: #658b00">object</span>)
|
||||
|
||||
<span style="color: #8B008B; font-weight: bold">for</span> i, eta <span style="color: #8B008B">in</span> <span style="color: #658b00">enumerate</span>(eta_vals):
|
||||
<span style="color: #8B008B; font-weight: bold">for</span> j, lmbd <span style="color: #8B008B">in</span> <span style="color: #658b00">enumerate</span>(lmbd_vals):
|
||||
CNN = ConvolutionalNeuralNetworkTensorflow(X_train, Y_train, X_test, Y_test,
|
||||
n_filters=n_filters, n_neurons_connected=n_neurons_connected,
|
||||
n_categories=n_categories, epochs=epochs, batch_size=batch_size,
|
||||
eta=eta, lmbd=lmbd)
|
||||
CNN.fit()
|
||||
|
||||
<span style="color: #8B008B; font-weight: bold">print</span>(<span style="color: #CD5555">"Learning rate = "</span>, eta)
|
||||
<span style="color: #8B008B; font-weight: bold">print</span>(<span style="color: #CD5555">"Lambda = "</span>, lmbd)
|
||||
<span style="color: #8B008B; font-weight: bold">print</span>(<span style="color: #CD5555">"Test accuracy: %.3f"</span> % CNN.test_accuracy)
|
||||
<span style="color: #8B008B; font-weight: bold">print</span>()
|
||||
|
||||
CNN_tf[i][j] = CNN
|
||||
</pre></div>
|
||||
</section>
|
||||
|
||||
|
||||
<section>
|
||||
<h2 id="___sec16">Visualizing the results </h2>
|
||||
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
|
||||
<div class="highlight" style="background: #eeeedd"><pre style="font-size: 80%; line-height: 125%"><span></span><span style="color: #228B22"># visual representation of grid search</span>
|
||||
<span style="color: #228B22"># uses seaborn heatmap, could probably do this in matplotlib</span>
|
||||
<span style="color: #8B008B; font-weight: bold">import</span> <span style="color: #008b45; text-decoration: underline">seaborn</span> <span style="color: #8B008B; font-weight: bold">as</span> <span style="color: #008b45; text-decoration: underline">sns</span>
|
||||
|
||||
sns.set()
|
||||
|
||||
train_accuracy = np.zeros((<span style="color: #658b00">len</span>(eta_vals), <span style="color: #658b00">len</span>(lmbd_vals)))
|
||||
test_accuracy = np.zeros((<span style="color: #658b00">len</span>(eta_vals), <span style="color: #658b00">len</span>(lmbd_vals)))
|
||||
|
||||
<span style="color: #8B008B; font-weight: bold">for</span> i <span style="color: #8B008B">in</span> <span style="color: #658b00">range</span>(<span style="color: #658b00">len</span>(eta_vals)):
|
||||
<span style="color: #8B008B; font-weight: bold">for</span> j <span style="color: #8B008B">in</span> <span style="color: #658b00">range</span>(<span style="color: #658b00">len</span>(lmbd_vals)):
|
||||
CNN = CNN_tf[i][j]
|
||||
|
||||
train_accuracy[i][j] = CNN.train_accuracy
|
||||
test_accuracy[i][j] = CNN.test_accuracy
|
||||
|
||||
|
||||
fig, ax = plt.subplots(figsize = (<span style="color: #B452CD">10</span>, <span style="color: #B452CD">10</span>))
|
||||
sns.heatmap(train_accuracy, annot=<span style="color: #658b00">True</span>, ax=ax, cmap=<span style="color: #CD5555">"viridis"</span>)
|
||||
ax.set_title(<span style="color: #CD5555">"Training Accuracy"</span>)
|
||||
ax.set_ylabel(<span style="color: #CD5555">"$\eta$"</span>)
|
||||
ax.set_xlabel(<span style="color: #CD5555">"$\lambda$"</span>)
|
||||
plt.show()
|
||||
|
||||
fig, ax = plt.subplots(figsize = (<span style="color: #B452CD">10</span>, <span style="color: #B452CD">10</span>))
|
||||
sns.heatmap(test_accuracy, annot=<span style="color: #658b00">True</span>, ax=ax, cmap=<span style="color: #CD5555">"viridis"</span>)
|
||||
ax.set_title(<span style="color: #CD5555">"Test Accuracy"</span>)
|
||||
ax.set_ylabel(<span style="color: #CD5555">"$\eta$"</span>)
|
||||
ax.set_xlabel(<span style="color: #CD5555">"$\lambda$"</span>)
|
||||
plt.show()
|
||||
</pre></div>
|
||||
</section>
|
||||
|
||||
|
||||
<section>
|
||||
<h2 id="___sec17">Running with Keras </h2>
|
||||
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
|
||||
<div class="highlight" style="background: #eeeedd"><pre style="font-size: 80%; line-height: 125%"><span></span><span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">keras.models</span> <span style="color: #8B008B; font-weight: bold">import</span> Sequential
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">keras.layers.convolutional</span> <span style="color: #8B008B; font-weight: bold">import</span> Conv2D
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">keras.layers.convolutional</span> <span style="color: #8B008B; font-weight: bold">import</span> MaxPooling2D
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">keras.layers</span> <span style="color: #8B008B; font-weight: bold">import</span> Flatten
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">keras.layers</span> <span style="color: #8B008B; font-weight: bold">import</span> Dense
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">keras.regularizers</span> <span style="color: #8B008B; font-weight: bold">import</span> l2
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">keras.optimizers</span> <span style="color: #8B008B; font-weight: bold">import</span> SGD
|
||||
|
||||
<span style="color: #8B008B; font-weight: bold">def</span> <span style="color: #008b45">create_convolutional_neural_network_keras</span>(input_shape, receptive_field,
|
||||
n_filters, n_neurons_connected, n_categories,
|
||||
eta, lmbd):
|
||||
model = Sequential()
|
||||
model.add(Conv2D(n_filters, (receptive_field, receptive_field), input_shape=input_shape, padding=<span style="color: #CD5555">'same'</span>,
|
||||
activation=<span style="color: #CD5555">'relu'</span>, kernel_regularizer=l2(lmbd)))
|
||||
model.add(MaxPooling2D(pool_size=(<span style="color: #B452CD">2</span>, <span style="color: #B452CD">2</span>)))
|
||||
model.add(Flatten())
|
||||
model.add(Dense(n_neurons_connected, activation=<span style="color: #CD5555">'relu'</span>, kernel_regularizer=l2(lmbd)))
|
||||
model.add(Dense(n_categories, activation=<span style="color: #CD5555">'softmax'</span>, kernel_regularizer=l2(lmbd)))
|
||||
|
||||
sgd = SGD(lr=eta)
|
||||
model.compile(loss=<span style="color: #CD5555">'categorical_crossentropy'</span>, optimizer=sgd, metrics=[<span style="color: #CD5555">'accuracy'</span>])
|
||||
|
||||
<span style="color: #8B008B; font-weight: bold">return</span> model
|
||||
|
||||
epochs = <span style="color: #B452CD">100</span>
|
||||
batch_size = <span style="color: #B452CD">100</span>
|
||||
input_shape = X_train.shape[<span style="color: #B452CD">1</span>:<span style="color: #B452CD">4</span>]
|
||||
receptive_field = <span style="color: #B452CD">3</span>
|
||||
n_filters = <span style="color: #B452CD">10</span>
|
||||
n_neurons_connected = <span style="color: #B452CD">50</span>
|
||||
n_categories = <span style="color: #B452CD">10</span>
|
||||
|
||||
eta_vals = np.logspace(-<span style="color: #B452CD">5</span>, <span style="color: #B452CD">1</span>, <span style="color: #B452CD">7</span>)
|
||||
lmbd_vals = np.logspace(-<span style="color: #B452CD">5</span>, <span style="color: #B452CD">1</span>, <span style="color: #B452CD">7</span>)
|
||||
</pre></div>
|
||||
</section>
|
||||
|
||||
|
||||
<section>
|
||||
<h2 id="___sec18">Final part </h2>
|
||||
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
|
||||
<div class="highlight" style="background: #eeeedd"><pre style="font-size: 80%; line-height: 125%"><span></span>CNN_keras = np.zeros((<span style="color: #658b00">len</span>(eta_vals), <span style="color: #658b00">len</span>(lmbd_vals)), dtype=<span style="color: #658b00">object</span>)
|
||||
|
||||
<span style="color: #8B008B; font-weight: bold">for</span> i, eta <span style="color: #8B008B">in</span> <span style="color: #658b00">enumerate</span>(eta_vals):
|
||||
<span style="color: #8B008B; font-weight: bold">for</span> j, lmbd <span style="color: #8B008B">in</span> <span style="color: #658b00">enumerate</span>(lmbd_vals):
|
||||
CNN = create_convolutional_neural_network_keras(input_shape, receptive_field,
|
||||
n_filters, n_neurons_connected, n_categories,
|
||||
eta, lmbd)
|
||||
CNN.fit(X_train, Y_train, epochs=epochs, batch_size=batch_size, verbose=<span style="color: #B452CD">0</span>)
|
||||
scores = CNN.evaluate(X_test, Y_test)
|
||||
|
||||
CNN_keras[i][j] = CNN
|
||||
|
||||
<span style="color: #8B008B; font-weight: bold">print</span>(<span style="color: #CD5555">"Learning rate = "</span>, eta)
|
||||
<span style="color: #8B008B; font-weight: bold">print</span>(<span style="color: #CD5555">"Lambda = "</span>, lmbd)
|
||||
<span style="color: #8B008B; font-weight: bold">print</span>(<span style="color: #CD5555">"Test accuracy: %.3f"</span> % scores[<span style="color: #B452CD">1</span>])
|
||||
<span style="color: #8B008B; font-weight: bold">print</span>()
|
||||
</pre></div>
|
||||
</section>
|
||||
|
||||
|
||||
<section>
|
||||
<h2 id="___sec19">Final visualization </h2>
|
||||
|
||||
<p>
|
||||
|
||||
<!-- code=text typeset with pygments style "perldoc" -->
|
||||
<div class="highlight" style="background: #eeeedd"><pre style="font-size: 80%; line-height: 125%"><span></span># visual representation of grid search
|
||||
# uses seaborn heatmap, could probably do this in matplotlib
|
||||
import seaborn as sns
|
||||
|
||||
sns.set()
|
||||
|
||||
train_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))
|
||||
test_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))
|
||||
|
||||
for i in range(len(eta_vals)):
|
||||
for j in range(len(lmbd_vals)):
|
||||
CNN = CNN_keras[i][j]
|
||||
|
||||
train_accuracy[i][j] = CNN.evaluate(X_train, Y_train)[1]
|
||||
test_accuracy[i][j] = CNN.evaluate(X_test, Y_test)[1]
|
||||
|
||||
|
||||
fig, ax = plt.subplots(figsize = (10, 10))
|
||||
sns.heatmap(train_accuracy, annot=True, ax=ax, cmap="viridis")
|
||||
ax.set_title("Training Accuracy")
|
||||
ax.set_ylabel("$\eta$")
|
||||
ax.set_xlabel("$\lambda$")
|
||||
plt.show()
|
||||
|
||||
fig, ax = plt.subplots(figsize = (10, 10))
|
||||
sns.heatmap(test_accuracy, annot=True, ax=ax, cmap="viridis")
|
||||
ax.set_title("Test Accuracy")
|
||||
ax.set_ylabel("$\eta$")
|
||||
ax.set_xlabel("$\lambda$")
|
||||
plt.show()
|
||||
</pre></div>
|
||||
</section>
|
||||
|
||||
|
||||
<section>
|
||||
<h2 id="___sec20">Fun links </h2>
|
||||
|
||||
<ol>
|
||||
<p><li> <a href="https://arxiv.org/abs/1604.07316" target="_blank">Self-Driving cars using a convolutional neural network</a></li>
|
||||
<p><li> <a href="https://deepdreamgenerator.com/" target="_blank">Abstract art using convolutional neural networks</a></li>
|
||||
</ol>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
</div> <!-- class="slides" -->
|
||||
</div> <!-- class="reveal" -->
|
||||
|
||||
<script src="reveal.js/lib/js/head.min.js"></script>
|
||||
<script src="reveal.js/js/reveal.js"></script>
|
||||
|
||||
<script>
|
||||
// Full list of configuration options available here:
|
||||
// https://github.com/hakimel/reveal.js#configuration
|
||||
Reveal.initialize({
|
||||
|
||||
// Display navigation controls in the bottom right corner
|
||||
controls: true,
|
||||
|
||||
// Display progress bar (below the horiz. slider)
|
||||
progress: true,
|
||||
|
||||
// Display the page number of the current slide
|
||||
slideNumber: true,
|
||||
|
||||
// Push each slide change to the browser history
|
||||
history: false,
|
||||
|
||||
// Enable keyboard shortcuts for navigation
|
||||
keyboard: true,
|
||||
|
||||
// Enable the slide overview mode
|
||||
overview: true,
|
||||
|
||||
// Vertical centering of slides
|
||||
//center: true,
|
||||
center: false,
|
||||
|
||||
// Enables touch navigation on devices with touch input
|
||||
touch: true,
|
||||
|
||||
// Loop the presentation
|
||||
loop: false,
|
||||
|
||||
// Change the presentation direction to be RTL
|
||||
rtl: false,
|
||||
|
||||
// Turns fragments on and off globally
|
||||
fragments: true,
|
||||
|
||||
// Flags if the presentation is running in an embedded mode,
|
||||
// i.e. contained within a limited portion of the screen
|
||||
embedded: false,
|
||||
|
||||
// Number of milliseconds between automatically proceeding to the
|
||||
// next slide, disabled when set to 0, this value can be overwritten
|
||||
// by using a data-autoslide attribute on your slides
|
||||
autoSlide: 0,
|
||||
|
||||
// Stop auto-sliding after user input
|
||||
autoSlideStoppable: true,
|
||||
|
||||
// Enable slide navigation via mouse wheel
|
||||
mouseWheel: false,
|
||||
|
||||
// Hides the address bar on mobile devices
|
||||
hideAddressBar: true,
|
||||
|
||||
// Opens links in an iframe preview overlay
|
||||
previewLinks: false,
|
||||
|
||||
// Transition style
|
||||
transition: 'default', // default/cube/page/concave/zoom/linear/fade/none
|
||||
|
||||
// Transition speed
|
||||
transitionSpeed: 'default', // default/fast/slow
|
||||
|
||||
// Transition style for full page slide backgrounds
|
||||
backgroundTransition: 'default', // default/none/slide/concave/convex/zoom
|
||||
|
||||
// Number of slides away from the current that are visible
|
||||
viewDistance: 3,
|
||||
|
||||
// Parallax background image
|
||||
//parallaxBackgroundImage: '', // e.g. "'https://s3.amazonaws.com/hakim-static/reveal-js/reveal-parallax-1.jpg'"
|
||||
|
||||
// Parallax background size
|
||||
//parallaxBackgroundSize: '' // CSS syntax, e.g. "2100px 900px"
|
||||
|
||||
theme: Reveal.getQueryHash().theme, // available themes are in reveal.js/css/theme
|
||||
transition: Reveal.getQueryHash().transition || 'default', // default/cube/page/concave/zoom/linear/none
|
||||
|
||||
});
|
||||
|
||||
Reveal.initialize({
|
||||
dependencies: [
|
||||
// Cross-browser shim that fully implements classList - https://github.com/eligrey/classList.js/
|
||||
{ src: 'reveal.js/lib/js/classList.js', condition: function() { return !document.body.classList; } },
|
||||
|
||||
// Interpret Markdown in <section> elements
|
||||
{ src: 'reveal.js/plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
|
||||
{ src: 'reveal.js/plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
|
||||
|
||||
// Syntax highlight for <code> elements
|
||||
{ src: 'reveal.js/plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
|
||||
|
||||
// Zoom in and out with Alt+click
|
||||
{ src: 'reveal.js/plugin/zoom-js/zoom.js', async: true, condition: function() { return !!document.body.classList; } },
|
||||
|
||||
// Speaker notes
|
||||
{ src: 'reveal.js/plugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } },
|
||||
|
||||
// Remote control your reveal.js presentation using a touch device
|
||||
//{ src: 'reveal.js/plugin/remotes/remotes.js', async: true, condition: function() { return !!document.body.classList; } },
|
||||
|
||||
// MathJax
|
||||
//{ src: 'reveal.js/plugin/math/math.js', async: true }
|
||||
]
|
||||
});
|
||||
|
||||
Reveal.initialize({
|
||||
|
||||
// The "normal" size of the presentation, aspect ratio will be preserved
|
||||
// when the presentation is scaled to fit different resolutions. Can be
|
||||
// specified using percentage units.
|
||||
width: 1170, // original: 960,
|
||||
height: 700,
|
||||
|
||||
// Factor of the display size that should remain empty around the content
|
||||
margin: 0.1,
|
||||
|
||||
// Bounds for smallest/largest possible scale to apply to content
|
||||
minScale: 0.2,
|
||||
maxScale: 1.0
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- begin footer logo
|
||||
<div style="position: absolute; bottom: 0px; left: 0; margin-left: 0px">
|
||||
<img src="somelogo.png">
|
||||
</div>
|
||||
end footer logo -->
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,794 +0,0 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
(https://github.com/hplgit/doconce/)
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="generator" content="DocOnce: https://github.com/hplgit/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Convolutional Neural Networks">
|
||||
|
||||
<title>Convolutional Neural Networks</title>
|
||||
|
||||
|
||||
<link href="https://cdn.rawgit.com/hplgit/doconce/master/bundled/html_styles/style_solarized_box/css/solarized_light_code.css" rel="stylesheet" type="text/css" title="light"/>
|
||||
<script src="https://cdn.rawgit.com/hplgit/doconce/master/bundled/html_styles/style_solarized_box/js/highlight.pack.js"></script>
|
||||
<script>hljs.initHighlightingOnLoad();</script>
|
||||
|
||||
<link href="https://thomasf.github.io/solarized-css/solarized-light.min.css" rel="stylesheet">
|
||||
<style type="text/css">
|
||||
h1 {color: #b58900;} /* yellow */
|
||||
/* h1 {color: #cb4b16;} orange */
|
||||
/* h1 {color: #d33682;} magenta, the original choice of thomasf */
|
||||
code { padding: 0px; background-color: inherit; }
|
||||
pre {
|
||||
border: 0pt solid #93a1a1;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
div { text-align: justify; text-justify: inter-word; }
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
{'highest level': 2,
|
||||
'sections': [('Convolutional Neural Networks (recognizing images)',
|
||||
2,
|
||||
None,
|
||||
'___sec0'),
|
||||
('Regular NNs don’t scale well to full images',
|
||||
2,
|
||||
None,
|
||||
'___sec1'),
|
||||
('3D volumes of neurons', 2, None, '___sec2'),
|
||||
('Layers used to build CNNs', 2, None, '___sec3'),
|
||||
('Transforming images', 2, None, '___sec4'),
|
||||
('CNNs in brief', 2, None, '___sec5'),
|
||||
('CNNs in more detail, building convolutional neural networks in '
|
||||
'Tensorflow and Keras',
|
||||
2,
|
||||
None,
|
||||
'___sec6'),
|
||||
('Setting it up', 2, None, '___sec7'),
|
||||
('The MNIST dataset again', 2, None, '___sec8'),
|
||||
('Strong correlations', 2, None, '___sec9'),
|
||||
('Layers of a CNN', 2, None, '___sec10'),
|
||||
('Systematic reduction', 2, None, '___sec11'),
|
||||
('Prerequisites: Collect and pre-process data',
|
||||
2,
|
||||
None,
|
||||
'___sec12'),
|
||||
('Importing Keras and Tensorflow', 2, None, '___sec13'),
|
||||
('Using TensorFlow backend', 2, None, '___sec14'),
|
||||
('Train the model', 2, None, '___sec15'),
|
||||
('Visualizing the results', 2, None, '___sec16'),
|
||||
('Running with Keras', 2, None, '___sec17'),
|
||||
('Final part', 2, None, '___sec18'),
|
||||
('Final visualization', 2, None, '___sec19'),
|
||||
('Fun links', 2, None, '___sec20')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
|
||||
|
||||
|
||||
<script type="text/x-mathjax-config">
|
||||
MathJax.Hub.Config({
|
||||
TeX: {
|
||||
equationNumbers: { autoNumber: "AMS" },
|
||||
extensions: ["AMSmath.js", "AMSsymbols.js", "autobold.js", "color.js"]
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<script type="text/javascript" async
|
||||
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- ------------------- main content ---------------------- -->
|
||||
|
||||
|
||||
|
||||
<center><h1>Convolutional Neural Networks</h1></center> <!-- document title -->
|
||||
|
||||
<p>
|
||||
<!-- author(s): Morten Hjorth-Jensen -->
|
||||
|
||||
<center>
|
||||
<b>Morten Hjorth-Jensen</b> [1, 2]
|
||||
</center>
|
||||
|
||||
<p>
|
||||
<!-- institution(s) -->
|
||||
|
||||
<center>[1] <b>Department of Physics, University of Oslo</b></center>
|
||||
<center>[2] <b>Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University</b></center>
|
||||
<br>
|
||||
<p>
|
||||
<center><h4>Oct 3, 2019</h4></center> <!-- date -->
|
||||
<br>
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec0">Convolutional Neural Networks (recognizing images) </h2>
|
||||
|
||||
<p>
|
||||
Convolutional Neural Networks (CNN) are very similar to ordinary Neural Networks.
|
||||
|
||||
<p>
|
||||
They are made up of neurons that have learnable weights and
|
||||
biases. Each neuron receives some inputs, performs a dot product and
|
||||
optionally follows it with a non-linearity. The whole network still
|
||||
expresses a single differentiable score function: from the raw image
|
||||
pixels on one end to class scores at the other. And they still have a
|
||||
loss function (for example Softmax) on the last (fully-connected) layer
|
||||
and all the tips/tricks we developed for learning regular Neural
|
||||
Networks still apply (back propagation, gradient descent etc etc).
|
||||
|
||||
<p>
|
||||
What is the difference? <b>CNN architectures make the explicit assumption that
|
||||
the inputs are images, which allows us to encode certain properties
|
||||
into the architecture. These then make the forward function more
|
||||
efficient to implement and vastly reduce the amount of parameters in
|
||||
the network.</b>
|
||||
|
||||
<p>
|
||||
Here we provide only a superficial overview, for the more interested, we recommend highly the course
|
||||
<a href="https://www.uio.no/studier/emner/matnat/ifi/IN5400/index-eng.html" target="_blank">IN5400 – Machine Learning for Image Analysis</a>
|
||||
and the slides of <a href="http://cs231n.github.io/convolutional-networks/" target="_blank">CS231</a>.
|
||||
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec1">Regular NNs don’t scale well to full images </h2>
|
||||
|
||||
<p>
|
||||
As an example, consider
|
||||
an image of size \( 32\times 32\times 3 \) (32 wide, 32 high, 3 color channels), so a
|
||||
single fully-connected neuron in a first hidden layer of a regular
|
||||
Neural Network would have \( 32\times 32\times 3 = 3072 \) weights. This amount still
|
||||
seems manageable, but clearly this fully-connected structure does not
|
||||
scale to larger images. For example, an image of more respectable
|
||||
size, say \( 200\times 200\times 3 \), would lead to neurons that have
|
||||
\( 200\times 200\times 3 = 120,000 \) weights.
|
||||
|
||||
<p>
|
||||
We could have
|
||||
several such neurons, and the parameters would add up quickly! Clearly,
|
||||
this full connectivity is wasteful and the huge number of parameters
|
||||
would quickly lead to possible overfitting.
|
||||
|
||||
<p>
|
||||
<center> <!-- FIGURE -->
|
||||
<hr class="figure">
|
||||
<center><p class="caption">Figure 1: A regular 3-layer Neural Network. </p></center>
|
||||
<p><img src="figslides/nn.jpeg" align="bottom" width=500></p>
|
||||
</center>
|
||||
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec2">3D volumes of neurons </h2>
|
||||
|
||||
<p>
|
||||
Convolutional Neural Networks take advantage of the fact that the
|
||||
input consists of images and they constrain the architecture in a more
|
||||
sensible way.
|
||||
|
||||
<p>
|
||||
In particular, unlike a regular Neural Network, the
|
||||
layers of a CNN have neurons arranged in 3 dimensions: width,
|
||||
height, depth. (Note that the word depth here refers to the third
|
||||
dimension of an activation volume, not to the depth of a full Neural
|
||||
Network, which can refer to the total number of layers in a network.)
|
||||
|
||||
<p>
|
||||
To understand it better, the above example of an image
|
||||
with an input volume of
|
||||
activations has dimensions \( 32\times 32\times 3 \) (width, height,
|
||||
depth respectively).
|
||||
|
||||
<p>
|
||||
The neurons in a layer will
|
||||
only be connected to a small region of the layer before it, instead of
|
||||
all of the neurons in a fully-connected manner. Moreover, the final
|
||||
output layer could for this specific image have dimensions \( 1\times 1 \times 10 \),
|
||||
because by the
|
||||
end of the CNN architecture we will reduce the full image into a
|
||||
single vector of class scores, arranged along the depth
|
||||
dimension.
|
||||
|
||||
<p>
|
||||
<center> <!-- FIGURE -->
|
||||
<hr class="figure">
|
||||
<center><p class="caption">Figure 2: A CNN arranges its neurons in three dimensions (width, height, depth), as visualized in one of the layers. Every layer of a CNN transforms the 3D input volume to a 3D output volume of neuron activations. In this example, the red input layer holds the image, so its width and height would be the dimensions of the image, and the depth would be 3 (Red, Green, Blue channels). </p></center>
|
||||
<p><img src="figslides/cnn.jpeg" align="bottom" width=500></p>
|
||||
</center>
|
||||
|
||||
<p>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="___sec3">Layers used to build CNNs </h2>
|
||||
|
||||
<p>
|
||||
A simple CNN is a sequence of layers, and every layer of a CNN
|
||||
transforms one volume of activations to another through a
|
||||
differentiable function. We use three main types of layers to build
|
||||
CNN architectures: Convolutional Layer, Pooling Layer, and
|
||||
Fully-Connected Layer (exactly as seen in regular Neural Networks). We
|
||||
will stack these layers to form a full CNN architecture.
|
||||
|
||||
<p>
|
||||
A simple CNN for image classification could have the architecture:
|
||||
|
||||
<ul>
|
||||
<li> <b>INPUT</b> (\( 32\times 32 \times 3 \)) will hold the raw pixel values of the image, in this case an image of width 32, height 32, and with three color channels R,G,B.</li>
|
||||
<li> <b>CONV</b> (convolutional )layer will compute the output of neurons that are connected to local regions in the input, each computing a dot product between their weights and a small region they are connected to in the input volume. This may result in volume such as \( [32\times 32\times 12] \) if we decided to use 12 filters.</li>
|
||||
<li> <b>RELU</b> layer will apply an elementwise activation function, such as the \( max(0,x) \) thresholding at zero. This leaves the size of the volume unchanged (\( [32\times 32\times 12] \)).</li>
|
||||
<li> <b>POOL</b> (pooling) layer will perform a downsampling operation along the spatial dimensions (width, height), resulting in volume such as \( [16\times 16\times 12] \).</li>
|
||||
<li> <b>FC</b> (i.e. fully-connected) layer will compute the class scores, resulting in volume of size \( [1\times 1\times 10] \), where each of the 10 numbers correspond to a class score, such as among the 10 categories of the MNIST images we considered above . As with ordinary Neural Networks and as the name implies, each neuron in this layer will be connected to all the numbers in the previous volume.</li>
|
||||
</ul>
|
||||
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec4">Transforming images </h2>
|
||||
|
||||
<p>
|
||||
CNNs transform the original image layer by layer from the original
|
||||
pixel values to the final class scores.
|
||||
|
||||
<p>
|
||||
Observe that some layers contain
|
||||
parameters and other don’t. In particular, the CNN layers perform
|
||||
transformations that are a function of not only the activations in the
|
||||
input volume, but also of the parameters (the weights and biases of
|
||||
the neurons). On the other hand, the RELU/POOL layers will implement a
|
||||
fixed function. The parameters in the CONV/FC layers will be trained
|
||||
with gradient descent so that the class scores that the CNN computes
|
||||
are consistent with the labels in the training set for each image.
|
||||
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec5">CNNs in brief </h2>
|
||||
|
||||
<p>
|
||||
In summary:
|
||||
|
||||
<ul>
|
||||
<li> A CNN architecture is in the simplest case a list of Layers that transform the image volume into an output volume (e.g. holding the class scores)</li>
|
||||
<li> There are a few distinct types of Layers (e.g. CONV/FC/RELU/POOL are by far the most popular)</li>
|
||||
<li> Each Layer accepts an input 3D volume and transforms it to an output 3D volume through a differentiable function</li>
|
||||
<li> Each Layer may or may not have parameters (e.g. CONV/FC do, RELU/POOL don’t)</li>
|
||||
<li> Each Layer may or may not have additional hyperparameters (e.g. CONV/FC/POOL do, RELU doesn’t)</li>
|
||||
</ul>
|
||||
|
||||
For more material on convolutional networks, we strongly recommend
|
||||
the course
|
||||
<a href="https://www.uio.no/studier/emner/matnat/ifi/IN5400/index-eng.html" target="_blank">IN5400 – Machine Learning for Image Analysis</a>
|
||||
and the slides of <a href="http://cs231n.github.io/convolutional-networks/" target="_blank">CS231</a> which is taught at Stanford University (consistently ranked as one of the top computer science programs in the world). <a href="http://neuralnetworksanddeeplearning.com/chap6.html" target="_blank">Michael Nielsen's book is a must read, in particular chapter 6 which deals with CNNs</a>.
|
||||
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec6">CNNs in more detail, building convolutional neural networks in Tensorflow and Keras </h2>
|
||||
|
||||
<p>
|
||||
As discussed above, CNNs are neural networks built from the assumption that the inputs
|
||||
to the network are 2D images. This is important because the number of features or pixels in images
|
||||
grows very fast with the image size, and an enormous number of weights and biases are needed in order to build an accurate network.
|
||||
|
||||
<p>
|
||||
As before, we still have our input, a hidden layer and an output. What's novel about convolutional networks
|
||||
are the <b>convolutional</b> and <b>pooling</b> layers stacked in pairs between the input and the hidden layer.
|
||||
In addition, the data is no longer represented as a 2D feature matrix, instead each input is a number of 2D
|
||||
matrices, typically 1 for each color dimension (Red, Green, Blue).
|
||||
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec7">Setting it up </h2>
|
||||
|
||||
<p>
|
||||
It means that to represent the entire
|
||||
dataset of images, we require a 4D matrix or <b>tensor</b>. This tensor has the dimensions:
|
||||
$$
|
||||
(n_{inputs},\, n_{pixels, width},\, n_{pixels, height},\, depth) .
|
||||
$$
|
||||
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec8">The MNIST dataset again </h2>
|
||||
|
||||
<p>
|
||||
The MNIST dataset consists of grayscale images with a pixel size of
|
||||
\( 28\times 28 \), meaning we require \( 28 \times 28 = 724 \) weights to each
|
||||
neuron in the first hidden layer.
|
||||
|
||||
<p>
|
||||
If we were to analyze images of size \( 128\times 128 \) we would require
|
||||
\( 128 \times 128 = 16384 \) weights to each neuron. Even worse if we were
|
||||
dealing with color images, as most images are, we have an image matrix
|
||||
of size \( 128\times 128 \) for each color dimension (Red, Green, Blue),
|
||||
meaning 3 times the number of weights \( = 49152 \) are required for every
|
||||
single neuron in the first hidden layer.
|
||||
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec9">Strong correlations </h2>
|
||||
Images typically have strong local correlations, meaning that a small
|
||||
part of the image varies little from its neighboring regions. If for
|
||||
example we have an image of a blue car, we can roughly assume that a
|
||||
small blue part of the image is surrounded by other blue regions.
|
||||
|
||||
<p>
|
||||
Therefore, instead of connecting every single pixel to a neuron in the
|
||||
first hidden layer, as we have previously done with deep neural
|
||||
networks, we can instead connect each neuron to a small part of the
|
||||
image (in all 3 RGB depth dimensions). The size of each small area is
|
||||
fixed, and known as a <a href="https://en.wikipedia.org/wiki/Receptive_field" target="_blank">receptive</a>.
|
||||
|
||||
<p>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="___sec10">Layers of a CNN </h2>
|
||||
The layers of a convolutional neural network arrange neurons in 3D: width, height and depth.
|
||||
The input image is typically a square matrix of depth 3.
|
||||
|
||||
<p>
|
||||
A <b>convolution</b> is performed on the image which outputs
|
||||
a 3D volume of neurons. The weights to the input are arranged in a number of 2D matrices, known as <b>filters</b>.
|
||||
|
||||
<p>
|
||||
Each filter slides along the input image, taking the dot product
|
||||
between each small part of the image and the filter, in all depth
|
||||
dimensions. This is then passed through a non-linear function,
|
||||
typically the <b>Rectified Linear (ReLu)</b> function, which serves as the
|
||||
activation of the neurons in the first convolutional layer. This is
|
||||
further passed through a <b>pooling layer</b>, which reduces the size of the
|
||||
convolutional layer, e.g. by taking the maximum or average across some
|
||||
small regions, and this serves as input to the next convolutional
|
||||
layer.
|
||||
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec11">Systematic reduction </h2>
|
||||
|
||||
<p>
|
||||
By systematically reducing the size of the input volume, through
|
||||
convolution and pooling, the network should create representations of
|
||||
small parts of the input, and then from them assemble representations
|
||||
of larger areas. The final pooling layer is flattened to serve as
|
||||
input to a hidden layer, such that each neuron in the final pooling
|
||||
layer is connected to every single neuron in the hidden layer. This
|
||||
then serves as input to the output layer, e.g. a softmax output for
|
||||
classification.
|
||||
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec12">Prerequisites: Collect and pre-process data </h2>
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
|
||||
<div class="highlight" style="background: #eeeedd"><pre style="line-height: 125%"><span></span><span style="color: #228B22"># import necessary packages</span>
|
||||
<span style="color: #8B008B; font-weight: bold">import</span> <span style="color: #008b45; text-decoration: underline">numpy</span> <span style="color: #8B008B; font-weight: bold">as</span> <span style="color: #008b45; text-decoration: underline">np</span>
|
||||
<span style="color: #8B008B; font-weight: bold">import</span> <span style="color: #008b45; text-decoration: underline">matplotlib.pyplot</span> <span style="color: #8B008B; font-weight: bold">as</span> <span style="color: #008b45; text-decoration: underline">plt</span>
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn</span> <span style="color: #8B008B; font-weight: bold">import</span> datasets
|
||||
|
||||
|
||||
<span style="color: #228B22"># ensure the same random numbers appear every time</span>
|
||||
np.random.seed(<span style="color: #B452CD">0</span>)
|
||||
|
||||
<span style="color: #228B22"># display images in notebook</span>
|
||||
%matplotlib inline
|
||||
plt.rcParams[<span style="color: #CD5555">'figure.figsize'</span>] = (<span style="color: #B452CD">12</span>,<span style="color: #B452CD">12</span>)
|
||||
|
||||
|
||||
<span style="color: #228B22"># download MNIST dataset</span>
|
||||
digits = datasets.load_digits()
|
||||
|
||||
<span style="color: #228B22"># define inputs and labels</span>
|
||||
inputs = digits.images
|
||||
labels = digits.target
|
||||
|
||||
<span style="color: #228B22"># RGB images have a depth of 3</span>
|
||||
<span style="color: #228B22"># our images are grayscale so they should have a depth of 1</span>
|
||||
inputs = inputs[:,:,:,np.newaxis]
|
||||
|
||||
<span style="color: #8B008B; font-weight: bold">print</span>(<span style="color: #CD5555">"inputs = (n_inputs, pixel_width, pixel_height, depth) = "</span> + <span style="color: #658b00">str</span>(inputs.shape))
|
||||
<span style="color: #8B008B; font-weight: bold">print</span>(<span style="color: #CD5555">"labels = (n_inputs) = "</span> + <span style="color: #658b00">str</span>(labels.shape))
|
||||
|
||||
|
||||
<span style="color: #228B22"># choose some random images to display</span>
|
||||
n_inputs = <span style="color: #658b00">len</span>(inputs)
|
||||
indices = np.arange(n_inputs)
|
||||
random_indices = np.random.choice(indices, size=<span style="color: #B452CD">5</span>)
|
||||
|
||||
<span style="color: #8B008B; font-weight: bold">for</span> i, image <span style="color: #8B008B">in</span> <span style="color: #658b00">enumerate</span>(digits.images[random_indices]):
|
||||
plt.subplot(<span style="color: #B452CD">1</span>, <span style="color: #B452CD">5</span>, i+<span style="color: #B452CD">1</span>)
|
||||
plt.axis(<span style="color: #CD5555">'off'</span>)
|
||||
plt.imshow(image, cmap=plt.cm.gray_r, interpolation=<span style="color: #CD5555">'nearest'</span>)
|
||||
plt.title(<span style="color: #CD5555">"Label: %d"</span> % digits.target[random_indices[i]])
|
||||
plt.show()
|
||||
</pre></div>
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec13">Importing Keras and Tensorflow </h2>
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
|
||||
<div class="highlight" style="background: #eeeedd"><pre style="line-height: 125%"><span></span><span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">keras.utils</span> <span style="color: #8B008B; font-weight: bold">import</span> to_categorical
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.model_selection</span> <span style="color: #8B008B; font-weight: bold">import</span> train_test_split
|
||||
|
||||
<span style="color: #228B22"># representation of labels</span>
|
||||
labels = to_categorical(labels)
|
||||
|
||||
<span style="color: #228B22"># split into train and test data</span>
|
||||
<span style="color: #228B22"># one-liner from scikit-learn library</span>
|
||||
train_size = <span style="color: #B452CD">0.8</span>
|
||||
test_size = <span style="color: #B452CD">1</span> - train_size
|
||||
X_train, X_test, Y_train, Y_test = train_test_split(inputs, labels, train_size=train_size,
|
||||
test_size=test_size)
|
||||
</pre></div>
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec14">Using TensorFlow backend </h2>
|
||||
|
||||
<p>
|
||||
We need to define model and architecture and choose cost function and optmizer.
|
||||
<p>
|
||||
|
||||
<!-- code=text (!bc pycid) typeset with pygments style "perldoc" -->
|
||||
<div class="highlight" style="background: #eeeedd"><pre style="line-height: 125%"><span></span>import tensorflow as tf
|
||||
|
||||
class ConvolutionalNeuralNetworkTensorflow:
|
||||
def __init__(
|
||||
self,
|
||||
X_train,
|
||||
Y_train,
|
||||
X_test,
|
||||
Y_test,
|
||||
n_filters=10,
|
||||
n_neurons_connected=50,
|
||||
n_categories=10,
|
||||
receptive_field=3,
|
||||
stride=1,
|
||||
padding=1,
|
||||
epochs=10,
|
||||
batch_size=100,
|
||||
eta=0.1,
|
||||
lmbd=0.0):
|
||||
|
||||
self.global_step = tf.Variable(0, dtype=tf.int32, trainable=False, name='global_step')
|
||||
|
||||
self.X_train = X_train
|
||||
self.Y_train = Y_train
|
||||
self.X_test = X_test
|
||||
self.Y_test = Y_test
|
||||
|
||||
self.n_inputs, self.input_width, self.input_height, self.depth = X_train.shape
|
||||
|
||||
self.n_filters = n_filters
|
||||
self.n_downsampled = int(self.input_width*self.input_height*n_filters / 4)
|
||||
self.n_neurons_connected = n_neurons_connected
|
||||
self.n_categories = n_categories
|
||||
|
||||
self.receptive_field = receptive_field
|
||||
self.stride = stride
|
||||
self.strides = [stride, stride, stride, stride]
|
||||
self.padding = padding
|
||||
|
||||
self.epochs = epochs
|
||||
self.batch_size = batch_size
|
||||
self.iterations = self.n_inputs // self.batch_size
|
||||
self.eta = eta
|
||||
self.lmbd = lmbd
|
||||
|
||||
self.create_placeholders()
|
||||
self.create_CNN()
|
||||
self.create_loss()
|
||||
self.create_optimiser()
|
||||
self.create_accuracy()
|
||||
|
||||
def create_placeholders(self):
|
||||
with tf.name_scope('data'):
|
||||
self.X = tf.placeholder(tf.float32, shape=(None, self.input_width, self.input_height, self.depth), name='X_data')
|
||||
self.Y = tf.placeholder(tf.float32, shape=(None, self.n_categories), name='Y_data')
|
||||
|
||||
def create_CNN(self):
|
||||
with tf.name_scope('CNN'):
|
||||
|
||||
# Convolutional layer
|
||||
self.W_conv = self.weight_variable([self.receptive_field, self.receptive_field, self.depth, self.n_filters], name='conv', dtype=tf.float32)
|
||||
b_conv = self.weight_variable([self.n_filters], name='conv', dtype=tf.float32)
|
||||
z_conv = tf.nn.conv2d(self.X, self.W_conv, self.strides, padding='SAME', name='conv') + b_conv
|
||||
a_conv = tf.nn.relu(z_conv)
|
||||
|
||||
# 2x2 max pooling
|
||||
a_pool = tf.nn.max_pool(a_conv, [1, 2, 2, 1], [1, 2, 2, 1], padding='SAME', name='pool')
|
||||
|
||||
# Fully connected layer
|
||||
a_pool_flat = tf.reshape(a_pool, [-1, self.n_downsampled])
|
||||
self.W_fc = self.weight_variable([self.n_downsampled, self.n_neurons_connected], name='fc', dtype=tf.float32)
|
||||
b_fc = self.bias_variable([self.n_neurons_connected], name='fc', dtype=tf.float32)
|
||||
a_fc = tf.nn.relu(tf.matmul(a_pool_flat, self.W_fc) + b_fc)
|
||||
|
||||
# Output layer
|
||||
self.W_out = self.weight_variable([self.n_neurons_connected, self.n_categories], name='out', dtype=tf.float32)
|
||||
b_out = self.bias_variable([self.n_categories], name='out', dtype=tf.float32)
|
||||
self.z_out = tf.matmul(a_fc, self.W_out) + b_out
|
||||
|
||||
def create_loss(self):
|
||||
with tf.name_scope('loss'):
|
||||
softmax_loss = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits_v2(labels=self.Y, logits=self.z_out))
|
||||
|
||||
regularizer_loss_conv = tf.nn.l2_loss(self.W_conv)
|
||||
regularizer_loss_fc = tf.nn.l2_loss(self.W_fc)
|
||||
regularizer_loss_out = tf.nn.l2_loss(self.W_out)
|
||||
regularizer_loss = self.lmbd*(regularizer_loss_conv + regularizer_loss_fc + regularizer_loss_out)
|
||||
|
||||
self.loss = softmax_loss + regularizer_loss
|
||||
|
||||
def create_accuracy(self):
|
||||
with tf.name_scope('accuracy'):
|
||||
probabilities = tf.nn.softmax(self.z_out)
|
||||
predictions = tf.argmax(probabilities, 1)
|
||||
labels = tf.argmax(self.Y, 1)
|
||||
|
||||
correct_predictions = tf.equal(predictions, labels)
|
||||
correct_predictions = tf.cast(correct_predictions, tf.float32)
|
||||
self.accuracy = tf.reduce_mean(correct_predictions)
|
||||
|
||||
def create_optimiser(self):
|
||||
with tf.name_scope('optimizer'):
|
||||
self.optimizer = tf.train.GradientDescentOptimizer(learning_rate=self.eta).minimize(self.loss, global_step=self.global_step)
|
||||
|
||||
def weight_variable(self, shape, name='', dtype=tf.float32):
|
||||
initial = tf.truncated_normal(shape, stddev=0.1)
|
||||
return tf.Variable(initial, name=name, dtype=dtype)
|
||||
|
||||
def bias_variable(self, shape, name='', dtype=tf.float32):
|
||||
initial = tf.constant(0.1, shape=shape)
|
||||
return tf.Variable(initial, name=name, dtype=dtype)
|
||||
|
||||
def fit(self):
|
||||
data_indices = np.arange(self.n_inputs)
|
||||
|
||||
with tf.Session() as sess:
|
||||
sess.run(tf.global_variables_initializer())
|
||||
for i in range(self.epochs):
|
||||
for j in range(self.iterations):
|
||||
chosen_datapoints = np.random.choice(data_indices, size=self.batch_size, replace=False)
|
||||
batch_X, batch_Y = self.X_train[chosen_datapoints], self.Y_train[chosen_datapoints]
|
||||
|
||||
sess.run([CNN.loss, CNN.optimizer],
|
||||
feed_dict={CNN.X: batch_X,
|
||||
CNN.Y: batch_Y})
|
||||
accuracy = sess.run(CNN.accuracy,
|
||||
feed_dict={CNN.X: batch_X,
|
||||
CNN.Y: batch_Y})
|
||||
step = sess.run(CNN.global_step)
|
||||
|
||||
self.train_loss, self.train_accuracy = sess.run([CNN.loss, CNN.accuracy],
|
||||
feed_dict={CNN.X: self.X_train,
|
||||
CNN.Y: self.Y_train})
|
||||
|
||||
self.test_loss, self.test_accuracy = sess.run([CNN.loss, CNN.accuracy],
|
||||
feed_dict={CNN.X: self.X_test,
|
||||
CNN.Y: self.Y_test})
|
||||
</pre></div>
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec15">Train the model </h2>
|
||||
|
||||
<p>
|
||||
We need now to train the model, evaluate it and test its performance on test data, and eventually include hyperparameters.
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
|
||||
<div class="highlight" style="background: #eeeedd"><pre style="line-height: 125%"><span></span>epochs = <span style="color: #B452CD">100</span>
|
||||
batch_size = <span style="color: #B452CD">100</span>
|
||||
n_filters = <span style="color: #B452CD">10</span>
|
||||
n_neurons_connected = <span style="color: #B452CD">50</span>
|
||||
n_categories = <span style="color: #B452CD">10</span>
|
||||
|
||||
eta_vals = np.logspace(-<span style="color: #B452CD">5</span>, <span style="color: #B452CD">1</span>, <span style="color: #B452CD">7</span>)
|
||||
lmbd_vals = np.logspace(-<span style="color: #B452CD">5</span>, <span style="color: #B452CD">1</span>, <span style="color: #B452CD">7</span>)
|
||||
CNN_tf = np.zeros((<span style="color: #658b00">len</span>(eta_vals), <span style="color: #658b00">len</span>(lmbd_vals)), dtype=<span style="color: #658b00">object</span>)
|
||||
|
||||
<span style="color: #8B008B; font-weight: bold">for</span> i, eta <span style="color: #8B008B">in</span> <span style="color: #658b00">enumerate</span>(eta_vals):
|
||||
<span style="color: #8B008B; font-weight: bold">for</span> j, lmbd <span style="color: #8B008B">in</span> <span style="color: #658b00">enumerate</span>(lmbd_vals):
|
||||
CNN = ConvolutionalNeuralNetworkTensorflow(X_train, Y_train, X_test, Y_test,
|
||||
n_filters=n_filters, n_neurons_connected=n_neurons_connected,
|
||||
n_categories=n_categories, epochs=epochs, batch_size=batch_size,
|
||||
eta=eta, lmbd=lmbd)
|
||||
CNN.fit()
|
||||
|
||||
<span style="color: #8B008B; font-weight: bold">print</span>(<span style="color: #CD5555">"Learning rate = "</span>, eta)
|
||||
<span style="color: #8B008B; font-weight: bold">print</span>(<span style="color: #CD5555">"Lambda = "</span>, lmbd)
|
||||
<span style="color: #8B008B; font-weight: bold">print</span>(<span style="color: #CD5555">"Test accuracy: %.3f"</span> % CNN.test_accuracy)
|
||||
<span style="color: #8B008B; font-weight: bold">print</span>()
|
||||
|
||||
CNN_tf[i][j] = CNN
|
||||
</pre></div>
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec16">Visualizing the results </h2>
|
||||
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
|
||||
<div class="highlight" style="background: #eeeedd"><pre style="line-height: 125%"><span></span><span style="color: #228B22"># visual representation of grid search</span>
|
||||
<span style="color: #228B22"># uses seaborn heatmap, could probably do this in matplotlib</span>
|
||||
<span style="color: #8B008B; font-weight: bold">import</span> <span style="color: #008b45; text-decoration: underline">seaborn</span> <span style="color: #8B008B; font-weight: bold">as</span> <span style="color: #008b45; text-decoration: underline">sns</span>
|
||||
|
||||
sns.set()
|
||||
|
||||
train_accuracy = np.zeros((<span style="color: #658b00">len</span>(eta_vals), <span style="color: #658b00">len</span>(lmbd_vals)))
|
||||
test_accuracy = np.zeros((<span style="color: #658b00">len</span>(eta_vals), <span style="color: #658b00">len</span>(lmbd_vals)))
|
||||
|
||||
<span style="color: #8B008B; font-weight: bold">for</span> i <span style="color: #8B008B">in</span> <span style="color: #658b00">range</span>(<span style="color: #658b00">len</span>(eta_vals)):
|
||||
<span style="color: #8B008B; font-weight: bold">for</span> j <span style="color: #8B008B">in</span> <span style="color: #658b00">range</span>(<span style="color: #658b00">len</span>(lmbd_vals)):
|
||||
CNN = CNN_tf[i][j]
|
||||
|
||||
train_accuracy[i][j] = CNN.train_accuracy
|
||||
test_accuracy[i][j] = CNN.test_accuracy
|
||||
|
||||
|
||||
fig, ax = plt.subplots(figsize = (<span style="color: #B452CD">10</span>, <span style="color: #B452CD">10</span>))
|
||||
sns.heatmap(train_accuracy, annot=<span style="color: #658b00">True</span>, ax=ax, cmap=<span style="color: #CD5555">"viridis"</span>)
|
||||
ax.set_title(<span style="color: #CD5555">"Training Accuracy"</span>)
|
||||
ax.set_ylabel(<span style="color: #CD5555">"$\eta$"</span>)
|
||||
ax.set_xlabel(<span style="color: #CD5555">"$\lambda$"</span>)
|
||||
plt.show()
|
||||
|
||||
fig, ax = plt.subplots(figsize = (<span style="color: #B452CD">10</span>, <span style="color: #B452CD">10</span>))
|
||||
sns.heatmap(test_accuracy, annot=<span style="color: #658b00">True</span>, ax=ax, cmap=<span style="color: #CD5555">"viridis"</span>)
|
||||
ax.set_title(<span style="color: #CD5555">"Test Accuracy"</span>)
|
||||
ax.set_ylabel(<span style="color: #CD5555">"$\eta$"</span>)
|
||||
ax.set_xlabel(<span style="color: #CD5555">"$\lambda$"</span>)
|
||||
plt.show()
|
||||
</pre></div>
|
||||
<p>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="___sec17">Running with Keras </h2>
|
||||
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
|
||||
<div class="highlight" style="background: #eeeedd"><pre style="line-height: 125%"><span></span><span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">keras.models</span> <span style="color: #8B008B; font-weight: bold">import</span> Sequential
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">keras.layers.convolutional</span> <span style="color: #8B008B; font-weight: bold">import</span> Conv2D
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">keras.layers.convolutional</span> <span style="color: #8B008B; font-weight: bold">import</span> MaxPooling2D
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">keras.layers</span> <span style="color: #8B008B; font-weight: bold">import</span> Flatten
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">keras.layers</span> <span style="color: #8B008B; font-weight: bold">import</span> Dense
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">keras.regularizers</span> <span style="color: #8B008B; font-weight: bold">import</span> l2
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">keras.optimizers</span> <span style="color: #8B008B; font-weight: bold">import</span> SGD
|
||||
|
||||
<span style="color: #8B008B; font-weight: bold">def</span> <span style="color: #008b45">create_convolutional_neural_network_keras</span>(input_shape, receptive_field,
|
||||
n_filters, n_neurons_connected, n_categories,
|
||||
eta, lmbd):
|
||||
model = Sequential()
|
||||
model.add(Conv2D(n_filters, (receptive_field, receptive_field), input_shape=input_shape, padding=<span style="color: #CD5555">'same'</span>,
|
||||
activation=<span style="color: #CD5555">'relu'</span>, kernel_regularizer=l2(lmbd)))
|
||||
model.add(MaxPooling2D(pool_size=(<span style="color: #B452CD">2</span>, <span style="color: #B452CD">2</span>)))
|
||||
model.add(Flatten())
|
||||
model.add(Dense(n_neurons_connected, activation=<span style="color: #CD5555">'relu'</span>, kernel_regularizer=l2(lmbd)))
|
||||
model.add(Dense(n_categories, activation=<span style="color: #CD5555">'softmax'</span>, kernel_regularizer=l2(lmbd)))
|
||||
|
||||
sgd = SGD(lr=eta)
|
||||
model.compile(loss=<span style="color: #CD5555">'categorical_crossentropy'</span>, optimizer=sgd, metrics=[<span style="color: #CD5555">'accuracy'</span>])
|
||||
|
||||
<span style="color: #8B008B; font-weight: bold">return</span> model
|
||||
|
||||
epochs = <span style="color: #B452CD">100</span>
|
||||
batch_size = <span style="color: #B452CD">100</span>
|
||||
input_shape = X_train.shape[<span style="color: #B452CD">1</span>:<span style="color: #B452CD">4</span>]
|
||||
receptive_field = <span style="color: #B452CD">3</span>
|
||||
n_filters = <span style="color: #B452CD">10</span>
|
||||
n_neurons_connected = <span style="color: #B452CD">50</span>
|
||||
n_categories = <span style="color: #B452CD">10</span>
|
||||
|
||||
eta_vals = np.logspace(-<span style="color: #B452CD">5</span>, <span style="color: #B452CD">1</span>, <span style="color: #B452CD">7</span>)
|
||||
lmbd_vals = np.logspace(-<span style="color: #B452CD">5</span>, <span style="color: #B452CD">1</span>, <span style="color: #B452CD">7</span>)
|
||||
</pre></div>
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec18">Final part </h2>
|
||||
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
|
||||
<div class="highlight" style="background: #eeeedd"><pre style="line-height: 125%"><span></span>CNN_keras = np.zeros((<span style="color: #658b00">len</span>(eta_vals), <span style="color: #658b00">len</span>(lmbd_vals)), dtype=<span style="color: #658b00">object</span>)
|
||||
|
||||
<span style="color: #8B008B; font-weight: bold">for</span> i, eta <span style="color: #8B008B">in</span> <span style="color: #658b00">enumerate</span>(eta_vals):
|
||||
<span style="color: #8B008B; font-weight: bold">for</span> j, lmbd <span style="color: #8B008B">in</span> <span style="color: #658b00">enumerate</span>(lmbd_vals):
|
||||
CNN = create_convolutional_neural_network_keras(input_shape, receptive_field,
|
||||
n_filters, n_neurons_connected, n_categories,
|
||||
eta, lmbd)
|
||||
CNN.fit(X_train, Y_train, epochs=epochs, batch_size=batch_size, verbose=<span style="color: #B452CD">0</span>)
|
||||
scores = CNN.evaluate(X_test, Y_test)
|
||||
|
||||
CNN_keras[i][j] = CNN
|
||||
|
||||
<span style="color: #8B008B; font-weight: bold">print</span>(<span style="color: #CD5555">"Learning rate = "</span>, eta)
|
||||
<span style="color: #8B008B; font-weight: bold">print</span>(<span style="color: #CD5555">"Lambda = "</span>, lmbd)
|
||||
<span style="color: #8B008B; font-weight: bold">print</span>(<span style="color: #CD5555">"Test accuracy: %.3f"</span> % scores[<span style="color: #B452CD">1</span>])
|
||||
<span style="color: #8B008B; font-weight: bold">print</span>()
|
||||
</pre></div>
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec19">Final visualization </h2>
|
||||
|
||||
<p>
|
||||
|
||||
<!-- code=text typeset with pygments style "perldoc" -->
|
||||
<div class="highlight" style="background: #eeeedd"><pre style="line-height: 125%"><span></span># visual representation of grid search
|
||||
# uses seaborn heatmap, could probably do this in matplotlib
|
||||
import seaborn as sns
|
||||
|
||||
sns.set()
|
||||
|
||||
train_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))
|
||||
test_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))
|
||||
|
||||
for i in range(len(eta_vals)):
|
||||
for j in range(len(lmbd_vals)):
|
||||
CNN = CNN_keras[i][j]
|
||||
|
||||
train_accuracy[i][j] = CNN.evaluate(X_train, Y_train)[1]
|
||||
test_accuracy[i][j] = CNN.evaluate(X_test, Y_test)[1]
|
||||
|
||||
|
||||
fig, ax = plt.subplots(figsize = (10, 10))
|
||||
sns.heatmap(train_accuracy, annot=True, ax=ax, cmap="viridis")
|
||||
ax.set_title("Training Accuracy")
|
||||
ax.set_ylabel("$\eta$")
|
||||
ax.set_xlabel("$\lambda$")
|
||||
plt.show()
|
||||
|
||||
fig, ax = plt.subplots(figsize = (10, 10))
|
||||
sns.heatmap(test_accuracy, annot=True, ax=ax, cmap="viridis")
|
||||
ax.set_title("Test Accuracy")
|
||||
ax.set_ylabel("$\eta$")
|
||||
ax.set_xlabel("$\lambda$")
|
||||
plt.show()
|
||||
</pre></div>
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec20">Fun links </h2>
|
||||
|
||||
<ol>
|
||||
<li> <a href="https://arxiv.org/abs/1604.07316" target="_blank">Self-Driving cars using a convolutional neural network</a></li>
|
||||
<li> <a href="https://deepdreamgenerator.com/" target="_blank">Abstract art using convolutional neural networks</a></li>
|
||||
</ol>
|
||||
|
||||
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright --> © 1999-2019, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
@@ -1,799 +0,0 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
(https://github.com/hplgit/doconce/)
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="generator" content="DocOnce: https://github.com/hplgit/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Convolutional Neural Networks">
|
||||
|
||||
<title>Convolutional Neural Networks</title>
|
||||
|
||||
|
||||
<style type="text/css">
|
||||
/* bloodish style */
|
||||
|
||||
body {
|
||||
font-family: Helvetica, Verdana, Arial, Sans-serif;
|
||||
color: #404040;
|
||||
background: #ffffff;
|
||||
}
|
||||
h1 { font-size: 1.8em; color: #8A0808; }
|
||||
h2 { font-size: 1.6em; color: #8A0808; }
|
||||
h3 { font-size: 1.4em; color: #8A0808; }
|
||||
h4 { color: #8A0808; }
|
||||
a { color: #8A0808; text-decoration:none; }
|
||||
tt { font-family: "Courier New", Courier; }
|
||||
/* pre style removed because it will interfer with pygments */
|
||||
p { text-indent: 0px; }
|
||||
hr { border: 0; width: 80%; border-bottom: 1px solid #aaa}
|
||||
p.caption { width: 80%; font-style: normal; text-align: left; }
|
||||
hr.figure { border: 0; width: 80%; border-bottom: 1px solid #aaa}
|
||||
|
||||
div { text-align: justify; text-justify: inter-word; }
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
{'highest level': 2,
|
||||
'sections': [('Convolutional Neural Networks (recognizing images)',
|
||||
2,
|
||||
None,
|
||||
'___sec0'),
|
||||
('Regular NNs don’t scale well to full images',
|
||||
2,
|
||||
None,
|
||||
'___sec1'),
|
||||
('3D volumes of neurons', 2, None, '___sec2'),
|
||||
('Layers used to build CNNs', 2, None, '___sec3'),
|
||||
('Transforming images', 2, None, '___sec4'),
|
||||
('CNNs in brief', 2, None, '___sec5'),
|
||||
('CNNs in more detail, building convolutional neural networks in '
|
||||
'Tensorflow and Keras',
|
||||
2,
|
||||
None,
|
||||
'___sec6'),
|
||||
('Setting it up', 2, None, '___sec7'),
|
||||
('The MNIST dataset again', 2, None, '___sec8'),
|
||||
('Strong correlations', 2, None, '___sec9'),
|
||||
('Layers of a CNN', 2, None, '___sec10'),
|
||||
('Systematic reduction', 2, None, '___sec11'),
|
||||
('Prerequisites: Collect and pre-process data',
|
||||
2,
|
||||
None,
|
||||
'___sec12'),
|
||||
('Importing Keras and Tensorflow', 2, None, '___sec13'),
|
||||
('Using TensorFlow backend', 2, None, '___sec14'),
|
||||
('Train the model', 2, None, '___sec15'),
|
||||
('Visualizing the results', 2, None, '___sec16'),
|
||||
('Running with Keras', 2, None, '___sec17'),
|
||||
('Final part', 2, None, '___sec18'),
|
||||
('Final visualization', 2, None, '___sec19'),
|
||||
('Fun links', 2, None, '___sec20')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
|
||||
|
||||
|
||||
<script type="text/x-mathjax-config">
|
||||
MathJax.Hub.Config({
|
||||
TeX: {
|
||||
equationNumbers: { autoNumber: "AMS" },
|
||||
extensions: ["AMSmath.js", "AMSsymbols.js", "autobold.js", "color.js"]
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<script type="text/javascript" async
|
||||
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- ------------------- main content ---------------------- -->
|
||||
|
||||
|
||||
|
||||
<center><h1>Convolutional Neural Networks</h1></center> <!-- document title -->
|
||||
|
||||
<p>
|
||||
<!-- author(s): Morten Hjorth-Jensen -->
|
||||
|
||||
<center>
|
||||
<b>Morten Hjorth-Jensen</b> [1, 2]
|
||||
</center>
|
||||
|
||||
<p>
|
||||
<!-- institution(s) -->
|
||||
|
||||
<center>[1] <b>Department of Physics, University of Oslo</b></center>
|
||||
<center>[2] <b>Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University</b></center>
|
||||
<br>
|
||||
<p>
|
||||
<center><h4>Oct 3, 2019</h4></center> <!-- date -->
|
||||
<br>
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec0">Convolutional Neural Networks (recognizing images) </h2>
|
||||
|
||||
<p>
|
||||
Convolutional Neural Networks (CNN) are very similar to ordinary Neural Networks.
|
||||
|
||||
<p>
|
||||
They are made up of neurons that have learnable weights and
|
||||
biases. Each neuron receives some inputs, performs a dot product and
|
||||
optionally follows it with a non-linearity. The whole network still
|
||||
expresses a single differentiable score function: from the raw image
|
||||
pixels on one end to class scores at the other. And they still have a
|
||||
loss function (for example Softmax) on the last (fully-connected) layer
|
||||
and all the tips/tricks we developed for learning regular Neural
|
||||
Networks still apply (back propagation, gradient descent etc etc).
|
||||
|
||||
<p>
|
||||
What is the difference? <b>CNN architectures make the explicit assumption that
|
||||
the inputs are images, which allows us to encode certain properties
|
||||
into the architecture. These then make the forward function more
|
||||
efficient to implement and vastly reduce the amount of parameters in
|
||||
the network.</b>
|
||||
|
||||
<p>
|
||||
Here we provide only a superficial overview, for the more interested, we recommend highly the course
|
||||
<a href="https://www.uio.no/studier/emner/matnat/ifi/IN5400/index-eng.html" target="_blank">IN5400 – Machine Learning for Image Analysis</a>
|
||||
and the slides of <a href="http://cs231n.github.io/convolutional-networks/" target="_blank">CS231</a>.
|
||||
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec1">Regular NNs don’t scale well to full images </h2>
|
||||
|
||||
<p>
|
||||
As an example, consider
|
||||
an image of size \( 32\times 32\times 3 \) (32 wide, 32 high, 3 color channels), so a
|
||||
single fully-connected neuron in a first hidden layer of a regular
|
||||
Neural Network would have \( 32\times 32\times 3 = 3072 \) weights. This amount still
|
||||
seems manageable, but clearly this fully-connected structure does not
|
||||
scale to larger images. For example, an image of more respectable
|
||||
size, say \( 200\times 200\times 3 \), would lead to neurons that have
|
||||
\( 200\times 200\times 3 = 120,000 \) weights.
|
||||
|
||||
<p>
|
||||
We could have
|
||||
several such neurons, and the parameters would add up quickly! Clearly,
|
||||
this full connectivity is wasteful and the huge number of parameters
|
||||
would quickly lead to possible overfitting.
|
||||
|
||||
<p>
|
||||
<center> <!-- FIGURE -->
|
||||
<hr class="figure">
|
||||
<center><p class="caption">Figure 1: A regular 3-layer Neural Network. </p></center>
|
||||
<p><img src="figslides/nn.jpeg" align="bottom" width=500></p>
|
||||
</center>
|
||||
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec2">3D volumes of neurons </h2>
|
||||
|
||||
<p>
|
||||
Convolutional Neural Networks take advantage of the fact that the
|
||||
input consists of images and they constrain the architecture in a more
|
||||
sensible way.
|
||||
|
||||
<p>
|
||||
In particular, unlike a regular Neural Network, the
|
||||
layers of a CNN have neurons arranged in 3 dimensions: width,
|
||||
height, depth. (Note that the word depth here refers to the third
|
||||
dimension of an activation volume, not to the depth of a full Neural
|
||||
Network, which can refer to the total number of layers in a network.)
|
||||
|
||||
<p>
|
||||
To understand it better, the above example of an image
|
||||
with an input volume of
|
||||
activations has dimensions \( 32\times 32\times 3 \) (width, height,
|
||||
depth respectively).
|
||||
|
||||
<p>
|
||||
The neurons in a layer will
|
||||
only be connected to a small region of the layer before it, instead of
|
||||
all of the neurons in a fully-connected manner. Moreover, the final
|
||||
output layer could for this specific image have dimensions \( 1\times 1 \times 10 \),
|
||||
because by the
|
||||
end of the CNN architecture we will reduce the full image into a
|
||||
single vector of class scores, arranged along the depth
|
||||
dimension.
|
||||
|
||||
<p>
|
||||
<center> <!-- FIGURE -->
|
||||
<hr class="figure">
|
||||
<center><p class="caption">Figure 2: A CNN arranges its neurons in three dimensions (width, height, depth), as visualized in one of the layers. Every layer of a CNN transforms the 3D input volume to a 3D output volume of neuron activations. In this example, the red input layer holds the image, so its width and height would be the dimensions of the image, and the depth would be 3 (Red, Green, Blue channels). </p></center>
|
||||
<p><img src="figslides/cnn.jpeg" align="bottom" width=500></p>
|
||||
</center>
|
||||
|
||||
<p>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="___sec3">Layers used to build CNNs </h2>
|
||||
|
||||
<p>
|
||||
A simple CNN is a sequence of layers, and every layer of a CNN
|
||||
transforms one volume of activations to another through a
|
||||
differentiable function. We use three main types of layers to build
|
||||
CNN architectures: Convolutional Layer, Pooling Layer, and
|
||||
Fully-Connected Layer (exactly as seen in regular Neural Networks). We
|
||||
will stack these layers to form a full CNN architecture.
|
||||
|
||||
<p>
|
||||
A simple CNN for image classification could have the architecture:
|
||||
|
||||
<ul>
|
||||
<li> <b>INPUT</b> (\( 32\times 32 \times 3 \)) will hold the raw pixel values of the image, in this case an image of width 32, height 32, and with three color channels R,G,B.</li>
|
||||
<li> <b>CONV</b> (convolutional )layer will compute the output of neurons that are connected to local regions in the input, each computing a dot product between their weights and a small region they are connected to in the input volume. This may result in volume such as \( [32\times 32\times 12] \) if we decided to use 12 filters.</li>
|
||||
<li> <b>RELU</b> layer will apply an elementwise activation function, such as the \( max(0,x) \) thresholding at zero. This leaves the size of the volume unchanged (\( [32\times 32\times 12] \)).</li>
|
||||
<li> <b>POOL</b> (pooling) layer will perform a downsampling operation along the spatial dimensions (width, height), resulting in volume such as \( [16\times 16\times 12] \).</li>
|
||||
<li> <b>FC</b> (i.e. fully-connected) layer will compute the class scores, resulting in volume of size \( [1\times 1\times 10] \), where each of the 10 numbers correspond to a class score, such as among the 10 categories of the MNIST images we considered above . As with ordinary Neural Networks and as the name implies, each neuron in this layer will be connected to all the numbers in the previous volume.</li>
|
||||
</ul>
|
||||
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec4">Transforming images </h2>
|
||||
|
||||
<p>
|
||||
CNNs transform the original image layer by layer from the original
|
||||
pixel values to the final class scores.
|
||||
|
||||
<p>
|
||||
Observe that some layers contain
|
||||
parameters and other don’t. In particular, the CNN layers perform
|
||||
transformations that are a function of not only the activations in the
|
||||
input volume, but also of the parameters (the weights and biases of
|
||||
the neurons). On the other hand, the RELU/POOL layers will implement a
|
||||
fixed function. The parameters in the CONV/FC layers will be trained
|
||||
with gradient descent so that the class scores that the CNN computes
|
||||
are consistent with the labels in the training set for each image.
|
||||
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec5">CNNs in brief </h2>
|
||||
|
||||
<p>
|
||||
In summary:
|
||||
|
||||
<ul>
|
||||
<li> A CNN architecture is in the simplest case a list of Layers that transform the image volume into an output volume (e.g. holding the class scores)</li>
|
||||
<li> There are a few distinct types of Layers (e.g. CONV/FC/RELU/POOL are by far the most popular)</li>
|
||||
<li> Each Layer accepts an input 3D volume and transforms it to an output 3D volume through a differentiable function</li>
|
||||
<li> Each Layer may or may not have parameters (e.g. CONV/FC do, RELU/POOL don’t)</li>
|
||||
<li> Each Layer may or may not have additional hyperparameters (e.g. CONV/FC/POOL do, RELU doesn’t)</li>
|
||||
</ul>
|
||||
|
||||
For more material on convolutional networks, we strongly recommend
|
||||
the course
|
||||
<a href="https://www.uio.no/studier/emner/matnat/ifi/IN5400/index-eng.html" target="_blank">IN5400 – Machine Learning for Image Analysis</a>
|
||||
and the slides of <a href="http://cs231n.github.io/convolutional-networks/" target="_blank">CS231</a> which is taught at Stanford University (consistently ranked as one of the top computer science programs in the world). <a href="http://neuralnetworksanddeeplearning.com/chap6.html" target="_blank">Michael Nielsen's book is a must read, in particular chapter 6 which deals with CNNs</a>.
|
||||
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec6">CNNs in more detail, building convolutional neural networks in Tensorflow and Keras </h2>
|
||||
|
||||
<p>
|
||||
As discussed above, CNNs are neural networks built from the assumption that the inputs
|
||||
to the network are 2D images. This is important because the number of features or pixels in images
|
||||
grows very fast with the image size, and an enormous number of weights and biases are needed in order to build an accurate network.
|
||||
|
||||
<p>
|
||||
As before, we still have our input, a hidden layer and an output. What's novel about convolutional networks
|
||||
are the <b>convolutional</b> and <b>pooling</b> layers stacked in pairs between the input and the hidden layer.
|
||||
In addition, the data is no longer represented as a 2D feature matrix, instead each input is a number of 2D
|
||||
matrices, typically 1 for each color dimension (Red, Green, Blue).
|
||||
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec7">Setting it up </h2>
|
||||
|
||||
<p>
|
||||
It means that to represent the entire
|
||||
dataset of images, we require a 4D matrix or <b>tensor</b>. This tensor has the dimensions:
|
||||
$$
|
||||
(n_{inputs},\, n_{pixels, width},\, n_{pixels, height},\, depth) .
|
||||
$$
|
||||
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec8">The MNIST dataset again </h2>
|
||||
|
||||
<p>
|
||||
The MNIST dataset consists of grayscale images with a pixel size of
|
||||
\( 28\times 28 \), meaning we require \( 28 \times 28 = 724 \) weights to each
|
||||
neuron in the first hidden layer.
|
||||
|
||||
<p>
|
||||
If we were to analyze images of size \( 128\times 128 \) we would require
|
||||
\( 128 \times 128 = 16384 \) weights to each neuron. Even worse if we were
|
||||
dealing with color images, as most images are, we have an image matrix
|
||||
of size \( 128\times 128 \) for each color dimension (Red, Green, Blue),
|
||||
meaning 3 times the number of weights \( = 49152 \) are required for every
|
||||
single neuron in the first hidden layer.
|
||||
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec9">Strong correlations </h2>
|
||||
Images typically have strong local correlations, meaning that a small
|
||||
part of the image varies little from its neighboring regions. If for
|
||||
example we have an image of a blue car, we can roughly assume that a
|
||||
small blue part of the image is surrounded by other blue regions.
|
||||
|
||||
<p>
|
||||
Therefore, instead of connecting every single pixel to a neuron in the
|
||||
first hidden layer, as we have previously done with deep neural
|
||||
networks, we can instead connect each neuron to a small part of the
|
||||
image (in all 3 RGB depth dimensions). The size of each small area is
|
||||
fixed, and known as a <a href="https://en.wikipedia.org/wiki/Receptive_field" target="_blank">receptive</a>.
|
||||
|
||||
<p>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="___sec10">Layers of a CNN </h2>
|
||||
The layers of a convolutional neural network arrange neurons in 3D: width, height and depth.
|
||||
The input image is typically a square matrix of depth 3.
|
||||
|
||||
<p>
|
||||
A <b>convolution</b> is performed on the image which outputs
|
||||
a 3D volume of neurons. The weights to the input are arranged in a number of 2D matrices, known as <b>filters</b>.
|
||||
|
||||
<p>
|
||||
Each filter slides along the input image, taking the dot product
|
||||
between each small part of the image and the filter, in all depth
|
||||
dimensions. This is then passed through a non-linear function,
|
||||
typically the <b>Rectified Linear (ReLu)</b> function, which serves as the
|
||||
activation of the neurons in the first convolutional layer. This is
|
||||
further passed through a <b>pooling layer</b>, which reduces the size of the
|
||||
convolutional layer, e.g. by taking the maximum or average across some
|
||||
small regions, and this serves as input to the next convolutional
|
||||
layer.
|
||||
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec11">Systematic reduction </h2>
|
||||
|
||||
<p>
|
||||
By systematically reducing the size of the input volume, through
|
||||
convolution and pooling, the network should create representations of
|
||||
small parts of the input, and then from them assemble representations
|
||||
of larger areas. The final pooling layer is flattened to serve as
|
||||
input to a hidden layer, such that each neuron in the final pooling
|
||||
layer is connected to every single neuron in the hidden layer. This
|
||||
then serves as input to the output layer, e.g. a softmax output for
|
||||
classification.
|
||||
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec12">Prerequisites: Collect and pre-process data </h2>
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span><span style="color: #408080; font-style: italic"># import necessary packages</span>
|
||||
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">numpy</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">np</span>
|
||||
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">matplotlib.pyplot</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">plt</span>
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn</span> <span style="color: #008000; font-weight: bold">import</span> datasets
|
||||
|
||||
|
||||
<span style="color: #408080; font-style: italic"># ensure the same random numbers appear every time</span>
|
||||
np<span style="color: #666666">.</span>random<span style="color: #666666">.</span>seed(<span style="color: #666666">0</span>)
|
||||
|
||||
<span style="color: #408080; font-style: italic"># display images in notebook</span>
|
||||
<span style="color: #666666">%</span>matplotlib inline
|
||||
plt<span style="color: #666666">.</span>rcParams[<span style="color: #BA2121">'figure.figsize'</span>] <span style="color: #666666">=</span> (<span style="color: #666666">12</span>,<span style="color: #666666">12</span>)
|
||||
|
||||
|
||||
<span style="color: #408080; font-style: italic"># download MNIST dataset</span>
|
||||
digits <span style="color: #666666">=</span> datasets<span style="color: #666666">.</span>load_digits()
|
||||
|
||||
<span style="color: #408080; font-style: italic"># define inputs and labels</span>
|
||||
inputs <span style="color: #666666">=</span> digits<span style="color: #666666">.</span>images
|
||||
labels <span style="color: #666666">=</span> digits<span style="color: #666666">.</span>target
|
||||
|
||||
<span style="color: #408080; font-style: italic"># RGB images have a depth of 3</span>
|
||||
<span style="color: #408080; font-style: italic"># our images are grayscale so they should have a depth of 1</span>
|
||||
inputs <span style="color: #666666">=</span> inputs[:,:,:,np<span style="color: #666666">.</span>newaxis]
|
||||
|
||||
<span style="color: #008000; font-weight: bold">print</span>(<span style="color: #BA2121">"inputs = (n_inputs, pixel_width, pixel_height, depth) = "</span> <span style="color: #666666">+</span> <span style="color: #008000">str</span>(inputs<span style="color: #666666">.</span>shape))
|
||||
<span style="color: #008000; font-weight: bold">print</span>(<span style="color: #BA2121">"labels = (n_inputs) = "</span> <span style="color: #666666">+</span> <span style="color: #008000">str</span>(labels<span style="color: #666666">.</span>shape))
|
||||
|
||||
|
||||
<span style="color: #408080; font-style: italic"># choose some random images to display</span>
|
||||
n_inputs <span style="color: #666666">=</span> <span style="color: #008000">len</span>(inputs)
|
||||
indices <span style="color: #666666">=</span> np<span style="color: #666666">.</span>arange(n_inputs)
|
||||
random_indices <span style="color: #666666">=</span> np<span style="color: #666666">.</span>random<span style="color: #666666">.</span>choice(indices, size<span style="color: #666666">=5</span>)
|
||||
|
||||
<span style="color: #008000; font-weight: bold">for</span> i, image <span style="color: #AA22FF; font-weight: bold">in</span> <span style="color: #008000">enumerate</span>(digits<span style="color: #666666">.</span>images[random_indices]):
|
||||
plt<span style="color: #666666">.</span>subplot(<span style="color: #666666">1</span>, <span style="color: #666666">5</span>, i<span style="color: #666666">+1</span>)
|
||||
plt<span style="color: #666666">.</span>axis(<span style="color: #BA2121">'off'</span>)
|
||||
plt<span style="color: #666666">.</span>imshow(image, cmap<span style="color: #666666">=</span>plt<span style="color: #666666">.</span>cm<span style="color: #666666">.</span>gray_r, interpolation<span style="color: #666666">=</span><span style="color: #BA2121">'nearest'</span>)
|
||||
plt<span style="color: #666666">.</span>title(<span style="color: #BA2121">"Label: </span><span style="color: #BB6688; font-weight: bold">%d</span><span style="color: #BA2121">"</span> <span style="color: #666666">%</span> digits<span style="color: #666666">.</span>target[random_indices[i]])
|
||||
plt<span style="color: #666666">.</span>show()
|
||||
</pre></div>
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec13">Importing Keras and Tensorflow </h2>
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span><span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">keras.utils</span> <span style="color: #008000; font-weight: bold">import</span> to_categorical
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.model_selection</span> <span style="color: #008000; font-weight: bold">import</span> train_test_split
|
||||
|
||||
<span style="color: #408080; font-style: italic"># representation of labels</span>
|
||||
labels <span style="color: #666666">=</span> to_categorical(labels)
|
||||
|
||||
<span style="color: #408080; font-style: italic"># split into train and test data</span>
|
||||
<span style="color: #408080; font-style: italic"># one-liner from scikit-learn library</span>
|
||||
train_size <span style="color: #666666">=</span> <span style="color: #666666">0.8</span>
|
||||
test_size <span style="color: #666666">=</span> <span style="color: #666666">1</span> <span style="color: #666666">-</span> train_size
|
||||
X_train, X_test, Y_train, Y_test <span style="color: #666666">=</span> train_test_split(inputs, labels, train_size<span style="color: #666666">=</span>train_size,
|
||||
test_size<span style="color: #666666">=</span>test_size)
|
||||
</pre></div>
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec14">Using TensorFlow backend </h2>
|
||||
|
||||
<p>
|
||||
We need to define model and architecture and choose cost function and optmizer.
|
||||
<p>
|
||||
|
||||
<!-- code=text (!bc pycid) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span>import tensorflow as tf
|
||||
|
||||
class ConvolutionalNeuralNetworkTensorflow:
|
||||
def __init__(
|
||||
self,
|
||||
X_train,
|
||||
Y_train,
|
||||
X_test,
|
||||
Y_test,
|
||||
n_filters=10,
|
||||
n_neurons_connected=50,
|
||||
n_categories=10,
|
||||
receptive_field=3,
|
||||
stride=1,
|
||||
padding=1,
|
||||
epochs=10,
|
||||
batch_size=100,
|
||||
eta=0.1,
|
||||
lmbd=0.0):
|
||||
|
||||
self.global_step = tf.Variable(0, dtype=tf.int32, trainable=False, name='global_step')
|
||||
|
||||
self.X_train = X_train
|
||||
self.Y_train = Y_train
|
||||
self.X_test = X_test
|
||||
self.Y_test = Y_test
|
||||
|
||||
self.n_inputs, self.input_width, self.input_height, self.depth = X_train.shape
|
||||
|
||||
self.n_filters = n_filters
|
||||
self.n_downsampled = int(self.input_width*self.input_height*n_filters / 4)
|
||||
self.n_neurons_connected = n_neurons_connected
|
||||
self.n_categories = n_categories
|
||||
|
||||
self.receptive_field = receptive_field
|
||||
self.stride = stride
|
||||
self.strides = [stride, stride, stride, stride]
|
||||
self.padding = padding
|
||||
|
||||
self.epochs = epochs
|
||||
self.batch_size = batch_size
|
||||
self.iterations = self.n_inputs // self.batch_size
|
||||
self.eta = eta
|
||||
self.lmbd = lmbd
|
||||
|
||||
self.create_placeholders()
|
||||
self.create_CNN()
|
||||
self.create_loss()
|
||||
self.create_optimiser()
|
||||
self.create_accuracy()
|
||||
|
||||
def create_placeholders(self):
|
||||
with tf.name_scope('data'):
|
||||
self.X = tf.placeholder(tf.float32, shape=(None, self.input_width, self.input_height, self.depth), name='X_data')
|
||||
self.Y = tf.placeholder(tf.float32, shape=(None, self.n_categories), name='Y_data')
|
||||
|
||||
def create_CNN(self):
|
||||
with tf.name_scope('CNN'):
|
||||
|
||||
# Convolutional layer
|
||||
self.W_conv = self.weight_variable([self.receptive_field, self.receptive_field, self.depth, self.n_filters], name='conv', dtype=tf.float32)
|
||||
b_conv = self.weight_variable([self.n_filters], name='conv', dtype=tf.float32)
|
||||
z_conv = tf.nn.conv2d(self.X, self.W_conv, self.strides, padding='SAME', name='conv') + b_conv
|
||||
a_conv = tf.nn.relu(z_conv)
|
||||
|
||||
# 2x2 max pooling
|
||||
a_pool = tf.nn.max_pool(a_conv, [1, 2, 2, 1], [1, 2, 2, 1], padding='SAME', name='pool')
|
||||
|
||||
# Fully connected layer
|
||||
a_pool_flat = tf.reshape(a_pool, [-1, self.n_downsampled])
|
||||
self.W_fc = self.weight_variable([self.n_downsampled, self.n_neurons_connected], name='fc', dtype=tf.float32)
|
||||
b_fc = self.bias_variable([self.n_neurons_connected], name='fc', dtype=tf.float32)
|
||||
a_fc = tf.nn.relu(tf.matmul(a_pool_flat, self.W_fc) + b_fc)
|
||||
|
||||
# Output layer
|
||||
self.W_out = self.weight_variable([self.n_neurons_connected, self.n_categories], name='out', dtype=tf.float32)
|
||||
b_out = self.bias_variable([self.n_categories], name='out', dtype=tf.float32)
|
||||
self.z_out = tf.matmul(a_fc, self.W_out) + b_out
|
||||
|
||||
def create_loss(self):
|
||||
with tf.name_scope('loss'):
|
||||
softmax_loss = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits_v2(labels=self.Y, logits=self.z_out))
|
||||
|
||||
regularizer_loss_conv = tf.nn.l2_loss(self.W_conv)
|
||||
regularizer_loss_fc = tf.nn.l2_loss(self.W_fc)
|
||||
regularizer_loss_out = tf.nn.l2_loss(self.W_out)
|
||||
regularizer_loss = self.lmbd*(regularizer_loss_conv + regularizer_loss_fc + regularizer_loss_out)
|
||||
|
||||
self.loss = softmax_loss + regularizer_loss
|
||||
|
||||
def create_accuracy(self):
|
||||
with tf.name_scope('accuracy'):
|
||||
probabilities = tf.nn.softmax(self.z_out)
|
||||
predictions = tf.argmax(probabilities, 1)
|
||||
labels = tf.argmax(self.Y, 1)
|
||||
|
||||
correct_predictions = tf.equal(predictions, labels)
|
||||
correct_predictions = tf.cast(correct_predictions, tf.float32)
|
||||
self.accuracy = tf.reduce_mean(correct_predictions)
|
||||
|
||||
def create_optimiser(self):
|
||||
with tf.name_scope('optimizer'):
|
||||
self.optimizer = tf.train.GradientDescentOptimizer(learning_rate=self.eta).minimize(self.loss, global_step=self.global_step)
|
||||
|
||||
def weight_variable(self, shape, name='', dtype=tf.float32):
|
||||
initial = tf.truncated_normal(shape, stddev=0.1)
|
||||
return tf.Variable(initial, name=name, dtype=dtype)
|
||||
|
||||
def bias_variable(self, shape, name='', dtype=tf.float32):
|
||||
initial = tf.constant(0.1, shape=shape)
|
||||
return tf.Variable(initial, name=name, dtype=dtype)
|
||||
|
||||
def fit(self):
|
||||
data_indices = np.arange(self.n_inputs)
|
||||
|
||||
with tf.Session() as sess:
|
||||
sess.run(tf.global_variables_initializer())
|
||||
for i in range(self.epochs):
|
||||
for j in range(self.iterations):
|
||||
chosen_datapoints = np.random.choice(data_indices, size=self.batch_size, replace=False)
|
||||
batch_X, batch_Y = self.X_train[chosen_datapoints], self.Y_train[chosen_datapoints]
|
||||
|
||||
sess.run([CNN.loss, CNN.optimizer],
|
||||
feed_dict={CNN.X: batch_X,
|
||||
CNN.Y: batch_Y})
|
||||
accuracy = sess.run(CNN.accuracy,
|
||||
feed_dict={CNN.X: batch_X,
|
||||
CNN.Y: batch_Y})
|
||||
step = sess.run(CNN.global_step)
|
||||
|
||||
self.train_loss, self.train_accuracy = sess.run([CNN.loss, CNN.accuracy],
|
||||
feed_dict={CNN.X: self.X_train,
|
||||
CNN.Y: self.Y_train})
|
||||
|
||||
self.test_loss, self.test_accuracy = sess.run([CNN.loss, CNN.accuracy],
|
||||
feed_dict={CNN.X: self.X_test,
|
||||
CNN.Y: self.Y_test})
|
||||
</pre></div>
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec15">Train the model </h2>
|
||||
|
||||
<p>
|
||||
We need now to train the model, evaluate it and test its performance on test data, and eventually include hyperparameters.
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span>epochs <span style="color: #666666">=</span> <span style="color: #666666">100</span>
|
||||
batch_size <span style="color: #666666">=</span> <span style="color: #666666">100</span>
|
||||
n_filters <span style="color: #666666">=</span> <span style="color: #666666">10</span>
|
||||
n_neurons_connected <span style="color: #666666">=</span> <span style="color: #666666">50</span>
|
||||
n_categories <span style="color: #666666">=</span> <span style="color: #666666">10</span>
|
||||
|
||||
eta_vals <span style="color: #666666">=</span> np<span style="color: #666666">.</span>logspace(<span style="color: #666666">-5</span>, <span style="color: #666666">1</span>, <span style="color: #666666">7</span>)
|
||||
lmbd_vals <span style="color: #666666">=</span> np<span style="color: #666666">.</span>logspace(<span style="color: #666666">-5</span>, <span style="color: #666666">1</span>, <span style="color: #666666">7</span>)
|
||||
CNN_tf <span style="color: #666666">=</span> np<span style="color: #666666">.</span>zeros((<span style="color: #008000">len</span>(eta_vals), <span style="color: #008000">len</span>(lmbd_vals)), dtype<span style="color: #666666">=</span><span style="color: #008000">object</span>)
|
||||
|
||||
<span style="color: #008000; font-weight: bold">for</span> i, eta <span style="color: #AA22FF; font-weight: bold">in</span> <span style="color: #008000">enumerate</span>(eta_vals):
|
||||
<span style="color: #008000; font-weight: bold">for</span> j, lmbd <span style="color: #AA22FF; font-weight: bold">in</span> <span style="color: #008000">enumerate</span>(lmbd_vals):
|
||||
CNN <span style="color: #666666">=</span> ConvolutionalNeuralNetworkTensorflow(X_train, Y_train, X_test, Y_test,
|
||||
n_filters<span style="color: #666666">=</span>n_filters, n_neurons_connected<span style="color: #666666">=</span>n_neurons_connected,
|
||||
n_categories<span style="color: #666666">=</span>n_categories, epochs<span style="color: #666666">=</span>epochs, batch_size<span style="color: #666666">=</span>batch_size,
|
||||
eta<span style="color: #666666">=</span>eta, lmbd<span style="color: #666666">=</span>lmbd)
|
||||
CNN<span style="color: #666666">.</span>fit()
|
||||
|
||||
<span style="color: #008000; font-weight: bold">print</span>(<span style="color: #BA2121">"Learning rate = "</span>, eta)
|
||||
<span style="color: #008000; font-weight: bold">print</span>(<span style="color: #BA2121">"Lambda = "</span>, lmbd)
|
||||
<span style="color: #008000; font-weight: bold">print</span>(<span style="color: #BA2121">"Test accuracy: </span><span style="color: #BB6688; font-weight: bold">%.3f</span><span style="color: #BA2121">"</span> <span style="color: #666666">%</span> CNN<span style="color: #666666">.</span>test_accuracy)
|
||||
<span style="color: #008000; font-weight: bold">print</span>()
|
||||
|
||||
CNN_tf[i][j] <span style="color: #666666">=</span> CNN
|
||||
</pre></div>
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec16">Visualizing the results </h2>
|
||||
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span><span style="color: #408080; font-style: italic"># visual representation of grid search</span>
|
||||
<span style="color: #408080; font-style: italic"># uses seaborn heatmap, could probably do this in matplotlib</span>
|
||||
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">seaborn</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">sns</span>
|
||||
|
||||
sns<span style="color: #666666">.</span>set()
|
||||
|
||||
train_accuracy <span style="color: #666666">=</span> np<span style="color: #666666">.</span>zeros((<span style="color: #008000">len</span>(eta_vals), <span style="color: #008000">len</span>(lmbd_vals)))
|
||||
test_accuracy <span style="color: #666666">=</span> np<span style="color: #666666">.</span>zeros((<span style="color: #008000">len</span>(eta_vals), <span style="color: #008000">len</span>(lmbd_vals)))
|
||||
|
||||
<span style="color: #008000; font-weight: bold">for</span> i <span style="color: #AA22FF; font-weight: bold">in</span> <span style="color: #008000">range</span>(<span style="color: #008000">len</span>(eta_vals)):
|
||||
<span style="color: #008000; font-weight: bold">for</span> j <span style="color: #AA22FF; font-weight: bold">in</span> <span style="color: #008000">range</span>(<span style="color: #008000">len</span>(lmbd_vals)):
|
||||
CNN <span style="color: #666666">=</span> CNN_tf[i][j]
|
||||
|
||||
train_accuracy[i][j] <span style="color: #666666">=</span> CNN<span style="color: #666666">.</span>train_accuracy
|
||||
test_accuracy[i][j] <span style="color: #666666">=</span> CNN<span style="color: #666666">.</span>test_accuracy
|
||||
|
||||
|
||||
fig, ax <span style="color: #666666">=</span> plt<span style="color: #666666">.</span>subplots(figsize <span style="color: #666666">=</span> (<span style="color: #666666">10</span>, <span style="color: #666666">10</span>))
|
||||
sns<span style="color: #666666">.</span>heatmap(train_accuracy, annot<span style="color: #666666">=</span><span style="color: #008000">True</span>, ax<span style="color: #666666">=</span>ax, cmap<span style="color: #666666">=</span><span style="color: #BA2121">"viridis"</span>)
|
||||
ax<span style="color: #666666">.</span>set_title(<span style="color: #BA2121">"Training Accuracy"</span>)
|
||||
ax<span style="color: #666666">.</span>set_ylabel(<span style="color: #BA2121">"$\eta$"</span>)
|
||||
ax<span style="color: #666666">.</span>set_xlabel(<span style="color: #BA2121">"$\lambda$"</span>)
|
||||
plt<span style="color: #666666">.</span>show()
|
||||
|
||||
fig, ax <span style="color: #666666">=</span> plt<span style="color: #666666">.</span>subplots(figsize <span style="color: #666666">=</span> (<span style="color: #666666">10</span>, <span style="color: #666666">10</span>))
|
||||
sns<span style="color: #666666">.</span>heatmap(test_accuracy, annot<span style="color: #666666">=</span><span style="color: #008000">True</span>, ax<span style="color: #666666">=</span>ax, cmap<span style="color: #666666">=</span><span style="color: #BA2121">"viridis"</span>)
|
||||
ax<span style="color: #666666">.</span>set_title(<span style="color: #BA2121">"Test Accuracy"</span>)
|
||||
ax<span style="color: #666666">.</span>set_ylabel(<span style="color: #BA2121">"$\eta$"</span>)
|
||||
ax<span style="color: #666666">.</span>set_xlabel(<span style="color: #BA2121">"$\lambda$"</span>)
|
||||
plt<span style="color: #666666">.</span>show()
|
||||
</pre></div>
|
||||
<p>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="___sec17">Running with Keras </h2>
|
||||
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span><span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">keras.models</span> <span style="color: #008000; font-weight: bold">import</span> Sequential
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">keras.layers.convolutional</span> <span style="color: #008000; font-weight: bold">import</span> Conv2D
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">keras.layers.convolutional</span> <span style="color: #008000; font-weight: bold">import</span> MaxPooling2D
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">keras.layers</span> <span style="color: #008000; font-weight: bold">import</span> Flatten
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">keras.layers</span> <span style="color: #008000; font-weight: bold">import</span> Dense
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">keras.regularizers</span> <span style="color: #008000; font-weight: bold">import</span> l2
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">keras.optimizers</span> <span style="color: #008000; font-weight: bold">import</span> SGD
|
||||
|
||||
<span style="color: #008000; font-weight: bold">def</span> <span style="color: #0000FF">create_convolutional_neural_network_keras</span>(input_shape, receptive_field,
|
||||
n_filters, n_neurons_connected, n_categories,
|
||||
eta, lmbd):
|
||||
model <span style="color: #666666">=</span> Sequential()
|
||||
model<span style="color: #666666">.</span>add(Conv2D(n_filters, (receptive_field, receptive_field), input_shape<span style="color: #666666">=</span>input_shape, padding<span style="color: #666666">=</span><span style="color: #BA2121">'same'</span>,
|
||||
activation<span style="color: #666666">=</span><span style="color: #BA2121">'relu'</span>, kernel_regularizer<span style="color: #666666">=</span>l2(lmbd)))
|
||||
model<span style="color: #666666">.</span>add(MaxPooling2D(pool_size<span style="color: #666666">=</span>(<span style="color: #666666">2</span>, <span style="color: #666666">2</span>)))
|
||||
model<span style="color: #666666">.</span>add(Flatten())
|
||||
model<span style="color: #666666">.</span>add(Dense(n_neurons_connected, activation<span style="color: #666666">=</span><span style="color: #BA2121">'relu'</span>, kernel_regularizer<span style="color: #666666">=</span>l2(lmbd)))
|
||||
model<span style="color: #666666">.</span>add(Dense(n_categories, activation<span style="color: #666666">=</span><span style="color: #BA2121">'softmax'</span>, kernel_regularizer<span style="color: #666666">=</span>l2(lmbd)))
|
||||
|
||||
sgd <span style="color: #666666">=</span> SGD(lr<span style="color: #666666">=</span>eta)
|
||||
model<span style="color: #666666">.</span>compile(loss<span style="color: #666666">=</span><span style="color: #BA2121">'categorical_crossentropy'</span>, optimizer<span style="color: #666666">=</span>sgd, metrics<span style="color: #666666">=</span>[<span style="color: #BA2121">'accuracy'</span>])
|
||||
|
||||
<span style="color: #008000; font-weight: bold">return</span> model
|
||||
|
||||
epochs <span style="color: #666666">=</span> <span style="color: #666666">100</span>
|
||||
batch_size <span style="color: #666666">=</span> <span style="color: #666666">100</span>
|
||||
input_shape <span style="color: #666666">=</span> X_train<span style="color: #666666">.</span>shape[<span style="color: #666666">1</span>:<span style="color: #666666">4</span>]
|
||||
receptive_field <span style="color: #666666">=</span> <span style="color: #666666">3</span>
|
||||
n_filters <span style="color: #666666">=</span> <span style="color: #666666">10</span>
|
||||
n_neurons_connected <span style="color: #666666">=</span> <span style="color: #666666">50</span>
|
||||
n_categories <span style="color: #666666">=</span> <span style="color: #666666">10</span>
|
||||
|
||||
eta_vals <span style="color: #666666">=</span> np<span style="color: #666666">.</span>logspace(<span style="color: #666666">-5</span>, <span style="color: #666666">1</span>, <span style="color: #666666">7</span>)
|
||||
lmbd_vals <span style="color: #666666">=</span> np<span style="color: #666666">.</span>logspace(<span style="color: #666666">-5</span>, <span style="color: #666666">1</span>, <span style="color: #666666">7</span>)
|
||||
</pre></div>
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec18">Final part </h2>
|
||||
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span>CNN_keras <span style="color: #666666">=</span> np<span style="color: #666666">.</span>zeros((<span style="color: #008000">len</span>(eta_vals), <span style="color: #008000">len</span>(lmbd_vals)), dtype<span style="color: #666666">=</span><span style="color: #008000">object</span>)
|
||||
|
||||
<span style="color: #008000; font-weight: bold">for</span> i, eta <span style="color: #AA22FF; font-weight: bold">in</span> <span style="color: #008000">enumerate</span>(eta_vals):
|
||||
<span style="color: #008000; font-weight: bold">for</span> j, lmbd <span style="color: #AA22FF; font-weight: bold">in</span> <span style="color: #008000">enumerate</span>(lmbd_vals):
|
||||
CNN <span style="color: #666666">=</span> create_convolutional_neural_network_keras(input_shape, receptive_field,
|
||||
n_filters, n_neurons_connected, n_categories,
|
||||
eta, lmbd)
|
||||
CNN<span style="color: #666666">.</span>fit(X_train, Y_train, epochs<span style="color: #666666">=</span>epochs, batch_size<span style="color: #666666">=</span>batch_size, verbose<span style="color: #666666">=0</span>)
|
||||
scores <span style="color: #666666">=</span> CNN<span style="color: #666666">.</span>evaluate(X_test, Y_test)
|
||||
|
||||
CNN_keras[i][j] <span style="color: #666666">=</span> CNN
|
||||
|
||||
<span style="color: #008000; font-weight: bold">print</span>(<span style="color: #BA2121">"Learning rate = "</span>, eta)
|
||||
<span style="color: #008000; font-weight: bold">print</span>(<span style="color: #BA2121">"Lambda = "</span>, lmbd)
|
||||
<span style="color: #008000; font-weight: bold">print</span>(<span style="color: #BA2121">"Test accuracy: </span><span style="color: #BB6688; font-weight: bold">%.3f</span><span style="color: #BA2121">"</span> <span style="color: #666666">%</span> scores[<span style="color: #666666">1</span>])
|
||||
<span style="color: #008000; font-weight: bold">print</span>()
|
||||
</pre></div>
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec19">Final visualization </h2>
|
||||
|
||||
<p>
|
||||
|
||||
<!-- code=text typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span># visual representation of grid search
|
||||
# uses seaborn heatmap, could probably do this in matplotlib
|
||||
import seaborn as sns
|
||||
|
||||
sns.set()
|
||||
|
||||
train_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))
|
||||
test_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))
|
||||
|
||||
for i in range(len(eta_vals)):
|
||||
for j in range(len(lmbd_vals)):
|
||||
CNN = CNN_keras[i][j]
|
||||
|
||||
train_accuracy[i][j] = CNN.evaluate(X_train, Y_train)[1]
|
||||
test_accuracy[i][j] = CNN.evaluate(X_test, Y_test)[1]
|
||||
|
||||
|
||||
fig, ax = plt.subplots(figsize = (10, 10))
|
||||
sns.heatmap(train_accuracy, annot=True, ax=ax, cmap="viridis")
|
||||
ax.set_title("Training Accuracy")
|
||||
ax.set_ylabel("$\eta$")
|
||||
ax.set_xlabel("$\lambda$")
|
||||
plt.show()
|
||||
|
||||
fig, ax = plt.subplots(figsize = (10, 10))
|
||||
sns.heatmap(test_accuracy, annot=True, ax=ax, cmap="viridis")
|
||||
ax.set_title("Test Accuracy")
|
||||
ax.set_ylabel("$\eta$")
|
||||
ax.set_xlabel("$\lambda$")
|
||||
plt.show()
|
||||
</pre></div>
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec20">Fun links </h2>
|
||||
|
||||
<ol>
|
||||
<li> <a href="https://arxiv.org/abs/1604.07316" target="_blank">Self-Driving cars using a convolutional neural network</a></li>
|
||||
<li> <a href="https://deepdreamgenerator.com/" target="_blank">Abstract art using convolutional neural networks</a></li>
|
||||
</ol>
|
||||
|
||||
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright --> © 1999-2019, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
@@ -1,729 +0,0 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"<!-- dom:TITLE: Convolutional Neural Networks -->\n",
|
||||
"# Convolutional Neural Networks\n",
|
||||
"<!-- dom:AUTHOR: Morten Hjorth-Jensen at Department of Physics, University of Oslo & Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University -->\n",
|
||||
"<!-- Author: --> \n",
|
||||
"**Morten Hjorth-Jensen**, Department of Physics, University of Oslo and Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University\n",
|
||||
"\n",
|
||||
"Date: **Oct 3, 2019**\n",
|
||||
"\n",
|
||||
"Copyright 1999-2019, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"## Convolutional Neural Networks (recognizing images)\n",
|
||||
"\n",
|
||||
"Convolutional Neural Networks (CNN) are very similar to ordinary Neural Networks.\n",
|
||||
"\n",
|
||||
"They are made up of neurons that have learnable weights and\n",
|
||||
"biases. Each neuron receives some inputs, performs a dot product and\n",
|
||||
"optionally follows it with a non-linearity. The whole network still\n",
|
||||
"expresses a single differentiable score function: from the raw image\n",
|
||||
"pixels on one end to class scores at the other. And they still have a\n",
|
||||
"loss function (for example Softmax) on the last (fully-connected) layer\n",
|
||||
"and all the tips/tricks we developed for learning regular Neural\n",
|
||||
"Networks still apply (back propagation, gradient descent etc etc).\n",
|
||||
"\n",
|
||||
"What is the difference? **CNN architectures make the explicit assumption that\n",
|
||||
"the inputs are images, which allows us to encode certain properties\n",
|
||||
"into the architecture. These then make the forward function more\n",
|
||||
"efficient to implement and vastly reduce the amount of parameters in\n",
|
||||
"the network.**\n",
|
||||
"\n",
|
||||
"Here we provide only a superficial overview, for the more interested, we recommend highly the course\n",
|
||||
"[IN5400 – Machine Learning for Image Analysis](https://www.uio.no/studier/emner/matnat/ifi/IN5400/index-eng.html)\n",
|
||||
"and the slides of [CS231](http://cs231n.github.io/convolutional-networks/).\n",
|
||||
"\n",
|
||||
"## Regular NNs don’t scale well to full images\n",
|
||||
"\n",
|
||||
"As an example, consider\n",
|
||||
"an image of size $32\\times 32\\times 3$ (32 wide, 32 high, 3 color channels), so a\n",
|
||||
"single fully-connected neuron in a first hidden layer of a regular\n",
|
||||
"Neural Network would have $32\\times 32\\times 3 = 3072$ weights. This amount still\n",
|
||||
"seems manageable, but clearly this fully-connected structure does not\n",
|
||||
"scale to larger images. For example, an image of more respectable\n",
|
||||
"size, say $200\\times 200\\times 3$, would lead to neurons that have \n",
|
||||
"$200\\times 200\\times 3 = 120,000$ weights. \n",
|
||||
"\n",
|
||||
"We could have\n",
|
||||
"several such neurons, and the parameters would add up quickly! Clearly,\n",
|
||||
"this full connectivity is wasteful and the huge number of parameters\n",
|
||||
"would quickly lead to possible overfitting.\n",
|
||||
"\n",
|
||||
"<!-- dom:FIGURE: [figslides/nn.jpeg, width=500 frac=0.6] A regular 3-layer Neural Network. -->\n",
|
||||
"<!-- begin figure -->\n",
|
||||
"\n",
|
||||
"<p>A regular 3-layer Neural Network.</p>\n",
|
||||
"<img src=\"figslides/nn.jpeg\" width=500>\n",
|
||||
"\n",
|
||||
"<!-- end figure -->\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"## 3D volumes of neurons\n",
|
||||
"\n",
|
||||
"Convolutional Neural Networks take advantage of the fact that the\n",
|
||||
"input consists of images and they constrain the architecture in a more\n",
|
||||
"sensible way. \n",
|
||||
"\n",
|
||||
"In particular, unlike a regular Neural Network, the\n",
|
||||
"layers of a CNN have neurons arranged in 3 dimensions: width,\n",
|
||||
"height, depth. (Note that the word depth here refers to the third\n",
|
||||
"dimension of an activation volume, not to the depth of a full Neural\n",
|
||||
"Network, which can refer to the total number of layers in a network.)\n",
|
||||
"\n",
|
||||
"To understand it better, the above example of an image \n",
|
||||
"with an input volume of\n",
|
||||
"activations has dimensions $32\\times 32\\times 3$ (width, height,\n",
|
||||
"depth respectively). \n",
|
||||
"\n",
|
||||
"The neurons in a layer will\n",
|
||||
"only be connected to a small region of the layer before it, instead of\n",
|
||||
"all of the neurons in a fully-connected manner. Moreover, the final\n",
|
||||
"output layer could for this specific image have dimensions $1\\times 1 \\times 10$, \n",
|
||||
"because by the\n",
|
||||
"end of the CNN architecture we will reduce the full image into a\n",
|
||||
"single vector of class scores, arranged along the depth\n",
|
||||
"dimension. \n",
|
||||
"\n",
|
||||
"<!-- dom:FIGURE: [figslides/cnn.jpeg, width=500 frac=0.6] A CNN arranges its neurons in three dimensions (width, height, depth), as visualized in one of the layers. Every layer of a CNN transforms the 3D input volume to a 3D output volume of neuron activations. In this example, the red input layer holds the image, so its width and height would be the dimensions of the image, and the depth would be 3 (Red, Green, Blue channels). -->\n",
|
||||
"<!-- begin figure -->\n",
|
||||
"\n",
|
||||
"<p>A CNN arranges its neurons in three dimensions (width, height, depth), as visualized in one of the layers. Every layer of a CNN transforms the 3D input volume to a 3D output volume of neuron activations. In this example, the red input layer holds the image, so its width and height would be the dimensions of the image, and the depth would be 3 (Red, Green, Blue channels).</p>\n",
|
||||
"<img src=\"figslides/cnn.jpeg\" width=500>\n",
|
||||
"\n",
|
||||
"<!-- end figure -->\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"<!-- !split -->\n",
|
||||
"## Layers used to build CNNs\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"A simple CNN is a sequence of layers, and every layer of a CNN\n",
|
||||
"transforms one volume of activations to another through a\n",
|
||||
"differentiable function. We use three main types of layers to build\n",
|
||||
"CNN architectures: Convolutional Layer, Pooling Layer, and\n",
|
||||
"Fully-Connected Layer (exactly as seen in regular Neural Networks). We\n",
|
||||
"will stack these layers to form a full CNN architecture.\n",
|
||||
"\n",
|
||||
"A simple CNN for image classification could have the architecture:\n",
|
||||
"\n",
|
||||
"* **INPUT** ($32\\times 32 \\times 3$) will hold the raw pixel values of the image, in this case an image of width 32, height 32, and with three color channels R,G,B.\n",
|
||||
"\n",
|
||||
"* **CONV** (convolutional )layer will compute the output of neurons that are connected to local regions in the input, each computing a dot product between their weights and a small region they are connected to in the input volume. This may result in volume such as $[32\\times 32\\times 12]$ if we decided to use 12 filters.\n",
|
||||
"\n",
|
||||
"* **RELU** layer will apply an elementwise activation function, such as the $max(0,x)$ thresholding at zero. This leaves the size of the volume unchanged ($[32\\times 32\\times 12]$).\n",
|
||||
"\n",
|
||||
"* **POOL** (pooling) layer will perform a downsampling operation along the spatial dimensions (width, height), resulting in volume such as $[16\\times 16\\times 12]$.\n",
|
||||
"\n",
|
||||
"* **FC** (i.e. fully-connected) layer will compute the class scores, resulting in volume of size $[1\\times 1\\times 10]$, where each of the 10 numbers correspond to a class score, such as among the 10 categories of the MNIST images we considered above . As with ordinary Neural Networks and as the name implies, each neuron in this layer will be connected to all the numbers in the previous volume.\n",
|
||||
"\n",
|
||||
"## Transforming images\n",
|
||||
"\n",
|
||||
"CNNs transform the original image layer by layer from the original\n",
|
||||
"pixel values to the final class scores. \n",
|
||||
"\n",
|
||||
"Observe that some layers contain\n",
|
||||
"parameters and other don’t. In particular, the CNN layers perform\n",
|
||||
"transformations that are a function of not only the activations in the\n",
|
||||
"input volume, but also of the parameters (the weights and biases of\n",
|
||||
"the neurons). On the other hand, the RELU/POOL layers will implement a\n",
|
||||
"fixed function. The parameters in the CONV/FC layers will be trained\n",
|
||||
"with gradient descent so that the class scores that the CNN computes\n",
|
||||
"are consistent with the labels in the training set for each image.\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"## CNNs in brief\n",
|
||||
"\n",
|
||||
"In summary:\n",
|
||||
"\n",
|
||||
"* A CNN architecture is in the simplest case a list of Layers that transform the image volume into an output volume (e.g. holding the class scores)\n",
|
||||
"\n",
|
||||
"* There are a few distinct types of Layers (e.g. CONV/FC/RELU/POOL are by far the most popular)\n",
|
||||
"\n",
|
||||
"* Each Layer accepts an input 3D volume and transforms it to an output 3D volume through a differentiable function\n",
|
||||
"\n",
|
||||
"* Each Layer may or may not have parameters (e.g. CONV/FC do, RELU/POOL don’t)\n",
|
||||
"\n",
|
||||
"* Each Layer may or may not have additional hyperparameters (e.g. CONV/FC/POOL do, RELU doesn’t)\n",
|
||||
"\n",
|
||||
"For more material on convolutional networks, we strongly recommend\n",
|
||||
"the course\n",
|
||||
"[IN5400 – Machine Learning for Image Analysis](https://www.uio.no/studier/emner/matnat/ifi/IN5400/index-eng.html)\n",
|
||||
"and the slides of [CS231](http://cs231n.github.io/convolutional-networks/) which is taught at Stanford University (consistently ranked as one of the top computer science programs in the world). [Michael Nielsen's book is a must read, in particular chapter 6 which deals with CNNs](http://neuralnetworksanddeeplearning.com/chap6.html).\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"## CNNs in more detail, building convolutional neural networks in Tensorflow and Keras\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"As discussed above, CNNs are neural networks built from the assumption that the inputs\n",
|
||||
"to the network are 2D images. This is important because the number of features or pixels in images\n",
|
||||
"grows very fast with the image size, and an enormous number of weights and biases are needed in order to build an accurate network. \n",
|
||||
"\n",
|
||||
"As before, we still have our input, a hidden layer and an output. What's novel about convolutional networks\n",
|
||||
"are the **convolutional** and **pooling** layers stacked in pairs between the input and the hidden layer.\n",
|
||||
"In addition, the data is no longer represented as a 2D feature matrix, instead each input is a number of 2D\n",
|
||||
"matrices, typically 1 for each color dimension (Red, Green, Blue). \n",
|
||||
"\n",
|
||||
"\n",
|
||||
"## Setting it up\n",
|
||||
"\n",
|
||||
"It means that to represent the entire\n",
|
||||
"dataset of images, we require a 4D matrix or **tensor**. This tensor has the dimensions:"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"$$\n",
|
||||
"(n_{inputs},\\, n_{pixels, width},\\, n_{pixels, height},\\, depth) .\n",
|
||||
"$$"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## The MNIST dataset again\n",
|
||||
"\n",
|
||||
"The MNIST dataset consists of grayscale images with a pixel size of\n",
|
||||
"$28\\times 28$, meaning we require $28 \\times 28 = 724$ weights to each\n",
|
||||
"neuron in the first hidden layer.\n",
|
||||
"\n",
|
||||
"If we were to analyze images of size $128\\times 128$ we would require\n",
|
||||
"$128 \\times 128 = 16384$ weights to each neuron. Even worse if we were\n",
|
||||
"dealing with color images, as most images are, we have an image matrix\n",
|
||||
"of size $128\\times 128$ for each color dimension (Red, Green, Blue),\n",
|
||||
"meaning 3 times the number of weights $= 49152$ are required for every\n",
|
||||
"single neuron in the first hidden layer.\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"## Strong correlations\n",
|
||||
"Images typically have strong local correlations, meaning that a small\n",
|
||||
"part of the image varies little from its neighboring regions. If for\n",
|
||||
"example we have an image of a blue car, we can roughly assume that a\n",
|
||||
"small blue part of the image is surrounded by other blue regions.\n",
|
||||
"\n",
|
||||
"Therefore, instead of connecting every single pixel to a neuron in the\n",
|
||||
"first hidden layer, as we have previously done with deep neural\n",
|
||||
"networks, we can instead connect each neuron to a small part of the\n",
|
||||
"image (in all 3 RGB depth dimensions). The size of each small area is\n",
|
||||
"fixed, and known as a [receptive](https://en.wikipedia.org/wiki/Receptive_field).\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"<!-- !split -->\n",
|
||||
"## Layers of a CNN\n",
|
||||
"The layers of a convolutional neural network arrange neurons in 3D: width, height and depth. \n",
|
||||
"The input image is typically a square matrix of depth 3. \n",
|
||||
"\n",
|
||||
"A **convolution** is performed on the image which outputs\n",
|
||||
"a 3D volume of neurons. The weights to the input are arranged in a number of 2D matrices, known as **filters**.\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"Each filter slides along the input image, taking the dot product\n",
|
||||
"between each small part of the image and the filter, in all depth\n",
|
||||
"dimensions. This is then passed through a non-linear function,\n",
|
||||
"typically the **Rectified Linear (ReLu)** function, which serves as the\n",
|
||||
"activation of the neurons in the first convolutional layer. This is\n",
|
||||
"further passed through a **pooling layer**, which reduces the size of the\n",
|
||||
"convolutional layer, e.g. by taking the maximum or average across some\n",
|
||||
"small regions, and this serves as input to the next convolutional\n",
|
||||
"layer.\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"## Systematic reduction\n",
|
||||
"\n",
|
||||
"By systematically reducing the size of the input volume, through\n",
|
||||
"convolution and pooling, the network should create representations of\n",
|
||||
"small parts of the input, and then from them assemble representations\n",
|
||||
"of larger areas. The final pooling layer is flattened to serve as\n",
|
||||
"input to a hidden layer, such that each neuron in the final pooling\n",
|
||||
"layer is connected to every single neuron in the hidden layer. This\n",
|
||||
"then serves as input to the output layer, e.g. a softmax output for\n",
|
||||
"classification.\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"## Prerequisites: Collect and pre-process data"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%matplotlib inline\n",
|
||||
"\n",
|
||||
"# import necessary packages\n",
|
||||
"import numpy as np\n",
|
||||
"import matplotlib.pyplot as plt\n",
|
||||
"from sklearn import datasets\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"# ensure the same random numbers appear every time\n",
|
||||
"np.random.seed(0)\n",
|
||||
"\n",
|
||||
"# display images in notebook\n",
|
||||
"%matplotlib inline\n",
|
||||
"plt.rcParams['figure.figsize'] = (12,12)\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"# download MNIST dataset\n",
|
||||
"digits = datasets.load_digits()\n",
|
||||
"\n",
|
||||
"# define inputs and labels\n",
|
||||
"inputs = digits.images\n",
|
||||
"labels = digits.target\n",
|
||||
"\n",
|
||||
"# RGB images have a depth of 3\n",
|
||||
"# our images are grayscale so they should have a depth of 1\n",
|
||||
"inputs = inputs[:,:,:,np.newaxis]\n",
|
||||
"\n",
|
||||
"print(\"inputs = (n_inputs, pixel_width, pixel_height, depth) = \" + str(inputs.shape))\n",
|
||||
"print(\"labels = (n_inputs) = \" + str(labels.shape))\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"# choose some random images to display\n",
|
||||
"n_inputs = len(inputs)\n",
|
||||
"indices = np.arange(n_inputs)\n",
|
||||
"random_indices = np.random.choice(indices, size=5)\n",
|
||||
"\n",
|
||||
"for i, image in enumerate(digits.images[random_indices]):\n",
|
||||
" plt.subplot(1, 5, i+1)\n",
|
||||
" plt.axis('off')\n",
|
||||
" plt.imshow(image, cmap=plt.cm.gray_r, interpolation='nearest')\n",
|
||||
" plt.title(\"Label: %d\" % digits.target[random_indices[i]])\n",
|
||||
"plt.show()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Importing Keras and Tensorflow"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from keras.utils import to_categorical\n",
|
||||
"from sklearn.model_selection import train_test_split\n",
|
||||
"\n",
|
||||
"# representation of labels\n",
|
||||
"labels = to_categorical(labels)\n",
|
||||
"\n",
|
||||
"# split into train and test data\n",
|
||||
"# one-liner from scikit-learn library\n",
|
||||
"train_size = 0.8\n",
|
||||
"test_size = 1 - train_size\n",
|
||||
"X_train, X_test, Y_train, Y_test = train_test_split(inputs, labels, train_size=train_size,\n",
|
||||
" test_size=test_size)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Using TensorFlow backend\n",
|
||||
"\n",
|
||||
"We need to define model and architecture and choose cost function and optmizer."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"\n",
|
||||
"import tensorflow as tf\n",
|
||||
"\n",
|
||||
"class ConvolutionalNeuralNetworkTensorflow:\n",
|
||||
" def __init__(\n",
|
||||
" self,\n",
|
||||
" X_train,\n",
|
||||
" Y_train,\n",
|
||||
" X_test,\n",
|
||||
" Y_test,\n",
|
||||
" n_filters=10,\n",
|
||||
" n_neurons_connected=50,\n",
|
||||
" n_categories=10,\n",
|
||||
" receptive_field=3,\n",
|
||||
" stride=1,\n",
|
||||
" padding=1,\n",
|
||||
" epochs=10,\n",
|
||||
" batch_size=100,\n",
|
||||
" eta=0.1,\n",
|
||||
" lmbd=0.0):\n",
|
||||
" \n",
|
||||
" self.global_step = tf.Variable(0, dtype=tf.int32, trainable=False, name='global_step')\n",
|
||||
" \n",
|
||||
" self.X_train = X_train\n",
|
||||
" self.Y_train = Y_train\n",
|
||||
" self.X_test = X_test\n",
|
||||
" self.Y_test = Y_test\n",
|
||||
" \n",
|
||||
" self.n_inputs, self.input_width, self.input_height, self.depth = X_train.shape\n",
|
||||
" \n",
|
||||
" self.n_filters = n_filters\n",
|
||||
" self.n_downsampled = int(self.input_width*self.input_height*n_filters / 4)\n",
|
||||
" self.n_neurons_connected = n_neurons_connected\n",
|
||||
" self.n_categories = n_categories\n",
|
||||
" \n",
|
||||
" self.receptive_field = receptive_field\n",
|
||||
" self.stride = stride\n",
|
||||
" self.strides = [stride, stride, stride, stride]\n",
|
||||
" self.padding = padding\n",
|
||||
" \n",
|
||||
" self.epochs = epochs\n",
|
||||
" self.batch_size = batch_size\n",
|
||||
" self.iterations = self.n_inputs // self.batch_size\n",
|
||||
" self.eta = eta\n",
|
||||
" self.lmbd = lmbd\n",
|
||||
" \n",
|
||||
" self.create_placeholders()\n",
|
||||
" self.create_CNN()\n",
|
||||
" self.create_loss()\n",
|
||||
" self.create_optimiser()\n",
|
||||
" self.create_accuracy()\n",
|
||||
" \n",
|
||||
" def create_placeholders(self):\n",
|
||||
" with tf.name_scope('data'):\n",
|
||||
" self.X = tf.placeholder(tf.float32, shape=(None, self.input_width, self.input_height, self.depth), name='X_data')\n",
|
||||
" self.Y = tf.placeholder(tf.float32, shape=(None, self.n_categories), name='Y_data')\n",
|
||||
" \n",
|
||||
" def create_CNN(self):\n",
|
||||
" with tf.name_scope('CNN'):\n",
|
||||
" \n",
|
||||
" # Convolutional layer\n",
|
||||
" self.W_conv = self.weight_variable([self.receptive_field, self.receptive_field, self.depth, self.n_filters], name='conv', dtype=tf.float32)\n",
|
||||
" b_conv = self.weight_variable([self.n_filters], name='conv', dtype=tf.float32)\n",
|
||||
" z_conv = tf.nn.conv2d(self.X, self.W_conv, self.strides, padding='SAME', name='conv') + b_conv\n",
|
||||
" a_conv = tf.nn.relu(z_conv)\n",
|
||||
" \n",
|
||||
" # 2x2 max pooling\n",
|
||||
" a_pool = tf.nn.max_pool(a_conv, [1, 2, 2, 1], [1, 2, 2, 1], padding='SAME', name='pool')\n",
|
||||
" \n",
|
||||
" # Fully connected layer\n",
|
||||
" a_pool_flat = tf.reshape(a_pool, [-1, self.n_downsampled])\n",
|
||||
" self.W_fc = self.weight_variable([self.n_downsampled, self.n_neurons_connected], name='fc', dtype=tf.float32)\n",
|
||||
" b_fc = self.bias_variable([self.n_neurons_connected], name='fc', dtype=tf.float32)\n",
|
||||
" a_fc = tf.nn.relu(tf.matmul(a_pool_flat, self.W_fc) + b_fc)\n",
|
||||
" \n",
|
||||
" # Output layer\n",
|
||||
" self.W_out = self.weight_variable([self.n_neurons_connected, self.n_categories], name='out', dtype=tf.float32)\n",
|
||||
" b_out = self.bias_variable([self.n_categories], name='out', dtype=tf.float32)\n",
|
||||
" self.z_out = tf.matmul(a_fc, self.W_out) + b_out\n",
|
||||
" \n",
|
||||
" def create_loss(self):\n",
|
||||
" with tf.name_scope('loss'):\n",
|
||||
" softmax_loss = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits_v2(labels=self.Y, logits=self.z_out))\n",
|
||||
" \n",
|
||||
" regularizer_loss_conv = tf.nn.l2_loss(self.W_conv)\n",
|
||||
" regularizer_loss_fc = tf.nn.l2_loss(self.W_fc)\n",
|
||||
" regularizer_loss_out = tf.nn.l2_loss(self.W_out)\n",
|
||||
" regularizer_loss = self.lmbd*(regularizer_loss_conv + regularizer_loss_fc + regularizer_loss_out)\n",
|
||||
" \n",
|
||||
" self.loss = softmax_loss + regularizer_loss\n",
|
||||
"\n",
|
||||
" def create_accuracy(self):\n",
|
||||
" with tf.name_scope('accuracy'):\n",
|
||||
" probabilities = tf.nn.softmax(self.z_out)\n",
|
||||
" predictions = tf.argmax(probabilities, 1)\n",
|
||||
" labels = tf.argmax(self.Y, 1)\n",
|
||||
" \n",
|
||||
" correct_predictions = tf.equal(predictions, labels)\n",
|
||||
" correct_predictions = tf.cast(correct_predictions, tf.float32)\n",
|
||||
" self.accuracy = tf.reduce_mean(correct_predictions)\n",
|
||||
" \n",
|
||||
" def create_optimiser(self):\n",
|
||||
" with tf.name_scope('optimizer'):\n",
|
||||
" self.optimizer = tf.train.GradientDescentOptimizer(learning_rate=self.eta).minimize(self.loss, global_step=self.global_step)\n",
|
||||
" \n",
|
||||
" def weight_variable(self, shape, name='', dtype=tf.float32):\n",
|
||||
" initial = tf.truncated_normal(shape, stddev=0.1)\n",
|
||||
" return tf.Variable(initial, name=name, dtype=dtype)\n",
|
||||
" \n",
|
||||
" def bias_variable(self, shape, name='', dtype=tf.float32):\n",
|
||||
" initial = tf.constant(0.1, shape=shape)\n",
|
||||
" return tf.Variable(initial, name=name, dtype=dtype)\n",
|
||||
"\n",
|
||||
" def fit(self):\n",
|
||||
" data_indices = np.arange(self.n_inputs)\n",
|
||||
"\n",
|
||||
" with tf.Session() as sess:\n",
|
||||
" sess.run(tf.global_variables_initializer())\n",
|
||||
" for i in range(self.epochs):\n",
|
||||
" for j in range(self.iterations):\n",
|
||||
" chosen_datapoints = np.random.choice(data_indices, size=self.batch_size, replace=False)\n",
|
||||
" batch_X, batch_Y = self.X_train[chosen_datapoints], self.Y_train[chosen_datapoints]\n",
|
||||
" \n",
|
||||
" sess.run([CNN.loss, CNN.optimizer],\n",
|
||||
" feed_dict={CNN.X: batch_X,\n",
|
||||
" CNN.Y: batch_Y})\n",
|
||||
" accuracy = sess.run(CNN.accuracy,\n",
|
||||
" feed_dict={CNN.X: batch_X,\n",
|
||||
" CNN.Y: batch_Y})\n",
|
||||
" step = sess.run(CNN.global_step)\n",
|
||||
" \n",
|
||||
" self.train_loss, self.train_accuracy = sess.run([CNN.loss, CNN.accuracy],\n",
|
||||
" feed_dict={CNN.X: self.X_train,\n",
|
||||
" CNN.Y: self.Y_train})\n",
|
||||
" \n",
|
||||
" self.test_loss, self.test_accuracy = sess.run([CNN.loss, CNN.accuracy],\n",
|
||||
" feed_dict={CNN.X: self.X_test,\n",
|
||||
" CNN.Y: self.Y_test})"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Train the model\n",
|
||||
"\n",
|
||||
"We need now to train the model, evaluate it and test its performance on test data, and eventually include hyperparameters."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"epochs = 100\n",
|
||||
"batch_size = 100\n",
|
||||
"n_filters = 10\n",
|
||||
"n_neurons_connected = 50\n",
|
||||
"n_categories = 10\n",
|
||||
"\n",
|
||||
"eta_vals = np.logspace(-5, 1, 7)\n",
|
||||
"lmbd_vals = np.logspace(-5, 1, 7)\n",
|
||||
"CNN_tf = np.zeros((len(eta_vals), len(lmbd_vals)), dtype=object)\n",
|
||||
" \n",
|
||||
"for i, eta in enumerate(eta_vals):\n",
|
||||
" for j, lmbd in enumerate(lmbd_vals):\n",
|
||||
" CNN = ConvolutionalNeuralNetworkTensorflow(X_train, Y_train, X_test, Y_test,\n",
|
||||
" n_filters=n_filters, n_neurons_connected=n_neurons_connected,\n",
|
||||
" n_categories=n_categories, epochs=epochs, batch_size=batch_size,\n",
|
||||
" eta=eta, lmbd=lmbd)\n",
|
||||
" CNN.fit()\n",
|
||||
" \n",
|
||||
" print(\"Learning rate = \", eta)\n",
|
||||
" print(\"Lambda = \", lmbd)\n",
|
||||
" print(\"Test accuracy: %.3f\" % CNN.test_accuracy)\n",
|
||||
" print()\n",
|
||||
" \n",
|
||||
" CNN_tf[i][j] = CNN"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Visualizing the results"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# visual representation of grid search\n",
|
||||
"# uses seaborn heatmap, could probably do this in matplotlib\n",
|
||||
"import seaborn as sns\n",
|
||||
"\n",
|
||||
"sns.set()\n",
|
||||
"\n",
|
||||
"train_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))\n",
|
||||
"test_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))\n",
|
||||
"\n",
|
||||
"for i in range(len(eta_vals)):\n",
|
||||
" for j in range(len(lmbd_vals)):\n",
|
||||
" CNN = CNN_tf[i][j]\n",
|
||||
"\n",
|
||||
" train_accuracy[i][j] = CNN.train_accuracy\n",
|
||||
" test_accuracy[i][j] = CNN.test_accuracy\n",
|
||||
"\n",
|
||||
" \n",
|
||||
"fig, ax = plt.subplots(figsize = (10, 10))\n",
|
||||
"sns.heatmap(train_accuracy, annot=True, ax=ax, cmap=\"viridis\")\n",
|
||||
"ax.set_title(\"Training Accuracy\")\n",
|
||||
"ax.set_ylabel(\"$\\eta$\")\n",
|
||||
"ax.set_xlabel(\"$\\lambda$\")\n",
|
||||
"plt.show()\n",
|
||||
"\n",
|
||||
"fig, ax = plt.subplots(figsize = (10, 10))\n",
|
||||
"sns.heatmap(test_accuracy, annot=True, ax=ax, cmap=\"viridis\")\n",
|
||||
"ax.set_title(\"Test Accuracy\")\n",
|
||||
"ax.set_ylabel(\"$\\eta$\")\n",
|
||||
"ax.set_xlabel(\"$\\lambda$\")\n",
|
||||
"plt.show()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"<!-- !split -->\n",
|
||||
"## Running with Keras"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from keras.models import Sequential\n",
|
||||
"from keras.layers.convolutional import Conv2D\n",
|
||||
"from keras.layers.convolutional import MaxPooling2D\n",
|
||||
"from keras.layers import Flatten\n",
|
||||
"from keras.layers import Dense\n",
|
||||
"from keras.regularizers import l2\n",
|
||||
"from keras.optimizers import SGD\n",
|
||||
"\n",
|
||||
"def create_convolutional_neural_network_keras(input_shape, receptive_field,\n",
|
||||
" n_filters, n_neurons_connected, n_categories,\n",
|
||||
" eta, lmbd):\n",
|
||||
" model = Sequential()\n",
|
||||
" model.add(Conv2D(n_filters, (receptive_field, receptive_field), input_shape=input_shape, padding='same',\n",
|
||||
" activation='relu', kernel_regularizer=l2(lmbd)))\n",
|
||||
" model.add(MaxPooling2D(pool_size=(2, 2)))\n",
|
||||
" model.add(Flatten())\n",
|
||||
" model.add(Dense(n_neurons_connected, activation='relu', kernel_regularizer=l2(lmbd)))\n",
|
||||
" model.add(Dense(n_categories, activation='softmax', kernel_regularizer=l2(lmbd)))\n",
|
||||
" \n",
|
||||
" sgd = SGD(lr=eta)\n",
|
||||
" model.compile(loss='categorical_crossentropy', optimizer=sgd, metrics=['accuracy'])\n",
|
||||
" \n",
|
||||
" return model\n",
|
||||
"\n",
|
||||
"epochs = 100\n",
|
||||
"batch_size = 100\n",
|
||||
"input_shape = X_train.shape[1:4]\n",
|
||||
"receptive_field = 3\n",
|
||||
"n_filters = 10\n",
|
||||
"n_neurons_connected = 50\n",
|
||||
"n_categories = 10\n",
|
||||
"\n",
|
||||
"eta_vals = np.logspace(-5, 1, 7)\n",
|
||||
"lmbd_vals = np.logspace(-5, 1, 7)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Final part"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"CNN_keras = np.zeros((len(eta_vals), len(lmbd_vals)), dtype=object)\n",
|
||||
" \n",
|
||||
"for i, eta in enumerate(eta_vals):\n",
|
||||
" for j, lmbd in enumerate(lmbd_vals):\n",
|
||||
" CNN = create_convolutional_neural_network_keras(input_shape, receptive_field,\n",
|
||||
" n_filters, n_neurons_connected, n_categories,\n",
|
||||
" eta, lmbd)\n",
|
||||
" CNN.fit(X_train, Y_train, epochs=epochs, batch_size=batch_size, verbose=0)\n",
|
||||
" scores = CNN.evaluate(X_test, Y_test)\n",
|
||||
" \n",
|
||||
" CNN_keras[i][j] = CNN\n",
|
||||
" \n",
|
||||
" print(\"Learning rate = \", eta)\n",
|
||||
" print(\"Lambda = \", lmbd)\n",
|
||||
" print(\"Test accuracy: %.3f\" % scores[1])\n",
|
||||
" print()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Final visualization"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
" # visual representation of grid search\n",
|
||||
" # uses seaborn heatmap, could probably do this in matplotlib\n",
|
||||
" import seaborn as sns\n",
|
||||
" \n",
|
||||
" sns.set()\n",
|
||||
" \n",
|
||||
" train_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))\n",
|
||||
" test_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))\n",
|
||||
" \n",
|
||||
" for i in range(len(eta_vals)):\n",
|
||||
" for j in range(len(lmbd_vals)):\n",
|
||||
" CNN = CNN_keras[i][j]\n",
|
||||
" \n",
|
||||
" train_accuracy[i][j] = CNN.evaluate(X_train, Y_train)[1]\n",
|
||||
" test_accuracy[i][j] = CNN.evaluate(X_test, Y_test)[1]\n",
|
||||
" \n",
|
||||
" \n",
|
||||
" fig, ax = plt.subplots(figsize = (10, 10))\n",
|
||||
" sns.heatmap(train_accuracy, annot=True, ax=ax, cmap=\"viridis\")\n",
|
||||
" ax.set_title(\"Training Accuracy\")\n",
|
||||
" ax.set_ylabel(\"$\\eta$\")\n",
|
||||
" ax.set_xlabel(\"$\\lambda$\")\n",
|
||||
" plt.show()\n",
|
||||
" \n",
|
||||
" fig, ax = plt.subplots(figsize = (10, 10))\n",
|
||||
" sns.heatmap(test_accuracy, annot=True, ax=ax, cmap=\"viridis\")\n",
|
||||
" ax.set_title(\"Test Accuracy\")\n",
|
||||
" ax.set_ylabel(\"$\\eta$\")\n",
|
||||
" ax.set_xlabel(\"$\\lambda$\")\n",
|
||||
" plt.show()\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Fun links\n",
|
||||
"\n",
|
||||
"1. [Self-Driving cars using a convolutional neural network](https://arxiv.org/abs/1604.07316)\n",
|
||||
"\n",
|
||||
"2. [Abstract art using convolutional neural networks](https://deepdreamgenerator.com/)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
||||
@@ -1,811 +0,0 @@
|
||||
%%
|
||||
%% Automatically generated file from DocOnce source
|
||||
%% (https://github.com/hplgit/doconce/)
|
||||
%%
|
||||
%%
|
||||
% #ifdef PTEX2TEX_EXPLANATION
|
||||
%%
|
||||
%% The file follows the ptex2tex extended LaTeX format, see
|
||||
%% ptex2tex: http://code.google.com/p/ptex2tex/
|
||||
%%
|
||||
%% Run
|
||||
%% ptex2tex myfile
|
||||
%% or
|
||||
%% doconce ptex2tex myfile
|
||||
%%
|
||||
%% to turn myfile.p.tex into an ordinary LaTeX file myfile.tex.
|
||||
%% (The ptex2tex program: http://code.google.com/p/ptex2tex)
|
||||
%% Many preprocess options can be added to ptex2tex or doconce ptex2tex
|
||||
%%
|
||||
%% ptex2tex -DMINTED myfile
|
||||
%% doconce ptex2tex myfile envir=minted
|
||||
%%
|
||||
%% ptex2tex will typeset code environments according to a global or local
|
||||
%% .ptex2tex.cfg configure file. doconce ptex2tex will typeset code
|
||||
%% according to options on the command line (just type doconce ptex2tex to
|
||||
%% see examples). If doconce ptex2tex has envir=minted, it enables the
|
||||
%% minted style without needing -DMINTED.
|
||||
% #endif
|
||||
|
||||
% #define PREAMBLE
|
||||
|
||||
% #ifdef PREAMBLE
|
||||
%-------------------- begin preamble ----------------------
|
||||
|
||||
\documentclass[%
|
||||
oneside, % oneside: electronic viewing, twoside: printing
|
||||
final, % draft: marks overfull hboxes, figures with paths
|
||||
10pt]{article}
|
||||
|
||||
\listfiles % print all files needed to compile this document
|
||||
|
||||
\usepackage{relsize,makeidx,color,setspace,amsmath,amsfonts,amssymb}
|
||||
\usepackage[table]{xcolor}
|
||||
\usepackage{bm,ltablex,microtype}
|
||||
|
||||
\usepackage[pdftex]{graphicx}
|
||||
|
||||
\usepackage{ptex2tex}
|
||||
% #ifdef MINTED
|
||||
\usepackage{minted}
|
||||
\usemintedstyle{default}
|
||||
% #endif
|
||||
|
||||
\usepackage[T1]{fontenc}
|
||||
%\usepackage[latin1]{inputenc}
|
||||
\usepackage{ucs}
|
||||
\usepackage[utf8x]{inputenc}
|
||||
|
||||
\usepackage{lmodern} % Latin Modern fonts derived from Computer Modern
|
||||
|
||||
% Hyperlinks in PDF:
|
||||
\definecolor{linkcolor}{rgb}{0,0,0.4}
|
||||
\usepackage{hyperref}
|
||||
\hypersetup{
|
||||
breaklinks=true,
|
||||
colorlinks=true,
|
||||
linkcolor=linkcolor,
|
||||
urlcolor=linkcolor,
|
||||
citecolor=black,
|
||||
filecolor=black,
|
||||
%filecolor=blue,
|
||||
pdfmenubar=true,
|
||||
pdftoolbar=true,
|
||||
bookmarksdepth=3 % Uncomment (and tweak) for PDF bookmarks with more levels than the TOC
|
||||
}
|
||||
%\hyperbaseurl{} % hyperlinks are relative to this root
|
||||
|
||||
\setcounter{tocdepth}{2} % levels in table of contents
|
||||
|
||||
% Tricks for having figures close to where they are defined:
|
||||
% 1. define less restrictive rules for where to put figures
|
||||
\setcounter{topnumber}{2}
|
||||
\setcounter{bottomnumber}{2}
|
||||
\setcounter{totalnumber}{4}
|
||||
\renewcommand{\topfraction}{0.95}
|
||||
\renewcommand{\bottomfraction}{0.95}
|
||||
\renewcommand{\textfraction}{0}
|
||||
\renewcommand{\floatpagefraction}{0.75}
|
||||
% floatpagefraction must always be less than topfraction!
|
||||
% 2. ensure all figures are flushed before next section
|
||||
\usepackage[section]{placeins}
|
||||
% 3. enable begin{figure}[H] (often leads to ugly pagebreaks)
|
||||
%\usepackage{float}\restylefloat{figure}
|
||||
|
||||
% --- fancyhdr package for fancy headers ---
|
||||
\usepackage{fancyhdr}
|
||||
\fancyhf{} % sets both header and footer to nothing
|
||||
\renewcommand{\headrulewidth}{0pt}
|
||||
\fancyfoot[LE,RO]{\thepage}
|
||||
% Ensure copyright on titlepage (article style) and chapter pages (book style)
|
||||
\fancypagestyle{plain}{
|
||||
\fancyhf{}
|
||||
\fancyfoot[C]{{\footnotesize \copyright\ 1999-2019, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license}}
|
||||
% \renewcommand{\footrulewidth}{0mm}
|
||||
\renewcommand{\headrulewidth}{0mm}
|
||||
}
|
||||
% Ensure copyright on titlepages with \thispagestyle{empty}
|
||||
\fancypagestyle{empty}{
|
||||
\fancyhf{}
|
||||
\fancyfoot[C]{{\footnotesize \copyright\ 1999-2019, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license}}
|
||||
\renewcommand{\footrulewidth}{0mm}
|
||||
\renewcommand{\headrulewidth}{0mm}
|
||||
}
|
||||
|
||||
\pagestyle{fancy}
|
||||
|
||||
|
||||
% prevent orhpans and widows
|
||||
\clubpenalty = 10000
|
||||
\widowpenalty = 10000
|
||||
|
||||
% --- end of standard preamble for documents ---
|
||||
|
||||
|
||||
% insert custom LaTeX commands...
|
||||
|
||||
\raggedbottom
|
||||
\makeindex
|
||||
\usepackage[totoc]{idxlayout} % for index in the toc
|
||||
\usepackage[nottoc]{tocbibind} % for references/bibliography in the toc
|
||||
|
||||
%-------------------- end preamble ----------------------
|
||||
|
||||
\begin{document}
|
||||
|
||||
% matching end for #ifdef PREAMBLE
|
||||
% #endif
|
||||
|
||||
\newcommand{\exercisesection}[1]{\subsection*{#1}}
|
||||
|
||||
|
||||
% ------------------- main content ----------------------
|
||||
|
||||
|
||||
|
||||
% ----------------- title -------------------------
|
||||
|
||||
\thispagestyle{empty}
|
||||
|
||||
\begin{center}
|
||||
{\LARGE\bf
|
||||
\begin{spacing}{1.25}
|
||||
Convolutional Neural Networks
|
||||
\end{spacing}
|
||||
}
|
||||
\end{center}
|
||||
|
||||
% ----------------- author(s) -------------------------
|
||||
|
||||
\begin{center}
|
||||
{\bf Morten Hjorth-Jensen${}^{1, 2}$} \\ [0mm]
|
||||
\end{center}
|
||||
|
||||
\begin{center}
|
||||
% List of all institutions:
|
||||
\centerline{{\small ${}^1$Department of Physics, University of Oslo}}
|
||||
\centerline{{\small ${}^2$Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University}}
|
||||
\end{center}
|
||||
|
||||
% ----------------- end author(s) -------------------------
|
||||
|
||||
% --- begin date ---
|
||||
\begin{center}
|
||||
Oct 3, 2019
|
||||
\end{center}
|
||||
% --- end date ---
|
||||
|
||||
\vspace{1cm}
|
||||
|
||||
|
||||
% !split
|
||||
\subsection{Convolutional Neural Networks (recognizing images)}
|
||||
|
||||
Convolutional Neural Networks (CNN) are very similar to ordinary Neural Networks.
|
||||
|
||||
They are made up of neurons that have learnable weights and
|
||||
biases. Each neuron receives some inputs, performs a dot product and
|
||||
optionally follows it with a non-linearity. The whole network still
|
||||
expresses a single differentiable score function: from the raw image
|
||||
pixels on one end to class scores at the other. And they still have a
|
||||
loss function (for example Softmax) on the last (fully-connected) layer
|
||||
and all the tips/tricks we developed for learning regular Neural
|
||||
Networks still apply (back propagation, gradient descent etc etc).
|
||||
|
||||
What is the difference? \textbf{CNN architectures make the explicit assumption that
|
||||
the inputs are images, which allows us to encode certain properties
|
||||
into the architecture. These then make the forward function more
|
||||
efficient to implement and vastly reduce the amount of parameters in
|
||||
the network.}
|
||||
|
||||
Here we provide only a superficial overview, for the more interested, we recommend highly the course
|
||||
\href{{https://www.uio.no/studier/emner/matnat/ifi/IN5400/index-eng.html}}{IN5400 – Machine Learning for Image Analysis}
|
||||
and the slides of \href{{http://cs231n.github.io/convolutional-networks/}}{CS231}.
|
||||
|
||||
% !split
|
||||
\subsection{Regular NNs don’t scale well to full images}
|
||||
|
||||
As an example, consider
|
||||
an image of size $32\times 32\times 3$ (32 wide, 32 high, 3 color channels), so a
|
||||
single fully-connected neuron in a first hidden layer of a regular
|
||||
Neural Network would have $32\times 32\times 3 = 3072$ weights. This amount still
|
||||
seems manageable, but clearly this fully-connected structure does not
|
||||
scale to larger images. For example, an image of more respectable
|
||||
size, say $200\times 200\times 3$, would lead to neurons that have
|
||||
$200\times 200\times 3 = 120,000$ weights.
|
||||
|
||||
We could have
|
||||
several such neurons, and the parameters would add up quickly! Clearly,
|
||||
this full connectivity is wasteful and the huge number of parameters
|
||||
would quickly lead to possible overfitting.
|
||||
|
||||
|
||||
\begin{figure}[!ht] %
|
||||
\centerline{\includegraphics[width=0.6\linewidth]{figslides/nn.jpeg}}
|
||||
\caption{
|
||||
A regular 3-layer Neural Network.
|
||||
}
|
||||
\end{figure}
|
||||
%\clearpage % flush figures
|
||||
|
||||
|
||||
% !split
|
||||
\subsection{3D volumes of neurons}
|
||||
|
||||
Convolutional Neural Networks take advantage of the fact that the
|
||||
input consists of images and they constrain the architecture in a more
|
||||
sensible way.
|
||||
|
||||
In particular, unlike a regular Neural Network, the
|
||||
layers of a CNN have neurons arranged in 3 dimensions: width,
|
||||
height, depth. (Note that the word depth here refers to the third
|
||||
dimension of an activation volume, not to the depth of a full Neural
|
||||
Network, which can refer to the total number of layers in a network.)
|
||||
|
||||
To understand it better, the above example of an image
|
||||
with an input volume of
|
||||
activations has dimensions $32\times 32\times 3$ (width, height,
|
||||
depth respectively).
|
||||
|
||||
The neurons in a layer will
|
||||
only be connected to a small region of the layer before it, instead of
|
||||
all of the neurons in a fully-connected manner. Moreover, the final
|
||||
output layer could for this specific image have dimensions $1\times 1 \times 10$,
|
||||
because by the
|
||||
end of the CNN architecture we will reduce the full image into a
|
||||
single vector of class scores, arranged along the depth
|
||||
dimension.
|
||||
|
||||
|
||||
\begin{figure}[!ht] %
|
||||
\centerline{\includegraphics[width=0.6\linewidth]{figslides/cnn.jpeg}}
|
||||
\caption{
|
||||
A CNN arranges its neurons in three dimensions (width, height, depth), as visualized in one of the layers. Every layer of a CNN transforms the 3D input volume to a 3D output volume of neuron activations. In this example, the red input layer holds the image, so its width and height would be the dimensions of the image, and the depth would be 3 (Red, Green, Blue channels).
|
||||
}
|
||||
\end{figure}
|
||||
%\clearpage % flush figures
|
||||
|
||||
|
||||
|
||||
|
||||
% !split
|
||||
\subsection{Layers used to build CNNs}
|
||||
|
||||
|
||||
A simple CNN is a sequence of layers, and every layer of a CNN
|
||||
transforms one volume of activations to another through a
|
||||
differentiable function. We use three main types of layers to build
|
||||
CNN architectures: Convolutional Layer, Pooling Layer, and
|
||||
Fully-Connected Layer (exactly as seen in regular Neural Networks). We
|
||||
will stack these layers to form a full CNN architecture.
|
||||
|
||||
A simple CNN for image classification could have the architecture:
|
||||
|
||||
\begin{itemize}
|
||||
\item \textbf{INPUT} ($32\times 32 \times 3$) will hold the raw pixel values of the image, in this case an image of width 32, height 32, and with three color channels R,G,B.
|
||||
|
||||
\item \textbf{CONV} (convolutional )layer will compute the output of neurons that are connected to local regions in the input, each computing a dot product between their weights and a small region they are connected to in the input volume. This may result in volume such as $[32\times 32\times 12]$ if we decided to use 12 filters.
|
||||
|
||||
\item \textbf{RELU} layer will apply an elementwise activation function, such as the $max(0,x)$ thresholding at zero. This leaves the size of the volume unchanged ($[32\times 32\times 12]$).
|
||||
|
||||
\item \textbf{POOL} (pooling) layer will perform a downsampling operation along the spatial dimensions (width, height), resulting in volume such as $[16\times 16\times 12]$.
|
||||
|
||||
\item \textbf{FC} (i.e.~fully-connected) layer will compute the class scores, resulting in volume of size $[1\times 1\times 10]$, where each of the 10 numbers correspond to a class score, such as among the 10 categories of the MNIST images we considered above . As with ordinary Neural Networks and as the name implies, each neuron in this layer will be connected to all the numbers in the previous volume.
|
||||
\end{itemize}
|
||||
|
||||
\noindent
|
||||
% !split
|
||||
\subsection{Transforming images}
|
||||
|
||||
CNNs transform the original image layer by layer from the original
|
||||
pixel values to the final class scores.
|
||||
|
||||
Observe that some layers contain
|
||||
parameters and other don’t. In particular, the CNN layers perform
|
||||
transformations that are a function of not only the activations in the
|
||||
input volume, but also of the parameters (the weights and biases of
|
||||
the neurons). On the other hand, the RELU/POOL layers will implement a
|
||||
fixed function. The parameters in the CONV/FC layers will be trained
|
||||
with gradient descent so that the class scores that the CNN computes
|
||||
are consistent with the labels in the training set for each image.
|
||||
|
||||
|
||||
% !split
|
||||
\subsection{CNNs in brief}
|
||||
|
||||
In summary:
|
||||
|
||||
\begin{itemize}
|
||||
\item A CNN architecture is in the simplest case a list of Layers that transform the image volume into an output volume (e.g.~holding the class scores)
|
||||
|
||||
\item There are a few distinct types of Layers (e.g.~CONV/FC/RELU/POOL are by far the most popular)
|
||||
|
||||
\item Each Layer accepts an input 3D volume and transforms it to an output 3D volume through a differentiable function
|
||||
|
||||
\item Each Layer may or may not have parameters (e.g.~CONV/FC do, RELU/POOL don’t)
|
||||
|
||||
\item Each Layer may or may not have additional hyperparameters (e.g.~CONV/FC/POOL do, RELU doesn’t)
|
||||
\end{itemize}
|
||||
|
||||
\noindent
|
||||
For more material on convolutional networks, we strongly recommend
|
||||
the course
|
||||
\href{{https://www.uio.no/studier/emner/matnat/ifi/IN5400/index-eng.html}}{IN5400 – Machine Learning for Image Analysis}
|
||||
and the slides of \href{{http://cs231n.github.io/convolutional-networks/}}{CS231} which is taught at Stanford University (consistently ranked as one of the top computer science programs in the world). \href{{http://neuralnetworksanddeeplearning.com/chap6.html}}{Michael Nielsen's book is a must read, in particular chapter 6 which deals with CNNs}.
|
||||
|
||||
|
||||
% !split
|
||||
\subsection{CNNs in more detail, building convolutional neural networks in Tensorflow and Keras}
|
||||
|
||||
|
||||
As discussed above, CNNs are neural networks built from the assumption that the inputs
|
||||
to the network are 2D images. This is important because the number of features or pixels in images
|
||||
grows very fast with the image size, and an enormous number of weights and biases are needed in order to build an accurate network.
|
||||
|
||||
As before, we still have our input, a hidden layer and an output. What's novel about convolutional networks
|
||||
are the \textbf{convolutional} and \textbf{pooling} layers stacked in pairs between the input and the hidden layer.
|
||||
In addition, the data is no longer represented as a 2D feature matrix, instead each input is a number of 2D
|
||||
matrices, typically 1 for each color dimension (Red, Green, Blue).
|
||||
|
||||
|
||||
% !split
|
||||
\subsection{Setting it up}
|
||||
|
||||
It means that to represent the entire
|
||||
dataset of images, we require a 4D matrix or \textbf{tensor}. This tensor has the dimensions:
|
||||
\[
|
||||
(n_{inputs},\, n_{pixels, width},\, n_{pixels, height},\, depth) .
|
||||
\]
|
||||
|
||||
% !split
|
||||
\subsection{The MNIST dataset again}
|
||||
|
||||
The MNIST dataset consists of grayscale images with a pixel size of
|
||||
$28\times 28$, meaning we require $28 \times 28 = 724$ weights to each
|
||||
neuron in the first hidden layer.
|
||||
|
||||
If we were to analyze images of size $128\times 128$ we would require
|
||||
$128 \times 128 = 16384$ weights to each neuron. Even worse if we were
|
||||
dealing with color images, as most images are, we have an image matrix
|
||||
of size $128\times 128$ for each color dimension (Red, Green, Blue),
|
||||
meaning 3 times the number of weights $= 49152$ are required for every
|
||||
single neuron in the first hidden layer.
|
||||
|
||||
|
||||
% !split
|
||||
\subsection{Strong correlations}
|
||||
Images typically have strong local correlations, meaning that a small
|
||||
part of the image varies little from its neighboring regions. If for
|
||||
example we have an image of a blue car, we can roughly assume that a
|
||||
small blue part of the image is surrounded by other blue regions.
|
||||
|
||||
Therefore, instead of connecting every single pixel to a neuron in the
|
||||
first hidden layer, as we have previously done with deep neural
|
||||
networks, we can instead connect each neuron to a small part of the
|
||||
image (in all 3 RGB depth dimensions). The size of each small area is
|
||||
fixed, and known as a \href{{https://en.wikipedia.org/wiki/Receptive_field}}{receptive}.
|
||||
|
||||
|
||||
% !split
|
||||
\subsection{Layers of a CNN}
|
||||
The layers of a convolutional neural network arrange neurons in 3D: width, height and depth.
|
||||
The input image is typically a square matrix of depth 3.
|
||||
|
||||
A \textbf{convolution} is performed on the image which outputs
|
||||
a 3D volume of neurons. The weights to the input are arranged in a number of 2D matrices, known as \textbf{filters}.
|
||||
|
||||
|
||||
Each filter slides along the input image, taking the dot product
|
||||
between each small part of the image and the filter, in all depth
|
||||
dimensions. This is then passed through a non-linear function,
|
||||
typically the \textbf{Rectified Linear (ReLu)} function, which serves as the
|
||||
activation of the neurons in the first convolutional layer. This is
|
||||
further passed through a \textbf{pooling layer}, which reduces the size of the
|
||||
convolutional layer, e.g.~by taking the maximum or average across some
|
||||
small regions, and this serves as input to the next convolutional
|
||||
layer.
|
||||
|
||||
|
||||
% !split
|
||||
\subsection{Systematic reduction}
|
||||
|
||||
By systematically reducing the size of the input volume, through
|
||||
convolution and pooling, the network should create representations of
|
||||
small parts of the input, and then from them assemble representations
|
||||
of larger areas. The final pooling layer is flattened to serve as
|
||||
input to a hidden layer, such that each neuron in the final pooling
|
||||
layer is connected to every single neuron in the hidden layer. This
|
||||
then serves as input to the output layer, e.g.~a softmax output for
|
||||
classification.
|
||||
|
||||
|
||||
% !split
|
||||
\subsection{Prerequisites: Collect and pre-process data}
|
||||
\bpycod
|
||||
# import necessary packages
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
from sklearn import datasets
|
||||
|
||||
|
||||
# ensure the same random numbers appear every time
|
||||
np.random.seed(0)
|
||||
|
||||
# display images in notebook
|
||||
%matplotlib inline
|
||||
plt.rcParams['figure.figsize'] = (12,12)
|
||||
|
||||
|
||||
# download MNIST dataset
|
||||
digits = datasets.load_digits()
|
||||
|
||||
# define inputs and labels
|
||||
inputs = digits.images
|
||||
labels = digits.target
|
||||
|
||||
# RGB images have a depth of 3
|
||||
# our images are grayscale so they should have a depth of 1
|
||||
inputs = inputs[:,:,:,np.newaxis]
|
||||
|
||||
print("inputs = (n_inputs, pixel_width, pixel_height, depth) = " + str(inputs.shape))
|
||||
print("labels = (n_inputs) = " + str(labels.shape))
|
||||
|
||||
|
||||
# choose some random images to display
|
||||
n_inputs = len(inputs)
|
||||
indices = np.arange(n_inputs)
|
||||
random_indices = np.random.choice(indices, size=5)
|
||||
|
||||
for i, image in enumerate(digits.images[random_indices]):
|
||||
plt.subplot(1, 5, i+1)
|
||||
plt.axis('off')
|
||||
plt.imshow(image, cmap=plt.cm.gray_r, interpolation='nearest')
|
||||
plt.title("Label: %d" % digits.target[random_indices[i]])
|
||||
plt.show()
|
||||
\epycod
|
||||
|
||||
|
||||
% !split
|
||||
\subsection{Importing Keras and Tensorflow}
|
||||
\bpycod
|
||||
from keras.utils import to_categorical
|
||||
from sklearn.model_selection import train_test_split
|
||||
|
||||
# representation of labels
|
||||
labels = to_categorical(labels)
|
||||
|
||||
# split into train and test data
|
||||
# one-liner from scikit-learn library
|
||||
train_size = 0.8
|
||||
test_size = 1 - train_size
|
||||
X_train, X_test, Y_train, Y_test = train_test_split(inputs, labels, train_size=train_size,
|
||||
test_size=test_size)
|
||||
\epycod
|
||||
|
||||
% !split
|
||||
\subsection{Using TensorFlow backend}
|
||||
|
||||
We need to define model and architecture and choose cost function and optmizer.
|
||||
\bpycid
|
||||
|
||||
import tensorflow as tf
|
||||
|
||||
class ConvolutionalNeuralNetworkTensorflow:
|
||||
def __init__(
|
||||
self,
|
||||
X_train,
|
||||
Y_train,
|
||||
X_test,
|
||||
Y_test,
|
||||
n_filters=10,
|
||||
n_neurons_connected=50,
|
||||
n_categories=10,
|
||||
receptive_field=3,
|
||||
stride=1,
|
||||
padding=1,
|
||||
epochs=10,
|
||||
batch_size=100,
|
||||
eta=0.1,
|
||||
lmbd=0.0):
|
||||
|
||||
self.global_step = tf.Variable(0, dtype=tf.int32, trainable=False, name='global_step')
|
||||
|
||||
self.X_train = X_train
|
||||
self.Y_train = Y_train
|
||||
self.X_test = X_test
|
||||
self.Y_test = Y_test
|
||||
|
||||
self.n_inputs, self.input_width, self.input_height, self.depth = X_train.shape
|
||||
|
||||
self.n_filters = n_filters
|
||||
self.n_downsampled = int(self.input_width*self.input_height*n_filters / 4)
|
||||
self.n_neurons_connected = n_neurons_connected
|
||||
self.n_categories = n_categories
|
||||
|
||||
self.receptive_field = receptive_field
|
||||
self.stride = stride
|
||||
self.strides = [stride, stride, stride, stride]
|
||||
self.padding = padding
|
||||
|
||||
self.epochs = epochs
|
||||
self.batch_size = batch_size
|
||||
self.iterations = self.n_inputs // self.batch_size
|
||||
self.eta = eta
|
||||
self.lmbd = lmbd
|
||||
|
||||
self.create_placeholders()
|
||||
self.create_CNN()
|
||||
self.create_loss()
|
||||
self.create_optimiser()
|
||||
self.create_accuracy()
|
||||
|
||||
def create_placeholders(self):
|
||||
with tf.name_scope('data'):
|
||||
self.X = tf.placeholder(tf.float32, shape=(None, self.input_width, self.input_height, self.depth), name='X_data')
|
||||
self.Y = tf.placeholder(tf.float32, shape=(None, self.n_categories), name='Y_data')
|
||||
|
||||
def create_CNN(self):
|
||||
with tf.name_scope('CNN'):
|
||||
|
||||
# Convolutional layer
|
||||
self.W_conv = self.weight_variable([self.receptive_field, self.receptive_field, self.depth, self.n_filters], name='conv', dtype=tf.float32)
|
||||
b_conv = self.weight_variable([self.n_filters], name='conv', dtype=tf.float32)
|
||||
z_conv = tf.nn.conv2d(self.X, self.W_conv, self.strides, padding='SAME', name='conv') + b_conv
|
||||
a_conv = tf.nn.relu(z_conv)
|
||||
|
||||
# 2x2 max pooling
|
||||
a_pool = tf.nn.max_pool(a_conv, [1, 2, 2, 1], [1, 2, 2, 1], padding='SAME', name='pool')
|
||||
|
||||
# Fully connected layer
|
||||
a_pool_flat = tf.reshape(a_pool, [-1, self.n_downsampled])
|
||||
self.W_fc = self.weight_variable([self.n_downsampled, self.n_neurons_connected], name='fc', dtype=tf.float32)
|
||||
b_fc = self.bias_variable([self.n_neurons_connected], name='fc', dtype=tf.float32)
|
||||
a_fc = tf.nn.relu(tf.matmul(a_pool_flat, self.W_fc) + b_fc)
|
||||
|
||||
# Output layer
|
||||
self.W_out = self.weight_variable([self.n_neurons_connected, self.n_categories], name='out', dtype=tf.float32)
|
||||
b_out = self.bias_variable([self.n_categories], name='out', dtype=tf.float32)
|
||||
self.z_out = tf.matmul(a_fc, self.W_out) + b_out
|
||||
|
||||
def create_loss(self):
|
||||
with tf.name_scope('loss'):
|
||||
softmax_loss = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits_v2(labels=self.Y, logits=self.z_out))
|
||||
|
||||
regularizer_loss_conv = tf.nn.l2_loss(self.W_conv)
|
||||
regularizer_loss_fc = tf.nn.l2_loss(self.W_fc)
|
||||
regularizer_loss_out = tf.nn.l2_loss(self.W_out)
|
||||
regularizer_loss = self.lmbd*(regularizer_loss_conv + regularizer_loss_fc + regularizer_loss_out)
|
||||
|
||||
self.loss = softmax_loss + regularizer_loss
|
||||
|
||||
def create_accuracy(self):
|
||||
with tf.name_scope('accuracy'):
|
||||
probabilities = tf.nn.softmax(self.z_out)
|
||||
predictions = tf.argmax(probabilities, 1)
|
||||
labels = tf.argmax(self.Y, 1)
|
||||
|
||||
correct_predictions = tf.equal(predictions, labels)
|
||||
correct_predictions = tf.cast(correct_predictions, tf.float32)
|
||||
self.accuracy = tf.reduce_mean(correct_predictions)
|
||||
|
||||
def create_optimiser(self):
|
||||
with tf.name_scope('optimizer'):
|
||||
self.optimizer = tf.train.GradientDescentOptimizer(learning_rate=self.eta).minimize(self.loss, global_step=self.global_step)
|
||||
|
||||
def weight_variable(self, shape, name='', dtype=tf.float32):
|
||||
initial = tf.truncated_normal(shape, stddev=0.1)
|
||||
return tf.Variable(initial, name=name, dtype=dtype)
|
||||
|
||||
def bias_variable(self, shape, name='', dtype=tf.float32):
|
||||
initial = tf.constant(0.1, shape=shape)
|
||||
return tf.Variable(initial, name=name, dtype=dtype)
|
||||
|
||||
def fit(self):
|
||||
data_indices = np.arange(self.n_inputs)
|
||||
|
||||
with tf.Session() as sess:
|
||||
sess.run(tf.global_variables_initializer())
|
||||
for i in range(self.epochs):
|
||||
for j in range(self.iterations):
|
||||
chosen_datapoints = np.random.choice(data_indices, size=self.batch_size, replace=False)
|
||||
batch_X, batch_Y = self.X_train[chosen_datapoints], self.Y_train[chosen_datapoints]
|
||||
|
||||
sess.run([CNN.loss, CNN.optimizer],
|
||||
feed_dict={CNN.X: batch_X,
|
||||
CNN.Y: batch_Y})
|
||||
accuracy = sess.run(CNN.accuracy,
|
||||
feed_dict={CNN.X: batch_X,
|
||||
CNN.Y: batch_Y})
|
||||
step = sess.run(CNN.global_step)
|
||||
|
||||
self.train_loss, self.train_accuracy = sess.run([CNN.loss, CNN.accuracy],
|
||||
feed_dict={CNN.X: self.X_train,
|
||||
CNN.Y: self.Y_train})
|
||||
|
||||
self.test_loss, self.test_accuracy = sess.run([CNN.loss, CNN.accuracy],
|
||||
feed_dict={CNN.X: self.X_test,
|
||||
CNN.Y: self.Y_test})
|
||||
\epycid
|
||||
|
||||
% !split
|
||||
\subsection{Train the model}
|
||||
|
||||
We need now to train the model, evaluate it and test its performance on test data, and eventually include hyperparameters.
|
||||
\bpycod
|
||||
epochs = 100
|
||||
batch_size = 100
|
||||
n_filters = 10
|
||||
n_neurons_connected = 50
|
||||
n_categories = 10
|
||||
|
||||
eta_vals = np.logspace(-5, 1, 7)
|
||||
lmbd_vals = np.logspace(-5, 1, 7)
|
||||
CNN_tf = np.zeros((len(eta_vals), len(lmbd_vals)), dtype=object)
|
||||
|
||||
for i, eta in enumerate(eta_vals):
|
||||
for j, lmbd in enumerate(lmbd_vals):
|
||||
CNN = ConvolutionalNeuralNetworkTensorflow(X_train, Y_train, X_test, Y_test,
|
||||
n_filters=n_filters, n_neurons_connected=n_neurons_connected,
|
||||
n_categories=n_categories, epochs=epochs, batch_size=batch_size,
|
||||
eta=eta, lmbd=lmbd)
|
||||
CNN.fit()
|
||||
|
||||
print("Learning rate = ", eta)
|
||||
print("Lambda = ", lmbd)
|
||||
print("Test accuracy: %.3f" % CNN.test_accuracy)
|
||||
print()
|
||||
|
||||
CNN_tf[i][j] = CNN
|
||||
\epycod
|
||||
|
||||
% !split
|
||||
\subsection{Visualizing the results}
|
||||
|
||||
\bpycod
|
||||
# visual representation of grid search
|
||||
# uses seaborn heatmap, could probably do this in matplotlib
|
||||
import seaborn as sns
|
||||
|
||||
sns.set()
|
||||
|
||||
train_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))
|
||||
test_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))
|
||||
|
||||
for i in range(len(eta_vals)):
|
||||
for j in range(len(lmbd_vals)):
|
||||
CNN = CNN_tf[i][j]
|
||||
|
||||
train_accuracy[i][j] = CNN.train_accuracy
|
||||
test_accuracy[i][j] = CNN.test_accuracy
|
||||
|
||||
|
||||
fig, ax = plt.subplots(figsize = (10, 10))
|
||||
sns.heatmap(train_accuracy, annot=True, ax=ax, cmap="viridis")
|
||||
ax.set_title("Training Accuracy")
|
||||
ax.set_ylabel("$\eta$")
|
||||
ax.set_xlabel("$\lambda$")
|
||||
plt.show()
|
||||
|
||||
fig, ax = plt.subplots(figsize = (10, 10))
|
||||
sns.heatmap(test_accuracy, annot=True, ax=ax, cmap="viridis")
|
||||
ax.set_title("Test Accuracy")
|
||||
ax.set_ylabel("$\eta$")
|
||||
ax.set_xlabel("$\lambda$")
|
||||
plt.show()
|
||||
\epycod
|
||||
|
||||
% !split
|
||||
\subsection{Running with Keras}
|
||||
|
||||
\bpycod
|
||||
from keras.models import Sequential
|
||||
from keras.layers.convolutional import Conv2D
|
||||
from keras.layers.convolutional import MaxPooling2D
|
||||
from keras.layers import Flatten
|
||||
from keras.layers import Dense
|
||||
from keras.regularizers import l2
|
||||
from keras.optimizers import SGD
|
||||
|
||||
def create_convolutional_neural_network_keras(input_shape, receptive_field,
|
||||
n_filters, n_neurons_connected, n_categories,
|
||||
eta, lmbd):
|
||||
model = Sequential()
|
||||
model.add(Conv2D(n_filters, (receptive_field, receptive_field), input_shape=input_shape, padding='same',
|
||||
activation='relu', kernel_regularizer=l2(lmbd)))
|
||||
model.add(MaxPooling2D(pool_size=(2, 2)))
|
||||
model.add(Flatten())
|
||||
model.add(Dense(n_neurons_connected, activation='relu', kernel_regularizer=l2(lmbd)))
|
||||
model.add(Dense(n_categories, activation='softmax', kernel_regularizer=l2(lmbd)))
|
||||
|
||||
sgd = SGD(lr=eta)
|
||||
model.compile(loss='categorical_crossentropy', optimizer=sgd, metrics=['accuracy'])
|
||||
|
||||
return model
|
||||
|
||||
epochs = 100
|
||||
batch_size = 100
|
||||
input_shape = X_train.shape[1:4]
|
||||
receptive_field = 3
|
||||
n_filters = 10
|
||||
n_neurons_connected = 50
|
||||
n_categories = 10
|
||||
|
||||
eta_vals = np.logspace(-5, 1, 7)
|
||||
lmbd_vals = np.logspace(-5, 1, 7)
|
||||
\epycod
|
||||
|
||||
% !split
|
||||
\subsection{Final part}
|
||||
|
||||
\bpycod
|
||||
CNN_keras = np.zeros((len(eta_vals), len(lmbd_vals)), dtype=object)
|
||||
|
||||
for i, eta in enumerate(eta_vals):
|
||||
for j, lmbd in enumerate(lmbd_vals):
|
||||
CNN = create_convolutional_neural_network_keras(input_shape, receptive_field,
|
||||
n_filters, n_neurons_connected, n_categories,
|
||||
eta, lmbd)
|
||||
CNN.fit(X_train, Y_train, epochs=epochs, batch_size=batch_size, verbose=0)
|
||||
scores = CNN.evaluate(X_test, Y_test)
|
||||
|
||||
CNN_keras[i][j] = CNN
|
||||
|
||||
print("Learning rate = ", eta)
|
||||
print("Lambda = ", lmbd)
|
||||
print("Test accuracy: %.3f" % scores[1])
|
||||
print()
|
||||
\epycod
|
||||
|
||||
% !split
|
||||
\subsection{Final visualization}
|
||||
|
||||
\bccq
|
||||
# visual representation of grid search
|
||||
# uses seaborn heatmap, could probably do this in matplotlib
|
||||
import seaborn as sns
|
||||
|
||||
sns.set()
|
||||
|
||||
train_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))
|
||||
test_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))
|
||||
|
||||
for i in range(len(eta_vals)):
|
||||
for j in range(len(lmbd_vals)):
|
||||
CNN = CNN_keras[i][j]
|
||||
|
||||
train_accuracy[i][j] = CNN.evaluate(X_train, Y_train)[1]
|
||||
test_accuracy[i][j] = CNN.evaluate(X_test, Y_test)[1]
|
||||
|
||||
|
||||
fig, ax = plt.subplots(figsize = (10, 10))
|
||||
sns.heatmap(train_accuracy, annot=True, ax=ax, cmap="viridis")
|
||||
ax.set_title("Training Accuracy")
|
||||
ax.set_ylabel("$\eta$")
|
||||
ax.set_xlabel("$\lambda$")
|
||||
plt.show()
|
||||
|
||||
fig, ax = plt.subplots(figsize = (10, 10))
|
||||
sns.heatmap(test_accuracy, annot=True, ax=ax, cmap="viridis")
|
||||
ax.set_title("Test Accuracy")
|
||||
ax.set_ylabel("$\eta$")
|
||||
ax.set_xlabel("$\lambda$")
|
||||
plt.show()
|
||||
\eccq
|
||||
|
||||
% !split
|
||||
\subsection{Fun links}
|
||||
|
||||
\begin{enumerate}
|
||||
\item \href{{https://arxiv.org/abs/1604.07316}}{Self-Driving cars using a convolutional neural network}
|
||||
|
||||
\item \href{{https://deepdreamgenerator.com/}}{Abstract art using convolutional neural networks}
|
||||
\end{enumerate}
|
||||
|
||||
\noindent
|
||||
|
||||
% ------------------- end of main content ---------------
|
||||
|
||||
% #ifdef PREAMBLE
|
||||
\end{document}
|
||||
% #endif
|
||||
|
||||
@@ -1,781 +0,0 @@
|
||||
%%
|
||||
%% Automatically generated file from DocOnce source
|
||||
%% (https://github.com/hplgit/doconce/)
|
||||
%%
|
||||
%%
|
||||
|
||||
|
||||
%-------------------- begin preamble ----------------------
|
||||
|
||||
\documentclass[%
|
||||
oneside, % oneside: electronic viewing, twoside: printing
|
||||
final, % draft: marks overfull hboxes, figures with paths
|
||||
10pt]{article}
|
||||
|
||||
\listfiles % print all files needed to compile this document
|
||||
|
||||
\usepackage{relsize,makeidx,color,setspace,amsmath,amsfonts,amssymb}
|
||||
\usepackage[table]{xcolor}
|
||||
\usepackage{bm,ltablex,microtype}
|
||||
|
||||
\usepackage[pdftex]{graphicx}
|
||||
|
||||
\usepackage{fancyvrb} % packages needed for verbatim environments
|
||||
\usepackage{minted}
|
||||
\usemintedstyle{default}
|
||||
|
||||
\usepackage[T1]{fontenc}
|
||||
%\usepackage[latin1]{inputenc}
|
||||
\usepackage{ucs}
|
||||
\usepackage[utf8x]{inputenc}
|
||||
|
||||
\usepackage{lmodern} % Latin Modern fonts derived from Computer Modern
|
||||
|
||||
% Hyperlinks in PDF:
|
||||
\definecolor{linkcolor}{rgb}{0,0,0.4}
|
||||
\usepackage{hyperref}
|
||||
\hypersetup{
|
||||
breaklinks=true,
|
||||
colorlinks=true,
|
||||
linkcolor=linkcolor,
|
||||
urlcolor=linkcolor,
|
||||
citecolor=black,
|
||||
filecolor=black,
|
||||
%filecolor=blue,
|
||||
pdfmenubar=true,
|
||||
pdftoolbar=true,
|
||||
bookmarksdepth=3 % Uncomment (and tweak) for PDF bookmarks with more levels than the TOC
|
||||
}
|
||||
%\hyperbaseurl{} % hyperlinks are relative to this root
|
||||
|
||||
\setcounter{tocdepth}{2} % levels in table of contents
|
||||
|
||||
% Tricks for having figures close to where they are defined:
|
||||
% 1. define less restrictive rules for where to put figures
|
||||
\setcounter{topnumber}{2}
|
||||
\setcounter{bottomnumber}{2}
|
||||
\setcounter{totalnumber}{4}
|
||||
\renewcommand{\topfraction}{0.95}
|
||||
\renewcommand{\bottomfraction}{0.95}
|
||||
\renewcommand{\textfraction}{0}
|
||||
\renewcommand{\floatpagefraction}{0.75}
|
||||
% floatpagefraction must always be less than topfraction!
|
||||
% 2. ensure all figures are flushed before next section
|
||||
\usepackage[section]{placeins}
|
||||
% 3. enable begin{figure}[H] (often leads to ugly pagebreaks)
|
||||
%\usepackage{float}\restylefloat{figure}
|
||||
|
||||
% --- fancyhdr package for fancy headers ---
|
||||
\usepackage{fancyhdr}
|
||||
\fancyhf{} % sets both header and footer to nothing
|
||||
\renewcommand{\headrulewidth}{0pt}
|
||||
\fancyfoot[LE,RO]{\thepage}
|
||||
% Ensure copyright on titlepage (article style) and chapter pages (book style)
|
||||
\fancypagestyle{plain}{
|
||||
\fancyhf{}
|
||||
\fancyfoot[C]{{\footnotesize \copyright\ 1999-2019, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license}}
|
||||
% \renewcommand{\footrulewidth}{0mm}
|
||||
\renewcommand{\headrulewidth}{0mm}
|
||||
}
|
||||
% Ensure copyright on titlepages with \thispagestyle{empty}
|
||||
\fancypagestyle{empty}{
|
||||
\fancyhf{}
|
||||
\fancyfoot[C]{{\footnotesize \copyright\ 1999-2019, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license}}
|
||||
\renewcommand{\footrulewidth}{0mm}
|
||||
\renewcommand{\headrulewidth}{0mm}
|
||||
}
|
||||
|
||||
\pagestyle{fancy}
|
||||
|
||||
|
||||
% prevent orhpans and widows
|
||||
\clubpenalty = 10000
|
||||
\widowpenalty = 10000
|
||||
|
||||
% --- end of standard preamble for documents ---
|
||||
|
||||
|
||||
% insert custom LaTeX commands...
|
||||
|
||||
\raggedbottom
|
||||
\makeindex
|
||||
\usepackage[totoc]{idxlayout} % for index in the toc
|
||||
\usepackage[nottoc]{tocbibind} % for references/bibliography in the toc
|
||||
|
||||
%-------------------- end preamble ----------------------
|
||||
|
||||
\begin{document}
|
||||
|
||||
% matching end for #ifdef PREAMBLE
|
||||
|
||||
\newcommand{\exercisesection}[1]{\subsection*{#1}}
|
||||
|
||||
|
||||
% ------------------- main content ----------------------
|
||||
|
||||
|
||||
|
||||
% ----------------- title -------------------------
|
||||
|
||||
\thispagestyle{empty}
|
||||
|
||||
\begin{center}
|
||||
{\LARGE\bf
|
||||
\begin{spacing}{1.25}
|
||||
Convolutional Neural Networks
|
||||
\end{spacing}
|
||||
}
|
||||
\end{center}
|
||||
|
||||
% ----------------- author(s) -------------------------
|
||||
|
||||
\begin{center}
|
||||
{\bf Morten Hjorth-Jensen${}^{1, 2}$} \\ [0mm]
|
||||
\end{center}
|
||||
|
||||
\begin{center}
|
||||
% List of all institutions:
|
||||
\centerline{{\small ${}^1$Department of Physics, University of Oslo}}
|
||||
\centerline{{\small ${}^2$Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University}}
|
||||
\end{center}
|
||||
|
||||
% ----------------- end author(s) -------------------------
|
||||
|
||||
% --- begin date ---
|
||||
\begin{center}
|
||||
Oct 3, 2019
|
||||
\end{center}
|
||||
% --- end date ---
|
||||
|
||||
\vspace{1cm}
|
||||
|
||||
|
||||
% !split
|
||||
\subsection*{Convolutional Neural Networks (recognizing images)}
|
||||
|
||||
Convolutional Neural Networks (CNN) are very similar to ordinary Neural Networks.
|
||||
|
||||
They are made up of neurons that have learnable weights and
|
||||
biases. Each neuron receives some inputs, performs a dot product and
|
||||
optionally follows it with a non-linearity. The whole network still
|
||||
expresses a single differentiable score function: from the raw image
|
||||
pixels on one end to class scores at the other. And they still have a
|
||||
loss function (for example Softmax) on the last (fully-connected) layer
|
||||
and all the tips/tricks we developed for learning regular Neural
|
||||
Networks still apply (back propagation, gradient descent etc etc).
|
||||
|
||||
What is the difference? \textbf{CNN architectures make the explicit assumption that
|
||||
the inputs are images, which allows us to encode certain properties
|
||||
into the architecture. These then make the forward function more
|
||||
efficient to implement and vastly reduce the amount of parameters in
|
||||
the network.}
|
||||
|
||||
Here we provide only a superficial overview, for the more interested, we recommend highly the course
|
||||
\href{{https://www.uio.no/studier/emner/matnat/ifi/IN5400/index-eng.html}}{IN5400 – Machine Learning for Image Analysis}
|
||||
and the slides of \href{{http://cs231n.github.io/convolutional-networks/}}{CS231}.
|
||||
|
||||
% !split
|
||||
\subsection*{Regular NNs don’t scale well to full images}
|
||||
|
||||
As an example, consider
|
||||
an image of size $32\times 32\times 3$ (32 wide, 32 high, 3 color channels), so a
|
||||
single fully-connected neuron in a first hidden layer of a regular
|
||||
Neural Network would have $32\times 32\times 3 = 3072$ weights. This amount still
|
||||
seems manageable, but clearly this fully-connected structure does not
|
||||
scale to larger images. For example, an image of more respectable
|
||||
size, say $200\times 200\times 3$, would lead to neurons that have
|
||||
$200\times 200\times 3 = 120,000$ weights.
|
||||
|
||||
We could have
|
||||
several such neurons, and the parameters would add up quickly! Clearly,
|
||||
this full connectivity is wasteful and the huge number of parameters
|
||||
would quickly lead to possible overfitting.
|
||||
|
||||
|
||||
\begin{figure}[!ht] %
|
||||
\centerline{\includegraphics[width=0.6\linewidth]{figslides/nn.jpeg}}
|
||||
\caption{
|
||||
A regular 3-layer Neural Network.
|
||||
}
|
||||
\end{figure}
|
||||
%\clearpage % flush figures
|
||||
|
||||
|
||||
% !split
|
||||
\subsection*{3D volumes of neurons}
|
||||
|
||||
Convolutional Neural Networks take advantage of the fact that the
|
||||
input consists of images and they constrain the architecture in a more
|
||||
sensible way.
|
||||
|
||||
In particular, unlike a regular Neural Network, the
|
||||
layers of a CNN have neurons arranged in 3 dimensions: width,
|
||||
height, depth. (Note that the word depth here refers to the third
|
||||
dimension of an activation volume, not to the depth of a full Neural
|
||||
Network, which can refer to the total number of layers in a network.)
|
||||
|
||||
To understand it better, the above example of an image
|
||||
with an input volume of
|
||||
activations has dimensions $32\times 32\times 3$ (width, height,
|
||||
depth respectively).
|
||||
|
||||
The neurons in a layer will
|
||||
only be connected to a small region of the layer before it, instead of
|
||||
all of the neurons in a fully-connected manner. Moreover, the final
|
||||
output layer could for this specific image have dimensions $1\times 1 \times 10$,
|
||||
because by the
|
||||
end of the CNN architecture we will reduce the full image into a
|
||||
single vector of class scores, arranged along the depth
|
||||
dimension.
|
||||
|
||||
|
||||
\begin{figure}[!ht] %
|
||||
\centerline{\includegraphics[width=0.6\linewidth]{figslides/cnn.jpeg}}
|
||||
\caption{
|
||||
A CNN arranges its neurons in three dimensions (width, height, depth), as visualized in one of the layers. Every layer of a CNN transforms the 3D input volume to a 3D output volume of neuron activations. In this example, the red input layer holds the image, so its width and height would be the dimensions of the image, and the depth would be 3 (Red, Green, Blue channels).
|
||||
}
|
||||
\end{figure}
|
||||
%\clearpage % flush figures
|
||||
|
||||
|
||||
|
||||
|
||||
% !split
|
||||
\subsection*{Layers used to build CNNs}
|
||||
|
||||
|
||||
A simple CNN is a sequence of layers, and every layer of a CNN
|
||||
transforms one volume of activations to another through a
|
||||
differentiable function. We use three main types of layers to build
|
||||
CNN architectures: Convolutional Layer, Pooling Layer, and
|
||||
Fully-Connected Layer (exactly as seen in regular Neural Networks). We
|
||||
will stack these layers to form a full CNN architecture.
|
||||
|
||||
A simple CNN for image classification could have the architecture:
|
||||
|
||||
\begin{itemize}
|
||||
\item \textbf{INPUT} ($32\times 32 \times 3$) will hold the raw pixel values of the image, in this case an image of width 32, height 32, and with three color channels R,G,B.
|
||||
|
||||
\item \textbf{CONV} (convolutional )layer will compute the output of neurons that are connected to local regions in the input, each computing a dot product between their weights and a small region they are connected to in the input volume. This may result in volume such as $[32\times 32\times 12]$ if we decided to use 12 filters.
|
||||
|
||||
\item \textbf{RELU} layer will apply an elementwise activation function, such as the $max(0,x)$ thresholding at zero. This leaves the size of the volume unchanged ($[32\times 32\times 12]$).
|
||||
|
||||
\item \textbf{POOL} (pooling) layer will perform a downsampling operation along the spatial dimensions (width, height), resulting in volume such as $[16\times 16\times 12]$.
|
||||
|
||||
\item \textbf{FC} (i.e.~fully-connected) layer will compute the class scores, resulting in volume of size $[1\times 1\times 10]$, where each of the 10 numbers correspond to a class score, such as among the 10 categories of the MNIST images we considered above . As with ordinary Neural Networks and as the name implies, each neuron in this layer will be connected to all the numbers in the previous volume.
|
||||
\end{itemize}
|
||||
|
||||
\noindent
|
||||
% !split
|
||||
\subsection*{Transforming images}
|
||||
|
||||
CNNs transform the original image layer by layer from the original
|
||||
pixel values to the final class scores.
|
||||
|
||||
Observe that some layers contain
|
||||
parameters and other don’t. In particular, the CNN layers perform
|
||||
transformations that are a function of not only the activations in the
|
||||
input volume, but also of the parameters (the weights and biases of
|
||||
the neurons). On the other hand, the RELU/POOL layers will implement a
|
||||
fixed function. The parameters in the CONV/FC layers will be trained
|
||||
with gradient descent so that the class scores that the CNN computes
|
||||
are consistent with the labels in the training set for each image.
|
||||
|
||||
|
||||
% !split
|
||||
\subsection*{CNNs in brief}
|
||||
|
||||
In summary:
|
||||
|
||||
\begin{itemize}
|
||||
\item A CNN architecture is in the simplest case a list of Layers that transform the image volume into an output volume (e.g.~holding the class scores)
|
||||
|
||||
\item There are a few distinct types of Layers (e.g.~CONV/FC/RELU/POOL are by far the most popular)
|
||||
|
||||
\item Each Layer accepts an input 3D volume and transforms it to an output 3D volume through a differentiable function
|
||||
|
||||
\item Each Layer may or may not have parameters (e.g.~CONV/FC do, RELU/POOL don’t)
|
||||
|
||||
\item Each Layer may or may not have additional hyperparameters (e.g.~CONV/FC/POOL do, RELU doesn’t)
|
||||
\end{itemize}
|
||||
|
||||
\noindent
|
||||
For more material on convolutional networks, we strongly recommend
|
||||
the course
|
||||
\href{{https://www.uio.no/studier/emner/matnat/ifi/IN5400/index-eng.html}}{IN5400 – Machine Learning for Image Analysis}
|
||||
and the slides of \href{{http://cs231n.github.io/convolutional-networks/}}{CS231} which is taught at Stanford University (consistently ranked as one of the top computer science programs in the world). \href{{http://neuralnetworksanddeeplearning.com/chap6.html}}{Michael Nielsen's book is a must read, in particular chapter 6 which deals with CNNs}.
|
||||
|
||||
|
||||
% !split
|
||||
\subsection*{CNNs in more detail, building convolutional neural networks in Tensorflow and Keras}
|
||||
|
||||
|
||||
As discussed above, CNNs are neural networks built from the assumption that the inputs
|
||||
to the network are 2D images. This is important because the number of features or pixels in images
|
||||
grows very fast with the image size, and an enormous number of weights and biases are needed in order to build an accurate network.
|
||||
|
||||
As before, we still have our input, a hidden layer and an output. What's novel about convolutional networks
|
||||
are the \textbf{convolutional} and \textbf{pooling} layers stacked in pairs between the input and the hidden layer.
|
||||
In addition, the data is no longer represented as a 2D feature matrix, instead each input is a number of 2D
|
||||
matrices, typically 1 for each color dimension (Red, Green, Blue).
|
||||
|
||||
|
||||
% !split
|
||||
\subsection*{Setting it up}
|
||||
|
||||
It means that to represent the entire
|
||||
dataset of images, we require a 4D matrix or \textbf{tensor}. This tensor has the dimensions:
|
||||
\[
|
||||
(n_{inputs},\, n_{pixels, width},\, n_{pixels, height},\, depth) .
|
||||
\]
|
||||
|
||||
% !split
|
||||
\subsection*{The MNIST dataset again}
|
||||
|
||||
The MNIST dataset consists of grayscale images with a pixel size of
|
||||
$28\times 28$, meaning we require $28 \times 28 = 724$ weights to each
|
||||
neuron in the first hidden layer.
|
||||
|
||||
If we were to analyze images of size $128\times 128$ we would require
|
||||
$128 \times 128 = 16384$ weights to each neuron. Even worse if we were
|
||||
dealing with color images, as most images are, we have an image matrix
|
||||
of size $128\times 128$ for each color dimension (Red, Green, Blue),
|
||||
meaning 3 times the number of weights $= 49152$ are required for every
|
||||
single neuron in the first hidden layer.
|
||||
|
||||
|
||||
% !split
|
||||
\subsection*{Strong correlations}
|
||||
Images typically have strong local correlations, meaning that a small
|
||||
part of the image varies little from its neighboring regions. If for
|
||||
example we have an image of a blue car, we can roughly assume that a
|
||||
small blue part of the image is surrounded by other blue regions.
|
||||
|
||||
Therefore, instead of connecting every single pixel to a neuron in the
|
||||
first hidden layer, as we have previously done with deep neural
|
||||
networks, we can instead connect each neuron to a small part of the
|
||||
image (in all 3 RGB depth dimensions). The size of each small area is
|
||||
fixed, and known as a \href{{https://en.wikipedia.org/wiki/Receptive_field}}{receptive}.
|
||||
|
||||
|
||||
% !split
|
||||
\subsection*{Layers of a CNN}
|
||||
The layers of a convolutional neural network arrange neurons in 3D: width, height and depth.
|
||||
The input image is typically a square matrix of depth 3.
|
||||
|
||||
A \textbf{convolution} is performed on the image which outputs
|
||||
a 3D volume of neurons. The weights to the input are arranged in a number of 2D matrices, known as \textbf{filters}.
|
||||
|
||||
|
||||
Each filter slides along the input image, taking the dot product
|
||||
between each small part of the image and the filter, in all depth
|
||||
dimensions. This is then passed through a non-linear function,
|
||||
typically the \textbf{Rectified Linear (ReLu)} function, which serves as the
|
||||
activation of the neurons in the first convolutional layer. This is
|
||||
further passed through a \textbf{pooling layer}, which reduces the size of the
|
||||
convolutional layer, e.g.~by taking the maximum or average across some
|
||||
small regions, and this serves as input to the next convolutional
|
||||
layer.
|
||||
|
||||
|
||||
% !split
|
||||
\subsection*{Systematic reduction}
|
||||
|
||||
By systematically reducing the size of the input volume, through
|
||||
convolution and pooling, the network should create representations of
|
||||
small parts of the input, and then from them assemble representations
|
||||
of larger areas. The final pooling layer is flattened to serve as
|
||||
input to a hidden layer, such that each neuron in the final pooling
|
||||
layer is connected to every single neuron in the hidden layer. This
|
||||
then serves as input to the output layer, e.g.~a softmax output for
|
||||
classification.
|
||||
|
||||
|
||||
% !split
|
||||
\subsection*{Prerequisites: Collect and pre-process data}
|
||||
\begin{minted}[fontsize=\fontsize{9pt}{9pt},linenos=false,mathescape,baselinestretch=1.0,fontfamily=tt,xleftmargin=7mm]{python}
|
||||
# import necessary packages
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
from sklearn import datasets
|
||||
|
||||
|
||||
# ensure the same random numbers appear every time
|
||||
np.random.seed(0)
|
||||
|
||||
# display images in notebook
|
||||
%matplotlib inline
|
||||
plt.rcParams['figure.figsize'] = (12,12)
|
||||
|
||||
|
||||
# download MNIST dataset
|
||||
digits = datasets.load_digits()
|
||||
|
||||
# define inputs and labels
|
||||
inputs = digits.images
|
||||
labels = digits.target
|
||||
|
||||
# RGB images have a depth of 3
|
||||
# our images are grayscale so they should have a depth of 1
|
||||
inputs = inputs[:,:,:,np.newaxis]
|
||||
|
||||
print("inputs = (n_inputs, pixel_width, pixel_height, depth) = " + str(inputs.shape))
|
||||
print("labels = (n_inputs) = " + str(labels.shape))
|
||||
|
||||
|
||||
# choose some random images to display
|
||||
n_inputs = len(inputs)
|
||||
indices = np.arange(n_inputs)
|
||||
random_indices = np.random.choice(indices, size=5)
|
||||
|
||||
for i, image in enumerate(digits.images[random_indices]):
|
||||
plt.subplot(1, 5, i+1)
|
||||
plt.axis('off')
|
||||
plt.imshow(image, cmap=plt.cm.gray_r, interpolation='nearest')
|
||||
plt.title("Label: %d" % digits.target[random_indices[i]])
|
||||
plt.show()
|
||||
\end{minted}
|
||||
|
||||
|
||||
% !split
|
||||
\subsection*{Importing Keras and Tensorflow}
|
||||
\begin{minted}[fontsize=\fontsize{9pt}{9pt},linenos=false,mathescape,baselinestretch=1.0,fontfamily=tt,xleftmargin=7mm]{python}
|
||||
from keras.utils import to_categorical
|
||||
from sklearn.model_selection import train_test_split
|
||||
|
||||
# representation of labels
|
||||
labels = to_categorical(labels)
|
||||
|
||||
# split into train and test data
|
||||
# one-liner from scikit-learn library
|
||||
train_size = 0.8
|
||||
test_size = 1 - train_size
|
||||
X_train, X_test, Y_train, Y_test = train_test_split(inputs, labels, train_size=train_size,
|
||||
test_size=test_size)
|
||||
\end{minted}
|
||||
|
||||
% !split
|
||||
\subsection*{Using TensorFlow backend}
|
||||
|
||||
We need to define model and architecture and choose cost function and optmizer.
|
||||
\begin{Verbatim}[numbers=none,fontsize=\fontsize{9pt}{9pt},baselinestretch=0.95]
|
||||
|
||||
import tensorflow as tf
|
||||
|
||||
class ConvolutionalNeuralNetworkTensorflow:
|
||||
def __init__(
|
||||
self,
|
||||
X_train,
|
||||
Y_train,
|
||||
X_test,
|
||||
Y_test,
|
||||
n_filters=10,
|
||||
n_neurons_connected=50,
|
||||
n_categories=10,
|
||||
receptive_field=3,
|
||||
stride=1,
|
||||
padding=1,
|
||||
epochs=10,
|
||||
batch_size=100,
|
||||
eta=0.1,
|
||||
lmbd=0.0):
|
||||
|
||||
self.global_step = tf.Variable(0, dtype=tf.int32, trainable=False, name='global_step')
|
||||
|
||||
self.X_train = X_train
|
||||
self.Y_train = Y_train
|
||||
self.X_test = X_test
|
||||
self.Y_test = Y_test
|
||||
|
||||
self.n_inputs, self.input_width, self.input_height, self.depth = X_train.shape
|
||||
|
||||
self.n_filters = n_filters
|
||||
self.n_downsampled = int(self.input_width*self.input_height*n_filters / 4)
|
||||
self.n_neurons_connected = n_neurons_connected
|
||||
self.n_categories = n_categories
|
||||
|
||||
self.receptive_field = receptive_field
|
||||
self.stride = stride
|
||||
self.strides = [stride, stride, stride, stride]
|
||||
self.padding = padding
|
||||
|
||||
self.epochs = epochs
|
||||
self.batch_size = batch_size
|
||||
self.iterations = self.n_inputs // self.batch_size
|
||||
self.eta = eta
|
||||
self.lmbd = lmbd
|
||||
|
||||
self.create_placeholders()
|
||||
self.create_CNN()
|
||||
self.create_loss()
|
||||
self.create_optimiser()
|
||||
self.create_accuracy()
|
||||
|
||||
def create_placeholders(self):
|
||||
with tf.name_scope('data'):
|
||||
self.X = tf.placeholder(tf.float32, shape=(None, self.input_width, self.input_height, self.depth), name='X_data')
|
||||
self.Y = tf.placeholder(tf.float32, shape=(None, self.n_categories), name='Y_data')
|
||||
|
||||
def create_CNN(self):
|
||||
with tf.name_scope('CNN'):
|
||||
|
||||
# Convolutional layer
|
||||
self.W_conv = self.weight_variable([self.receptive_field, self.receptive_field, self.depth, self.n_filters], name='conv', dtype=tf.float32)
|
||||
b_conv = self.weight_variable([self.n_filters], name='conv', dtype=tf.float32)
|
||||
z_conv = tf.nn.conv2d(self.X, self.W_conv, self.strides, padding='SAME', name='conv') + b_conv
|
||||
a_conv = tf.nn.relu(z_conv)
|
||||
|
||||
# 2x2 max pooling
|
||||
a_pool = tf.nn.max_pool(a_conv, [1, 2, 2, 1], [1, 2, 2, 1], padding='SAME', name='pool')
|
||||
|
||||
# Fully connected layer
|
||||
a_pool_flat = tf.reshape(a_pool, [-1, self.n_downsampled])
|
||||
self.W_fc = self.weight_variable([self.n_downsampled, self.n_neurons_connected], name='fc', dtype=tf.float32)
|
||||
b_fc = self.bias_variable([self.n_neurons_connected], name='fc', dtype=tf.float32)
|
||||
a_fc = tf.nn.relu(tf.matmul(a_pool_flat, self.W_fc) + b_fc)
|
||||
|
||||
# Output layer
|
||||
self.W_out = self.weight_variable([self.n_neurons_connected, self.n_categories], name='out', dtype=tf.float32)
|
||||
b_out = self.bias_variable([self.n_categories], name='out', dtype=tf.float32)
|
||||
self.z_out = tf.matmul(a_fc, self.W_out) + b_out
|
||||
|
||||
def create_loss(self):
|
||||
with tf.name_scope('loss'):
|
||||
softmax_loss = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits_v2(labels=self.Y, logits=self.z_out))
|
||||
|
||||
regularizer_loss_conv = tf.nn.l2_loss(self.W_conv)
|
||||
regularizer_loss_fc = tf.nn.l2_loss(self.W_fc)
|
||||
regularizer_loss_out = tf.nn.l2_loss(self.W_out)
|
||||
regularizer_loss = self.lmbd*(regularizer_loss_conv + regularizer_loss_fc + regularizer_loss_out)
|
||||
|
||||
self.loss = softmax_loss + regularizer_loss
|
||||
|
||||
def create_accuracy(self):
|
||||
with tf.name_scope('accuracy'):
|
||||
probabilities = tf.nn.softmax(self.z_out)
|
||||
predictions = tf.argmax(probabilities, 1)
|
||||
labels = tf.argmax(self.Y, 1)
|
||||
|
||||
correct_predictions = tf.equal(predictions, labels)
|
||||
correct_predictions = tf.cast(correct_predictions, tf.float32)
|
||||
self.accuracy = tf.reduce_mean(correct_predictions)
|
||||
|
||||
def create_optimiser(self):
|
||||
with tf.name_scope('optimizer'):
|
||||
self.optimizer = tf.train.GradientDescentOptimizer(learning_rate=self.eta).minimize(self.loss, global_step=self.global_step)
|
||||
|
||||
def weight_variable(self, shape, name='', dtype=tf.float32):
|
||||
initial = tf.truncated_normal(shape, stddev=0.1)
|
||||
return tf.Variable(initial, name=name, dtype=dtype)
|
||||
|
||||
def bias_variable(self, shape, name='', dtype=tf.float32):
|
||||
initial = tf.constant(0.1, shape=shape)
|
||||
return tf.Variable(initial, name=name, dtype=dtype)
|
||||
|
||||
def fit(self):
|
||||
data_indices = np.arange(self.n_inputs)
|
||||
|
||||
with tf.Session() as sess:
|
||||
sess.run(tf.global_variables_initializer())
|
||||
for i in range(self.epochs):
|
||||
for j in range(self.iterations):
|
||||
chosen_datapoints = np.random.choice(data_indices, size=self.batch_size, replace=False)
|
||||
batch_X, batch_Y = self.X_train[chosen_datapoints], self.Y_train[chosen_datapoints]
|
||||
|
||||
sess.run([CNN.loss, CNN.optimizer],
|
||||
feed_dict={CNN.X: batch_X,
|
||||
CNN.Y: batch_Y})
|
||||
accuracy = sess.run(CNN.accuracy,
|
||||
feed_dict={CNN.X: batch_X,
|
||||
CNN.Y: batch_Y})
|
||||
step = sess.run(CNN.global_step)
|
||||
|
||||
self.train_loss, self.train_accuracy = sess.run([CNN.loss, CNN.accuracy],
|
||||
feed_dict={CNN.X: self.X_train,
|
||||
CNN.Y: self.Y_train})
|
||||
|
||||
self.test_loss, self.test_accuracy = sess.run([CNN.loss, CNN.accuracy],
|
||||
feed_dict={CNN.X: self.X_test,
|
||||
CNN.Y: self.Y_test})
|
||||
\end{Verbatim}
|
||||
|
||||
% !split
|
||||
\subsection*{Train the model}
|
||||
|
||||
We need now to train the model, evaluate it and test its performance on test data, and eventually include hyperparameters.
|
||||
\begin{minted}[fontsize=\fontsize{9pt}{9pt},linenos=false,mathescape,baselinestretch=1.0,fontfamily=tt,xleftmargin=7mm]{python}
|
||||
epochs = 100
|
||||
batch_size = 100
|
||||
n_filters = 10
|
||||
n_neurons_connected = 50
|
||||
n_categories = 10
|
||||
|
||||
eta_vals = np.logspace(-5, 1, 7)
|
||||
lmbd_vals = np.logspace(-5, 1, 7)
|
||||
CNN_tf = np.zeros((len(eta_vals), len(lmbd_vals)), dtype=object)
|
||||
|
||||
for i, eta in enumerate(eta_vals):
|
||||
for j, lmbd in enumerate(lmbd_vals):
|
||||
CNN = ConvolutionalNeuralNetworkTensorflow(X_train, Y_train, X_test, Y_test,
|
||||
n_filters=n_filters, n_neurons_connected=n_neurons_connected,
|
||||
n_categories=n_categories, epochs=epochs, batch_size=batch_size,
|
||||
eta=eta, lmbd=lmbd)
|
||||
CNN.fit()
|
||||
|
||||
print("Learning rate = ", eta)
|
||||
print("Lambda = ", lmbd)
|
||||
print("Test accuracy: %.3f" % CNN.test_accuracy)
|
||||
print()
|
||||
|
||||
CNN_tf[i][j] = CNN
|
||||
\end{minted}
|
||||
|
||||
% !split
|
||||
\subsection*{Visualizing the results}
|
||||
|
||||
\begin{minted}[fontsize=\fontsize{9pt}{9pt},linenos=false,mathescape,baselinestretch=1.0,fontfamily=tt,xleftmargin=7mm]{python}
|
||||
# visual representation of grid search
|
||||
# uses seaborn heatmap, could probably do this in matplotlib
|
||||
import seaborn as sns
|
||||
|
||||
sns.set()
|
||||
|
||||
train_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))
|
||||
test_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))
|
||||
|
||||
for i in range(len(eta_vals)):
|
||||
for j in range(len(lmbd_vals)):
|
||||
CNN = CNN_tf[i][j]
|
||||
|
||||
train_accuracy[i][j] = CNN.train_accuracy
|
||||
test_accuracy[i][j] = CNN.test_accuracy
|
||||
|
||||
|
||||
fig, ax = plt.subplots(figsize = (10, 10))
|
||||
sns.heatmap(train_accuracy, annot=True, ax=ax, cmap="viridis")
|
||||
ax.set_title("Training Accuracy")
|
||||
ax.set_ylabel("$\eta$")
|
||||
ax.set_xlabel("$\lambda$")
|
||||
plt.show()
|
||||
|
||||
fig, ax = plt.subplots(figsize = (10, 10))
|
||||
sns.heatmap(test_accuracy, annot=True, ax=ax, cmap="viridis")
|
||||
ax.set_title("Test Accuracy")
|
||||
ax.set_ylabel("$\eta$")
|
||||
ax.set_xlabel("$\lambda$")
|
||||
plt.show()
|
||||
\end{minted}
|
||||
|
||||
% !split
|
||||
\subsection*{Running with Keras}
|
||||
|
||||
\begin{minted}[fontsize=\fontsize{9pt}{9pt},linenos=false,mathescape,baselinestretch=1.0,fontfamily=tt,xleftmargin=7mm]{python}
|
||||
from keras.models import Sequential
|
||||
from keras.layers.convolutional import Conv2D
|
||||
from keras.layers.convolutional import MaxPooling2D
|
||||
from keras.layers import Flatten
|
||||
from keras.layers import Dense
|
||||
from keras.regularizers import l2
|
||||
from keras.optimizers import SGD
|
||||
|
||||
def create_convolutional_neural_network_keras(input_shape, receptive_field,
|
||||
n_filters, n_neurons_connected, n_categories,
|
||||
eta, lmbd):
|
||||
model = Sequential()
|
||||
model.add(Conv2D(n_filters, (receptive_field, receptive_field), input_shape=input_shape, padding='same',
|
||||
activation='relu', kernel_regularizer=l2(lmbd)))
|
||||
model.add(MaxPooling2D(pool_size=(2, 2)))
|
||||
model.add(Flatten())
|
||||
model.add(Dense(n_neurons_connected, activation='relu', kernel_regularizer=l2(lmbd)))
|
||||
model.add(Dense(n_categories, activation='softmax', kernel_regularizer=l2(lmbd)))
|
||||
|
||||
sgd = SGD(lr=eta)
|
||||
model.compile(loss='categorical_crossentropy', optimizer=sgd, metrics=['accuracy'])
|
||||
|
||||
return model
|
||||
|
||||
epochs = 100
|
||||
batch_size = 100
|
||||
input_shape = X_train.shape[1:4]
|
||||
receptive_field = 3
|
||||
n_filters = 10
|
||||
n_neurons_connected = 50
|
||||
n_categories = 10
|
||||
|
||||
eta_vals = np.logspace(-5, 1, 7)
|
||||
lmbd_vals = np.logspace(-5, 1, 7)
|
||||
\end{minted}
|
||||
|
||||
% !split
|
||||
\subsection*{Final part}
|
||||
|
||||
\begin{minted}[fontsize=\fontsize{9pt}{9pt},linenos=false,mathescape,baselinestretch=1.0,fontfamily=tt,xleftmargin=7mm]{python}
|
||||
CNN_keras = np.zeros((len(eta_vals), len(lmbd_vals)), dtype=object)
|
||||
|
||||
for i, eta in enumerate(eta_vals):
|
||||
for j, lmbd in enumerate(lmbd_vals):
|
||||
CNN = create_convolutional_neural_network_keras(input_shape, receptive_field,
|
||||
n_filters, n_neurons_connected, n_categories,
|
||||
eta, lmbd)
|
||||
CNN.fit(X_train, Y_train, epochs=epochs, batch_size=batch_size, verbose=0)
|
||||
scores = CNN.evaluate(X_test, Y_test)
|
||||
|
||||
CNN_keras[i][j] = CNN
|
||||
|
||||
print("Learning rate = ", eta)
|
||||
print("Lambda = ", lmbd)
|
||||
print("Test accuracy: %.3f" % scores[1])
|
||||
print()
|
||||
\end{minted}
|
||||
|
||||
% !split
|
||||
\subsection*{Final visualization}
|
||||
|
||||
\begin{Verbatim}[numbers=none,fontsize=\fontsize{9pt}{9pt},baselinestretch=0.95]
|
||||
# visual representation of grid search
|
||||
# uses seaborn heatmap, could probably do this in matplotlib
|
||||
import seaborn as sns
|
||||
|
||||
sns.set()
|
||||
|
||||
train_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))
|
||||
test_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))
|
||||
|
||||
for i in range(len(eta_vals)):
|
||||
for j in range(len(lmbd_vals)):
|
||||
CNN = CNN_keras[i][j]
|
||||
|
||||
train_accuracy[i][j] = CNN.evaluate(X_train, Y_train)[1]
|
||||
test_accuracy[i][j] = CNN.evaluate(X_test, Y_test)[1]
|
||||
|
||||
|
||||
fig, ax = plt.subplots(figsize = (10, 10))
|
||||
sns.heatmap(train_accuracy, annot=True, ax=ax, cmap="viridis")
|
||||
ax.set_title("Training Accuracy")
|
||||
ax.set_ylabel("$\eta$")
|
||||
ax.set_xlabel("$\lambda$")
|
||||
plt.show()
|
||||
|
||||
fig, ax = plt.subplots(figsize = (10, 10))
|
||||
sns.heatmap(test_accuracy, annot=True, ax=ax, cmap="viridis")
|
||||
ax.set_title("Test Accuracy")
|
||||
ax.set_ylabel("$\eta$")
|
||||
ax.set_xlabel("$\lambda$")
|
||||
plt.show()
|
||||
\end{Verbatim}
|
||||
|
||||
% !split
|
||||
\subsection*{Fun links}
|
||||
|
||||
\begin{enumerate}
|
||||
\item \href{{https://arxiv.org/abs/1604.07316}}{Self-Driving cars using a convolutional neural network}
|
||||
|
||||
\item \href{{https://deepdreamgenerator.com/}}{Abstract art using convolutional neural networks}
|
||||
\end{enumerate}
|
||||
|
||||
\noindent
|
||||
|
||||
% ------------------- end of main content ---------------
|
||||
|
||||
\end{document}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
.DS_Store
|
||||
.svn
|
||||
log/*.log
|
||||
tmp/**
|
||||
node_modules/
|
||||
.sass-cache
|
||||
css/reveal.min.css
|
||||
js/reveal.min.js
|
||||
@@ -1,5 +0,0 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 0.10
|
||||
before_script:
|
||||
- npm install -g grunt-cli
|
||||
@@ -1,23 +0,0 @@
|
||||
## Contributing
|
||||
|
||||
Please keep the [issue tracker](http://github.com/hakimel/reveal.js/issues) limited to **bug reports**, **feature requests** and **pull requests**.
|
||||
|
||||
|
||||
### Personal Support
|
||||
If you have personal support or setup questions the best place to ask those are [StackOverflow](http://stackoverflow.com/questions/tagged/reveal.js).
|
||||
|
||||
|
||||
### Bug Reports
|
||||
When reporting a bug make sure to include information about which browser and operating system you are on as well as the necessary steps to reproduce the issue. If possible please include a link to a sample presentation where the bug can be tested.
|
||||
|
||||
|
||||
### Pull Requests
|
||||
- Should follow the coding style of the file you work in, most importantly:
|
||||
- Tabs to indent
|
||||
- Single-quoted strings
|
||||
- Should be made towards the **dev branch**
|
||||
- Should be submitted from a feature/topic branch (not your master)
|
||||
|
||||
|
||||
### Plugins
|
||||
Please do not submit plugins as pull requests. They should be maintained in their own separate repository. More information here: https://github.com/hakimel/reveal.js/wiki/Plugin-Guidelines
|
||||
@@ -1,140 +0,0 @@
|
||||
/* global module:false */
|
||||
module.exports = function(grunt) {
|
||||
var port = grunt.option('port') || 8000;
|
||||
// Project configuration
|
||||
grunt.initConfig({
|
||||
pkg: grunt.file.readJSON('package.json'),
|
||||
meta: {
|
||||
banner:
|
||||
'/*!\n' +
|
||||
' * reveal.js <%= pkg.version %> (<%= grunt.template.today("yyyy-mm-dd, HH:MM") %>)\n' +
|
||||
' * http://lab.hakim.se/reveal-js\n' +
|
||||
' * MIT licensed\n' +
|
||||
' *\n' +
|
||||
' * Copyright (C) 2014 Hakim El Hattab, http://hakim.se\n' +
|
||||
' */'
|
||||
},
|
||||
|
||||
qunit: {
|
||||
files: [ 'test/*.html' ]
|
||||
},
|
||||
|
||||
uglify: {
|
||||
options: {
|
||||
banner: '<%= meta.banner %>\n'
|
||||
},
|
||||
build: {
|
||||
src: 'js/reveal.js',
|
||||
dest: 'js/reveal.min.js'
|
||||
}
|
||||
},
|
||||
|
||||
cssmin: {
|
||||
compress: {
|
||||
files: {
|
||||
'css/reveal.min.css': [ 'css/reveal.css' ]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
sass: {
|
||||
main: {
|
||||
files: {
|
||||
'css/theme/darkgray.css': 'css/theme/source/darkgray.scss',
|
||||
'css/theme/beigesmall.css': 'css/theme/source/beigesmall.scss',
|
||||
'css/theme/cbc.css': 'css/theme/source/cbc.scss',
|
||||
'css/theme/default.css': 'css/theme/source/default.scss',
|
||||
'css/theme/beige.css': 'css/theme/source/beige.scss',
|
||||
'css/theme/night.css': 'css/theme/source/night.scss',
|
||||
'css/theme/serif.css': 'css/theme/source/serif.scss',
|
||||
'css/theme/simple.css': 'css/theme/source/simple.scss',
|
||||
'css/theme/sky.css': 'css/theme/source/sky.scss',
|
||||
'css/theme/moon.css': 'css/theme/source/moon.scss',
|
||||
'css/theme/solarized.css': 'css/theme/source/solarized.scss',
|
||||
'css/theme/blood.css': 'css/theme/source/blood.scss'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
jshint: {
|
||||
options: {
|
||||
curly: false,
|
||||
eqeqeq: true,
|
||||
immed: true,
|
||||
latedef: true,
|
||||
newcap: true,
|
||||
noarg: true,
|
||||
sub: true,
|
||||
undef: true,
|
||||
eqnull: true,
|
||||
browser: true,
|
||||
expr: true,
|
||||
globals: {
|
||||
head: false,
|
||||
module: false,
|
||||
console: false,
|
||||
unescape: false
|
||||
}
|
||||
},
|
||||
files: [ 'Gruntfile.js', 'js/reveal.js' ]
|
||||
},
|
||||
|
||||
connect: {
|
||||
server: {
|
||||
options: {
|
||||
port: port,
|
||||
base: '.'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
zip: {
|
||||
'reveal-js-presentation.zip': [
|
||||
'index.html',
|
||||
'css/**',
|
||||
'js/**',
|
||||
'lib/**',
|
||||
'images/**',
|
||||
'plugin/**'
|
||||
]
|
||||
},
|
||||
|
||||
watch: {
|
||||
main: {
|
||||
files: [ 'Gruntfile.js', 'js/reveal.js', 'css/reveal.css' ],
|
||||
tasks: 'default'
|
||||
},
|
||||
theme: {
|
||||
files: [ 'css/theme/source/*.scss', 'css/theme/template/*.scss' ],
|
||||
tasks: 'themes'
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Dependencies
|
||||
grunt.loadNpmTasks( 'grunt-contrib-qunit' );
|
||||
grunt.loadNpmTasks( 'grunt-contrib-jshint' );
|
||||
grunt.loadNpmTasks( 'grunt-contrib-cssmin' );
|
||||
grunt.loadNpmTasks( 'grunt-contrib-uglify' );
|
||||
grunt.loadNpmTasks( 'grunt-contrib-watch' );
|
||||
grunt.loadNpmTasks( 'grunt-contrib-sass' );
|
||||
grunt.loadNpmTasks( 'grunt-contrib-connect' );
|
||||
grunt.loadNpmTasks( 'grunt-zip' );
|
||||
|
||||
// Default task
|
||||
grunt.registerTask( 'default', [ 'jshint', 'cssmin', 'uglify', 'qunit' ] );
|
||||
|
||||
// Theme task
|
||||
grunt.registerTask( 'themes', [ 'sass' ] );
|
||||
|
||||
// Package presentation to archive
|
||||
grunt.registerTask( 'package', [ 'default', 'zip' ] );
|
||||
|
||||
// Serve presentation locally
|
||||
grunt.registerTask( 'serve', [ 'connect', 'watch' ] );
|
||||
|
||||
// Run tests
|
||||
grunt.registerTask( 'test', [ 'jshint', 'qunit' ] );
|
||||
|
||||
};
|
||||
@@ -1,19 +0,0 @@
|
||||
Copyright (C) 2015 Hakim El Hattab, http://hakim.se
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
@@ -1,27 +0,0 @@
|
||||
{
|
||||
"name": "reveal.js",
|
||||
"version": "3.1.0",
|
||||
"main": [
|
||||
"js/reveal.js",
|
||||
"css/reveal.css"
|
||||
],
|
||||
"homepage": "http://lab.hakim.se/reveal-js/",
|
||||
"license": "MIT",
|
||||
"description": "The HTML Presentation Framework",
|
||||
"authors": [
|
||||
"Hakim El Hattab <hakim.elhattab@gmail.com>"
|
||||
],
|
||||
"dependencies": {
|
||||
"headjs": "~0.9.6"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/hakimel/reveal.js.git"
|
||||
},
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test"
|
||||
]
|
||||
}
|
||||
|
Before Width: | Height: | Size: 9.8 KiB |
|
Before Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 11 KiB |
@@ -1,202 +0,0 @@
|
||||
/* Default Print Stylesheet Template
|
||||
by Rob Glazebrook of CSSnewbie.com
|
||||
Last Updated: June 4, 2008
|
||||
|
||||
Feel free (nay, compelled) to edit, append, and
|
||||
manipulate this file as you see fit. */
|
||||
|
||||
|
||||
@media print {
|
||||
|
||||
/* SECTION 1: Set default width, margin, float, and
|
||||
background. This prevents elements from extending
|
||||
beyond the edge of the printed page, and prevents
|
||||
unnecessary background images from printing */
|
||||
html {
|
||||
background: #fff;
|
||||
width: auto;
|
||||
height: auto;
|
||||
overflow: visible;
|
||||
}
|
||||
body {
|
||||
background: #fff;
|
||||
font-size: 20pt;
|
||||
width: auto;
|
||||
height: auto;
|
||||
border: 0;
|
||||
margin: 0 5%;
|
||||
padding: 0;
|
||||
overflow: visible;
|
||||
float: none !important;
|
||||
}
|
||||
|
||||
/* SECTION 2: Remove any elements not needed in print.
|
||||
This would include navigation, ads, sidebars, etc. */
|
||||
.nestedarrow,
|
||||
.controls,
|
||||
.fork-reveal,
|
||||
.share-reveal,
|
||||
.state-background,
|
||||
.reveal .progress,
|
||||
.reveal .backgrounds {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
/* SECTION 3: Set body font face, size, and color.
|
||||
Consider using a serif font for readability. */
|
||||
body, p, td, li, div {
|
||||
font-size: 20pt!important;
|
||||
font-family: Georgia, "Times New Roman", Times, serif !important;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
/* SECTION 4: Set heading font face, sizes, and color.
|
||||
Differentiate your headings from your body text.
|
||||
Perhaps use a large sans-serif for distinction. */
|
||||
h1,h2,h3,h4,h5,h6 {
|
||||
color: #000!important;
|
||||
height: auto;
|
||||
line-height: normal;
|
||||
font-family: Georgia, "Times New Roman", Times, serif !important;
|
||||
text-shadow: 0 0 0 #000 !important;
|
||||
text-align: left;
|
||||
letter-spacing: normal;
|
||||
}
|
||||
/* Need to reduce the size of the fonts for printing */
|
||||
h1 { font-size: 28pt !important; }
|
||||
h2 { font-size: 24pt !important; }
|
||||
h3 { font-size: 22pt !important; }
|
||||
h4 { font-size: 22pt !important; font-variant: small-caps; }
|
||||
h5 { font-size: 21pt !important; }
|
||||
h6 { font-size: 20pt !important; font-style: italic; }
|
||||
|
||||
/* SECTION 5: Make hyperlinks more usable.
|
||||
Ensure links are underlined, and consider appending
|
||||
the URL to the end of the link for usability. */
|
||||
a:link,
|
||||
a:visited {
|
||||
color: #000 !important;
|
||||
font-weight: bold;
|
||||
text-decoration: underline;
|
||||
}
|
||||
/*
|
||||
.reveal a:link:after,
|
||||
.reveal a:visited:after {
|
||||
content: " (" attr(href) ") ";
|
||||
color: #222 !important;
|
||||
font-size: 90%;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/* SECTION 6: more reveal.js specific additions by @skypanther */
|
||||
ul, ol, div, p {
|
||||
visibility: visible;
|
||||
position: static;
|
||||
width: auto;
|
||||
height: auto;
|
||||
display: block;
|
||||
overflow: visible;
|
||||
margin: 0;
|
||||
text-align: left !important;
|
||||
}
|
||||
.reveal pre,
|
||||
.reveal table {
|
||||
margin-left: 0;
|
||||
margin-right: 0;
|
||||
}
|
||||
.reveal pre code {
|
||||
padding: 20px;
|
||||
border: 1px solid #ddd;
|
||||
}
|
||||
.reveal blockquote {
|
||||
margin: 20px 0;
|
||||
}
|
||||
.reveal .slides {
|
||||
position: static !important;
|
||||
width: auto !important;
|
||||
height: auto !important;
|
||||
|
||||
left: 0 !important;
|
||||
top: 0 !important;
|
||||
margin-left: 0 !important;
|
||||
margin-top: 0 !important;
|
||||
padding: 0 !important;
|
||||
zoom: 1 !important;
|
||||
|
||||
overflow: visible !important;
|
||||
display: block !important;
|
||||
|
||||
text-align: left !important;
|
||||
-webkit-perspective: none;
|
||||
-moz-perspective: none;
|
||||
-ms-perspective: none;
|
||||
perspective: none;
|
||||
|
||||
-webkit-perspective-origin: 50% 50%;
|
||||
-moz-perspective-origin: 50% 50%;
|
||||
-ms-perspective-origin: 50% 50%;
|
||||
perspective-origin: 50% 50%;
|
||||
}
|
||||
.reveal .slides section {
|
||||
visibility: visible !important;
|
||||
position: static !important;
|
||||
width: 100% !important;
|
||||
height: auto !important;
|
||||
display: block !important;
|
||||
overflow: visible !important;
|
||||
|
||||
left: 0 !important;
|
||||
top: 0 !important;
|
||||
margin-left: 0 !important;
|
||||
margin-top: 0 !important;
|
||||
padding: 60px 20px !important;
|
||||
z-index: auto !important;
|
||||
|
||||
opacity: 1 !important;
|
||||
|
||||
page-break-after: always !important;
|
||||
|
||||
-webkit-transform-style: flat !important;
|
||||
-moz-transform-style: flat !important;
|
||||
-ms-transform-style: flat !important;
|
||||
transform-style: flat !important;
|
||||
|
||||
-webkit-transform: none !important;
|
||||
-moz-transform: none !important;
|
||||
-ms-transform: none !important;
|
||||
transform: none !important;
|
||||
|
||||
-webkit-transition: none !important;
|
||||
-moz-transition: none !important;
|
||||
-ms-transition: none !important;
|
||||
transition: none !important;
|
||||
}
|
||||
.reveal .slides section.stack {
|
||||
padding: 0 !important;
|
||||
}
|
||||
.reveal section:last-of-type {
|
||||
page-break-after: avoid !important;
|
||||
}
|
||||
.reveal section .fragment {
|
||||
opacity: 1 !important;
|
||||
visibility: visible !important;
|
||||
|
||||
-webkit-transform: none !important;
|
||||
-moz-transform: none !important;
|
||||
-ms-transform: none !important;
|
||||
transform: none !important;
|
||||
}
|
||||
.reveal section img {
|
||||
display: block;
|
||||
margin: 15px 0px;
|
||||
background: rgba(255,255,255,1);
|
||||
border: 1px solid #666;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.reveal section small {
|
||||
font-size: 0.8em;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,157 +0,0 @@
|
||||
/* Default Print Stylesheet Template
|
||||
by Rob Glazebrook of CSSnewbie.com
|
||||
Last Updated: June 4, 2008
|
||||
|
||||
Feel free (nay, compelled) to edit, append, and
|
||||
manipulate this file as you see fit. */
|
||||
|
||||
|
||||
/* SECTION 1: Set default width, margin, float, and
|
||||
background. This prevents elements from extending
|
||||
beyond the edge of the printed page, and prevents
|
||||
unnecessary background images from printing */
|
||||
|
||||
* {
|
||||
-webkit-print-color-adjust: exact;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0 auto !important;
|
||||
border: 0;
|
||||
padding: 0;
|
||||
float: none !important;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
html {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
/* SECTION 2: Remove any elements not needed in print.
|
||||
This would include navigation, ads, sidebars, etc. */
|
||||
.nestedarrow,
|
||||
.reveal .controls,
|
||||
.reveal .progress,
|
||||
.reveal .slide-number,
|
||||
.reveal .playback,
|
||||
.reveal.overview,
|
||||
.fork-reveal,
|
||||
.share-reveal,
|
||||
.state-background {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
/* SECTION 3: Set body font face, size, and color.
|
||||
Consider using a serif font for readability. */
|
||||
body, p, td, li, div {
|
||||
|
||||
}
|
||||
|
||||
/* SECTION 4: Set heading font face, sizes, and color.
|
||||
Differentiate your headings from your body text.
|
||||
Perhaps use a large sans-serif for distinction. */
|
||||
h1,h2,h3,h4,h5,h6 {
|
||||
text-shadow: 0 0 0 #000 !important;
|
||||
}
|
||||
|
||||
.reveal pre code {
|
||||
overflow: hidden !important;
|
||||
font-family: Courier, 'Courier New', monospace !important;
|
||||
}
|
||||
|
||||
|
||||
/* SECTION 5: more reveal.js specific additions by @skypanther */
|
||||
ul, ol, div, p {
|
||||
visibility: visible;
|
||||
position: static;
|
||||
width: auto;
|
||||
height: auto;
|
||||
display: block;
|
||||
overflow: visible;
|
||||
margin: auto;
|
||||
}
|
||||
.reveal {
|
||||
width: auto !important;
|
||||
height: auto !important;
|
||||
overflow: hidden !important;
|
||||
}
|
||||
.reveal .slides {
|
||||
position: static;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
|
||||
left: auto;
|
||||
top: auto;
|
||||
margin: 0 !important;
|
||||
padding: 0 !important;
|
||||
|
||||
overflow: visible;
|
||||
display: block;
|
||||
|
||||
-webkit-perspective: none;
|
||||
-moz-perspective: none;
|
||||
-ms-perspective: none;
|
||||
perspective: none;
|
||||
|
||||
-webkit-perspective-origin: 50% 50%; /* there isn't a none/auto value but 50-50 is the default */
|
||||
-moz-perspective-origin: 50% 50%;
|
||||
-ms-perspective-origin: 50% 50%;
|
||||
perspective-origin: 50% 50%;
|
||||
}
|
||||
.reveal .slides section {
|
||||
page-break-after: always !important;
|
||||
|
||||
visibility: visible !important;
|
||||
position: relative !important;
|
||||
display: block !important;
|
||||
position: relative !important;
|
||||
|
||||
margin: 0 !important;
|
||||
padding: 0 !important;
|
||||
box-sizing: border-box !important;
|
||||
min-height: 1px;
|
||||
|
||||
opacity: 1 !important;
|
||||
|
||||
-webkit-transform-style: flat !important;
|
||||
-moz-transform-style: flat !important;
|
||||
-ms-transform-style: flat !important;
|
||||
transform-style: flat !important;
|
||||
|
||||
-webkit-transform: none !important;
|
||||
-moz-transform: none !important;
|
||||
-ms-transform: none !important;
|
||||
transform: none !important;
|
||||
}
|
||||
.reveal section.stack {
|
||||
margin: 0 !important;
|
||||
padding: 0 !important;
|
||||
page-break-after: avoid !important;
|
||||
height: auto !important;
|
||||
min-height: auto !important;
|
||||
}
|
||||
.reveal img {
|
||||
box-shadow: none;
|
||||
}
|
||||
.reveal .roll {
|
||||
overflow: visible;
|
||||
line-height: 1em;
|
||||
}
|
||||
|
||||
/* Slide backgrounds are placed inside of their slide when exporting to PDF */
|
||||
.reveal section .slide-background {
|
||||
display: block !important;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
z-index: -1;
|
||||
}
|
||||
/* All elements should be above the slide-background */
|
||||
.reveal section>* {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
## Dependencies
|
||||
|
||||
Themes are written using Sass to keep things modular and reduce the need for repeated selectors across files. Make sure that you have the reveal.js development environment including the Grunt dependencies installed before proceding: https://github.com/hakimel/reveal.js#full-setup
|
||||
|
||||
## Creating a Theme
|
||||
|
||||
To create your own theme, start by duplicating any ```.scss``` file in [/css/theme/source](https://github.com/hakimel/reveal.js/blob/master/css/theme/source) and adding it to the compilation list in the [Gruntfile](https://github.com/hakimel/reveal.js/blob/master/Gruntfile.js).
|
||||
|
||||
Each theme file does four things in the following order:
|
||||
|
||||
1. **Include [/css/theme/template/mixins.scss](https://github.com/hakimel/reveal.js/blob/master/css/theme/template/mixins.scss)**
|
||||
Shared utility functions.
|
||||
|
||||
2. **Include [/css/theme/template/settings.scss](https://github.com/hakimel/reveal.js/blob/master/css/theme/template/settings.scss)**
|
||||
Declares a set of custom variables that the template file (step 4) expects. Can be overridden in step 3.
|
||||
|
||||
3. **Override**
|
||||
This is where you override the default theme. Either by specifying variables (see [settings.scss](https://github.com/hakimel/reveal.js/blob/master/css/theme/template/settings.scss) for reference) or by adding any selectors and styles you please.
|
||||
|
||||
4. **Include [/css/theme/template/theme.scss](https://github.com/hakimel/reveal.js/blob/master/css/theme/template/theme.scss)**
|
||||
The template theme file which will generate final CSS output based on the currently defined variables.
|
||||
|
||||
When you are done, run `grunt css-themes` to compile the Sass file to CSS and you are ready to use your new theme.
|
||||
@@ -1,154 +0,0 @@
|
||||
@import url(https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic);
|
||||
/**
|
||||
* Beige theme for reveal.js.
|
||||
*
|
||||
* Copyright (C) 2011-2012 Hakim El Hattab, http://hakim.se
|
||||
*/
|
||||
/* changed by hpl from 36px; */
|
||||
/* changed by hpl from 'League Gothic', Impact, sans-serif; */
|
||||
/* changed by hpl from uppercase; */
|
||||
@font-face {
|
||||
font-family: 'League Gothic';
|
||||
src: url("../../lib/font/league_gothic-webfont.eot");
|
||||
src: url("../../lib/font/league_gothic-webfont.eot?#iefix") format("embedded-opentype"), url("../../lib/font/league_gothic-webfont.woff") format("woff"), url("../../lib/font/league_gothic-webfont.ttf") format("truetype"), url("../../lib/font/league_gothic-webfont.svg#LeagueGothicRegular") format("svg");
|
||||
font-weight: normal;
|
||||
font-style: normal; }
|
||||
|
||||
/* changed (by hpl) from #333; */
|
||||
/*********************************************
|
||||
* GLOBAL STYLES
|
||||
*********************************************/
|
||||
body {
|
||||
background: #f7f2d3;
|
||||
background: -moz-radial-gradient(center, circle cover, white 0%, #f7f2d3 100%);
|
||||
background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%, white), color-stop(100%, #f7f2d3));
|
||||
background: -webkit-radial-gradient(center, circle cover, white 0%, #f7f2d3 100%);
|
||||
background: -o-radial-gradient(center, circle cover, white 0%, #f7f2d3 100%);
|
||||
background: -ms-radial-gradient(center, circle cover, white 0%, #f7f2d3 100%);
|
||||
background: radial-gradient(center, circle cover, white 0%, #f7f2d3 100%);
|
||||
background-color: #f7f3de; }
|
||||
|
||||
.reveal {
|
||||
font-family: "Lato", sans-serif;
|
||||
font-size: 30px;
|
||||
font-weight: normal;
|
||||
letter-spacing: -0.02em;
|
||||
color: #333333; }
|
||||
|
||||
::selection {
|
||||
color: white;
|
||||
background: rgba(79, 64, 28, 0.99);
|
||||
text-shadow: none; }
|
||||
|
||||
/*********************************************
|
||||
* HEADERS
|
||||
*********************************************/
|
||||
.reveal h1,
|
||||
.reveal h2,
|
||||
.reveal h3,
|
||||
.reveal h4,
|
||||
.reveal h5,
|
||||
.reveal h6 {
|
||||
margin: 0 0 20px 0;
|
||||
color: #222222;
|
||||
font-family: "Helvetica", Impact, sans-serif;
|
||||
line-height: 1.1em; /* changed (by hpl) from 0.9em */
|
||||
letter-spacing: 0.02em;
|
||||
text-transform: none;
|
||||
text-shadow: none; }
|
||||
|
||||
.reveal h1 {
|
||||
line-height: 1.2em;
|
||||
/* added by hpl */
|
||||
text-shadow: 0 1px 0 #cccccc, 0 2px 0 #c9c9c9, 0 3px 0 #bbbbbb, 0 4px 0 #b9b9b9, 0 5px 0 #aaaaaa, 0 6px 1px rgba(0, 0, 0, 0.1), 0 0 5px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.3), 0 3px 5px rgba(0, 0, 0, 0.2), 0 5px 10px rgba(0, 0, 0, 0.25), 0 20px 20px rgba(0, 0, 0, 0.15); }
|
||||
|
||||
/*********************************************
|
||||
* LINKS
|
||||
*********************************************/
|
||||
.reveal a:not(.image) {
|
||||
color: #8b743d;
|
||||
text-decoration: none;
|
||||
-webkit-transition: color .15s ease;
|
||||
-moz-transition: color .15s ease;
|
||||
-ms-transition: color .15s ease;
|
||||
-o-transition: color .15s ease;
|
||||
transition: color .15s ease; }
|
||||
|
||||
.reveal a:not(.image):hover {
|
||||
color: #c0a86e;
|
||||
text-shadow: none;
|
||||
border: none; }
|
||||
|
||||
.reveal .roll span:after {
|
||||
color: #fff;
|
||||
background: #564826; }
|
||||
|
||||
/*********************************************
|
||||
* IMAGES
|
||||
*********************************************/
|
||||
.reveal section img {
|
||||
margin: 15px 0px;
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
border: 4px solid #333333;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.15);
|
||||
-webkit-transition: all .2s linear;
|
||||
-moz-transition: all .2s linear;
|
||||
-ms-transition: all .2s linear;
|
||||
-o-transition: all .2s linear;
|
||||
transition: all .2s linear; }
|
||||
|
||||
.reveal a:hover img {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
border-color: #8b743d;
|
||||
box-shadow: 0 0 20px rgba(0, 0, 0, 0.55); }
|
||||
|
||||
/*********************************************
|
||||
* NAVIGATION CONTROLS
|
||||
*********************************************/
|
||||
.reveal .controls div.navigate-left,
|
||||
.reveal .controls div.navigate-left.enabled {
|
||||
border-right-color: #8b743d; }
|
||||
|
||||
.reveal .controls div.navigate-right,
|
||||
.reveal .controls div.navigate-right.enabled {
|
||||
border-left-color: #8b743d; }
|
||||
|
||||
.reveal .controls div.navigate-up,
|
||||
.reveal .controls div.navigate-up.enabled {
|
||||
border-bottom-color: #8b743d; }
|
||||
|
||||
.reveal .controls div.navigate-down,
|
||||
.reveal .controls div.navigate-down.enabled {
|
||||
border-top-color: #8b743d; }
|
||||
|
||||
.reveal .controls div.navigate-left.enabled:hover {
|
||||
border-right-color: #c0a86e; }
|
||||
|
||||
.reveal .controls div.navigate-right.enabled:hover {
|
||||
border-left-color: #c0a86e; }
|
||||
|
||||
.reveal .controls div.navigate-up.enabled:hover {
|
||||
border-bottom-color: #c0a86e; }
|
||||
|
||||
.reveal .controls div.navigate-down.enabled:hover {
|
||||
border-top-color: #c0a86e; }
|
||||
|
||||
/*********************************************
|
||||
* PROGRESS BAR
|
||||
*********************************************/
|
||||
.reveal .progress {
|
||||
background: rgba(0, 0, 0, 0.2); }
|
||||
|
||||
.reveal .progress span {
|
||||
background: #8b743d;
|
||||
-webkit-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
-moz-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
-ms-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
-o-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985); }
|
||||
|
||||
/*********************************************
|
||||
* SLIDE NUMBER
|
||||
*********************************************/
|
||||
.reveal .slide-number {
|
||||
color: #8b743d; }
|
||||
@@ -1,155 +0,0 @@
|
||||
@import url(https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic);
|
||||
/**
|
||||
* Beige theme for reveal.js.
|
||||
*
|
||||
* Copyright (C) 2011-2012 Hakim El Hattab, http://hakim.se
|
||||
*/
|
||||
/* changed by hpl from 36px; */
|
||||
/* changed by hpl from 'League Gothic', Impact, sans-serif; */
|
||||
/* changed by hpl from uppercase; */
|
||||
@font-face {
|
||||
font-family: 'League Gothic';
|
||||
src: url("../../lib/font/league_gothic-webfont.eot");
|
||||
src: url("../../lib/font/league_gothic-webfont.eot?#iefix") format("embedded-opentype"), url("../../lib/font/league_gothic-webfont.woff") format("woff"), url("../../lib/font/league_gothic-webfont.ttf") format("truetype"), url("../../lib/font/league_gothic-webfont.svg#LeagueGothicRegular") format("svg");
|
||||
font-weight: normal;
|
||||
font-style: normal; }
|
||||
|
||||
/* added/changed by hpl */
|
||||
/* changed (by hpl) from #333; */
|
||||
/*********************************************
|
||||
* GLOBAL STYLES
|
||||
*********************************************/
|
||||
body {
|
||||
background: #f7f2d3;
|
||||
background: -moz-radial-gradient(center, circle cover, white 0%, #f7f2d3 100%);
|
||||
background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%, white), color-stop(100%, #f7f2d3));
|
||||
background: -webkit-radial-gradient(center, circle cover, white 0%, #f7f2d3 100%);
|
||||
background: -o-radial-gradient(center, circle cover, white 0%, #f7f2d3 100%);
|
||||
background: -ms-radial-gradient(center, circle cover, white 0%, #f7f2d3 100%);
|
||||
background: radial-gradient(center, circle cover, white 0%, #f7f2d3 100%);
|
||||
background-color: #f7f3de; }
|
||||
|
||||
.reveal {
|
||||
font-family: "Lato", sans-serif;
|
||||
font-size: 25px;
|
||||
font-weight: normal;
|
||||
letter-spacing: -0.02em;
|
||||
color: #333333; }
|
||||
|
||||
::selection {
|
||||
color: white;
|
||||
background: rgba(79, 64, 28, 0.99);
|
||||
text-shadow: none; }
|
||||
|
||||
/*********************************************
|
||||
* HEADERS
|
||||
*********************************************/
|
||||
.reveal h1,
|
||||
.reveal h2,
|
||||
.reveal h3,
|
||||
.reveal h4,
|
||||
.reveal h5,
|
||||
.reveal h6 {
|
||||
margin: 0 0 20px 0;
|
||||
color: #222222;
|
||||
font-family: "Helvetica", Impact, sans-serif;
|
||||
line-height: 1.1em; /* changed (by hpl) from 0.9em */
|
||||
letter-spacing: 0.02em;
|
||||
text-transform: none;
|
||||
text-shadow: none; }
|
||||
|
||||
.reveal h1 {
|
||||
line-height: 1.2em;
|
||||
/* added by hpl */
|
||||
text-shadow: 0 1px 0 #cccccc, 0 2px 0 #c9c9c9, 0 3px 0 #bbbbbb, 0 4px 0 #b9b9b9, 0 5px 0 #aaaaaa, 0 6px 1px rgba(0, 0, 0, 0.1), 0 0 5px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.3), 0 3px 5px rgba(0, 0, 0, 0.2), 0 5px 10px rgba(0, 0, 0, 0.25), 0 20px 20px rgba(0, 0, 0, 0.15); }
|
||||
|
||||
/*********************************************
|
||||
* LINKS
|
||||
*********************************************/
|
||||
.reveal a:not(.image) {
|
||||
color: #8b743d;
|
||||
text-decoration: none;
|
||||
-webkit-transition: color .15s ease;
|
||||
-moz-transition: color .15s ease;
|
||||
-ms-transition: color .15s ease;
|
||||
-o-transition: color .15s ease;
|
||||
transition: color .15s ease; }
|
||||
|
||||
.reveal a:not(.image):hover {
|
||||
color: #c0a86e;
|
||||
text-shadow: none;
|
||||
border: none; }
|
||||
|
||||
.reveal .roll span:after {
|
||||
color: #fff;
|
||||
background: #564826; }
|
||||
|
||||
/*********************************************
|
||||
* IMAGES
|
||||
*********************************************/
|
||||
.reveal section img {
|
||||
margin: 15px 0px;
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
border: 4px solid #333333;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.15);
|
||||
-webkit-transition: all .2s linear;
|
||||
-moz-transition: all .2s linear;
|
||||
-ms-transition: all .2s linear;
|
||||
-o-transition: all .2s linear;
|
||||
transition: all .2s linear; }
|
||||
|
||||
.reveal a:hover img {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
border-color: #8b743d;
|
||||
box-shadow: 0 0 20px rgba(0, 0, 0, 0.55); }
|
||||
|
||||
/*********************************************
|
||||
* NAVIGATION CONTROLS
|
||||
*********************************************/
|
||||
.reveal .controls div.navigate-left,
|
||||
.reveal .controls div.navigate-left.enabled {
|
||||
border-right-color: #8b743d; }
|
||||
|
||||
.reveal .controls div.navigate-right,
|
||||
.reveal .controls div.navigate-right.enabled {
|
||||
border-left-color: #8b743d; }
|
||||
|
||||
.reveal .controls div.navigate-up,
|
||||
.reveal .controls div.navigate-up.enabled {
|
||||
border-bottom-color: #8b743d; }
|
||||
|
||||
.reveal .controls div.navigate-down,
|
||||
.reveal .controls div.navigate-down.enabled {
|
||||
border-top-color: #8b743d; }
|
||||
|
||||
.reveal .controls div.navigate-left.enabled:hover {
|
||||
border-right-color: #c0a86e; }
|
||||
|
||||
.reveal .controls div.navigate-right.enabled:hover {
|
||||
border-left-color: #c0a86e; }
|
||||
|
||||
.reveal .controls div.navigate-up.enabled:hover {
|
||||
border-bottom-color: #c0a86e; }
|
||||
|
||||
.reveal .controls div.navigate-down.enabled:hover {
|
||||
border-top-color: #c0a86e; }
|
||||
|
||||
/*********************************************
|
||||
* PROGRESS BAR
|
||||
*********************************************/
|
||||
.reveal .progress {
|
||||
background: rgba(0, 0, 0, 0.2); }
|
||||
|
||||
.reveal .progress span {
|
||||
background: #8b743d;
|
||||
-webkit-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
-moz-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
-ms-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
-o-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985); }
|
||||
|
||||
/*********************************************
|
||||
* SLIDE NUMBER
|
||||
*********************************************/
|
||||
.reveal .slide-number {
|
||||
color: #8b743d; }
|
||||
@@ -1,273 +0,0 @@
|
||||
@import url(../../lib/font/source-sans-pro/source-sans-pro.css);
|
||||
/**
|
||||
* Black theme for reveal.js. This is the opposite of the 'white' theme.
|
||||
*
|
||||
* Copyright (C) 2015 Hakim El Hattab, http://hakim.se
|
||||
*/
|
||||
section.has-light-background, section.has-light-background h1, section.has-light-background h2, section.has-light-background h3, section.has-light-background h4, section.has-light-background h5, section.has-light-background h6 {
|
||||
color: #222; }
|
||||
|
||||
/*********************************************
|
||||
* GLOBAL STYLES
|
||||
*********************************************/
|
||||
body {
|
||||
background: #222;
|
||||
background-color: #222; }
|
||||
|
||||
.reveal {
|
||||
font-family: 'Source Sans Pro', Helvetica, sans-serif;
|
||||
font-size: 30px; /* changed by hpl from 38px */
|
||||
font-weight: normal;
|
||||
color: #fff; }
|
||||
|
||||
::selection {
|
||||
color: #fff;
|
||||
background: #bee4fd;
|
||||
text-shadow: none; }
|
||||
|
||||
.reveal .slides > section, .reveal .slides > section > section {
|
||||
/* removed by hpl: line-height: 1.3; */
|
||||
font-weight: inherit; }
|
||||
|
||||
/*********************************************
|
||||
* HEADERS
|
||||
*********************************************/
|
||||
.reveal h1, .reveal h2, .reveal h3, .reveal h4, .reveal h5, .reveal h6 {
|
||||
margin: 0 0 20px 0;
|
||||
color: #fff;
|
||||
font-family: 'Source Sans Pro', Helvetica, sans-serif;
|
||||
font-weight: 600;
|
||||
line-height: 1.1em; /* changed by hpl from 1.2; */
|
||||
letter-spacing: normal;
|
||||
/* text-transform: uppercase; removed by hpl */
|
||||
text-shadow: none;
|
||||
word-wrap: break-word; }
|
||||
|
||||
.reveal h1 {
|
||||
line-height: 1.2em;
|
||||
}
|
||||
|
||||
/* Removed by hpl
|
||||
.reveal h1 {
|
||||
font-size: 2.5em; }
|
||||
|
||||
.reveal h2 {
|
||||
font-size: 1.6em; }
|
||||
|
||||
.reveal h3 {
|
||||
font-size: 1.3em; }
|
||||
|
||||
.reveal h4 {
|
||||
font-size: 1em; }
|
||||
*/
|
||||
|
||||
.reveal h1 {
|
||||
text-shadow: none; }
|
||||
|
||||
/*********************************************
|
||||
* OTHER
|
||||
*********************************************/
|
||||
.reveal p {
|
||||
margin: 20px 0;
|
||||
line-height: 1.3; }
|
||||
|
||||
/* Ensure certain elements are never larger than the slide itself */
|
||||
.reveal img, .reveal video, .reveal iframe {
|
||||
max-width: 95%;
|
||||
max-height: 95%; }
|
||||
|
||||
.reveal strong, .reveal b {
|
||||
font-weight: bold; }
|
||||
|
||||
.reveal em {
|
||||
font-style: italic; }
|
||||
|
||||
.reveal ol, .reveal dl, .reveal ul {
|
||||
display: inline-block;
|
||||
text-align: left;
|
||||
margin: 0 0 0 1em; }
|
||||
|
||||
.reveal ol {
|
||||
list-style-type: decimal; }
|
||||
|
||||
.reveal ul {
|
||||
list-style-type: disc; }
|
||||
|
||||
.reveal ul ul {
|
||||
list-style-type: square; }
|
||||
|
||||
.reveal ul ul ul {
|
||||
list-style-type: circle; }
|
||||
|
||||
.reveal ul ul, .reveal ul ol, .reveal ol ol, .reveal ol ul {
|
||||
display: block;
|
||||
margin-left: 40px; }
|
||||
|
||||
.reveal dt {
|
||||
font-weight: bold; }
|
||||
|
||||
.reveal dd {
|
||||
margin-left: 40px; }
|
||||
|
||||
.reveal q, .reveal blockquote {
|
||||
quotes: none; }
|
||||
|
||||
.reveal blockquote {
|
||||
display: block;
|
||||
position: relative;
|
||||
width: 70%;
|
||||
margin: 20px auto;
|
||||
padding: 5px;
|
||||
font-style: italic;
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
box-shadow: 0px 0px 2px rgba(0, 0, 0, 0.2); }
|
||||
|
||||
.reveal blockquote p:first-child, .reveal blockquote p:last-child {
|
||||
display: inline-block; }
|
||||
|
||||
.reveal q {
|
||||
font-style: italic; }
|
||||
|
||||
.reveal pre {
|
||||
display: block;
|
||||
position: relative;
|
||||
width: 90%;
|
||||
margin: 20px auto;
|
||||
text-align: left;
|
||||
font-size: 0.55em;
|
||||
font-family: monospace;
|
||||
line-height: 1.2em;
|
||||
word-wrap: break-word;
|
||||
box-shadow: 0px 0px 6px rgba(0, 0, 0, 0.3); }
|
||||
|
||||
.reveal code {
|
||||
font-family: monospace; }
|
||||
|
||||
.reveal pre code {
|
||||
display: block;
|
||||
padding: 5px;
|
||||
overflow: auto;
|
||||
max-height: 400px;
|
||||
word-wrap: normal;
|
||||
background: #3F3F3F;
|
||||
color: #DCDCDC; }
|
||||
|
||||
.reveal table {
|
||||
margin: auto;
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0; }
|
||||
|
||||
.reveal table th {
|
||||
font-weight: bold; }
|
||||
|
||||
.reveal table th, .reveal table td {
|
||||
/*text-align: left; */ /* hpl modification */
|
||||
padding: 0.2em 0.5em 0.2em 0.5em;
|
||||
border-bottom: 1px solid; }
|
||||
|
||||
.reveal table th[align="center"], .reveal table td[align="center"] {
|
||||
text-align: center; }
|
||||
|
||||
.reveal table th[align="right"], .reveal table td[align="right"] {
|
||||
text-align: right; }
|
||||
|
||||
.reveal table tr:last-child td {
|
||||
border-bottom: none; }
|
||||
|
||||
.reveal sup {
|
||||
vertical-align: super; }
|
||||
|
||||
.reveal sub {
|
||||
vertical-align: sub; }
|
||||
|
||||
.reveal small {
|
||||
display: inline-block;
|
||||
font-size: 0.6em;
|
||||
line-height: 1.2em;
|
||||
vertical-align: top; }
|
||||
|
||||
.reveal small * {
|
||||
vertical-align: top; }
|
||||
|
||||
/*********************************************
|
||||
* LINKS
|
||||
*********************************************/
|
||||
.reveal a {
|
||||
color: #42affa;
|
||||
text-decoration: none;
|
||||
-webkit-transition: color 0.15s ease;
|
||||
-moz-transition: color 0.15s ease;
|
||||
transition: color 0.15s ease; }
|
||||
|
||||
.reveal a:hover {
|
||||
color: #8dcffc;
|
||||
text-shadow: none;
|
||||
border: none; }
|
||||
|
||||
.reveal .roll span:after {
|
||||
color: #fff;
|
||||
background: #068ee9; }
|
||||
|
||||
/*********************************************
|
||||
* IMAGES
|
||||
*********************************************/
|
||||
.reveal section img {
|
||||
margin: 15px 0px;
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
border: 4px solid #fff;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.15); }
|
||||
|
||||
.reveal a img {
|
||||
-webkit-transition: all 0.15s linear;
|
||||
-moz-transition: all 0.15s linear;
|
||||
transition: all 0.15s linear; }
|
||||
|
||||
.reveal a:hover img {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
border-color: #42affa;
|
||||
box-shadow: 0 0 20px rgba(0, 0, 0, 0.55); }
|
||||
|
||||
/*********************************************
|
||||
* NAVIGATION CONTROLS
|
||||
*********************************************/
|
||||
.reveal .controls div.navigate-left, .reveal .controls div.navigate-left.enabled {
|
||||
border-right-color: #42affa; }
|
||||
|
||||
.reveal .controls div.navigate-right, .reveal .controls div.navigate-right.enabled {
|
||||
border-left-color: #42affa; }
|
||||
|
||||
.reveal .controls div.navigate-up, .reveal .controls div.navigate-up.enabled {
|
||||
border-bottom-color: #42affa; }
|
||||
|
||||
.reveal .controls div.navigate-down, .reveal .controls div.navigate-down.enabled {
|
||||
border-top-color: #42affa; }
|
||||
|
||||
.reveal .controls div.navigate-left.enabled:hover {
|
||||
border-right-color: #8dcffc; }
|
||||
|
||||
.reveal .controls div.navigate-right.enabled:hover {
|
||||
border-left-color: #8dcffc; }
|
||||
|
||||
.reveal .controls div.navigate-up.enabled:hover {
|
||||
border-bottom-color: #8dcffc; }
|
||||
|
||||
.reveal .controls div.navigate-down.enabled:hover {
|
||||
border-top-color: #8dcffc; }
|
||||
|
||||
/*********************************************
|
||||
* PROGRESS BAR
|
||||
*********************************************/
|
||||
.reveal .progress {
|
||||
background: rgba(0, 0, 0, 0.2); }
|
||||
|
||||
.reveal .progress span {
|
||||
background: #42affa;
|
||||
-webkit-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
-moz-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985); }
|
||||
|
||||
/*********************************************
|
||||
* SLIDE NUMBER
|
||||
*********************************************/
|
||||
.reveal .slide-number {
|
||||
color: #42affa; }
|
||||
@@ -1,180 +0,0 @@
|
||||
@import url(https://fonts.googleapis.com/css?family=Ubuntu:300,700,300italic,700italic);
|
||||
/**
|
||||
* Blood theme for reveal.js
|
||||
* Author: Walther http://github.com/Walther
|
||||
*
|
||||
* Designed to be used with highlight.js theme
|
||||
* "monokai_sublime.css" available from
|
||||
* https://github.com/isagalaev/highlight.js/
|
||||
*
|
||||
* For other themes, change $codeBackground accordingly.
|
||||
*
|
||||
*/
|
||||
/* changed by hpl from 36px; */
|
||||
/* changed by hpl from 'League Gothic', Impact, sans-serif; */
|
||||
/* changed by hpl from uppercase; */
|
||||
/*********************************************
|
||||
* GLOBAL STYLES
|
||||
*********************************************/
|
||||
body {
|
||||
background: #222222;
|
||||
background: -moz-radial-gradient(center, circle cover, #626262 0%, #222222 100%);
|
||||
background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%, #626262), color-stop(100%, #222222));
|
||||
background: -webkit-radial-gradient(center, circle cover, #626262 0%, #222222 100%);
|
||||
background: -o-radial-gradient(center, circle cover, #626262 0%, #222222 100%);
|
||||
background: -ms-radial-gradient(center, circle cover, #626262 0%, #222222 100%);
|
||||
background: radial-gradient(center, circle cover, #626262 0%, #222222 100%);
|
||||
background-color: #2b2b2b; }
|
||||
|
||||
.reveal {
|
||||
font-family: Ubuntu, "sans-serif";
|
||||
font-size: 30px;
|
||||
font-weight: normal;
|
||||
letter-spacing: -0.02em;
|
||||
color: #eeeeee; }
|
||||
|
||||
::selection {
|
||||
color: white;
|
||||
background: #aa2233;
|
||||
text-shadow: none; }
|
||||
|
||||
/*********************************************
|
||||
* HEADERS
|
||||
*********************************************/
|
||||
.reveal h1,
|
||||
.reveal h2,
|
||||
.reveal h3,
|
||||
.reveal h4,
|
||||
.reveal h5,
|
||||
.reveal h6 {
|
||||
margin: 0 0 20px 0;
|
||||
color: #eeeeee;
|
||||
font-family: Ubuntu, "sans-serif";
|
||||
line-height: 1.1em; /* changed (by hpl) from 0.9em */
|
||||
letter-spacing: 0.02em;
|
||||
text-transform: none;
|
||||
text-shadow: 2px 2px 2px #222222; }
|
||||
|
||||
.reveal h1 {
|
||||
line-height: 1.2em;
|
||||
/* added by hpl */
|
||||
text-shadow: 0 1px 0 #cccccc, 0 2px 0 #c9c9c9, 0 3px 0 #bbbbbb, 0 4px 0 #b9b9b9, 0 5px 0 #aaaaaa, 0 6px 1px rgba(0, 0, 0, 0.1), 0 0 5px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.3), 0 3px 5px rgba(0, 0, 0, 0.2), 0 5px 10px rgba(0, 0, 0, 0.25), 0 20px 20px rgba(0, 0, 0, 0.15); }
|
||||
|
||||
/*********************************************
|
||||
* LINKS
|
||||
*********************************************/
|
||||
.reveal a:not(.image) {
|
||||
color: #aa2233;
|
||||
text-decoration: none;
|
||||
-webkit-transition: color .15s ease;
|
||||
-moz-transition: color .15s ease;
|
||||
-ms-transition: color .15s ease;
|
||||
-o-transition: color .15s ease;
|
||||
transition: color .15s ease; }
|
||||
|
||||
.reveal a:not(.image):hover {
|
||||
color: #dd5566;
|
||||
text-shadow: none;
|
||||
border: none; }
|
||||
|
||||
.reveal .roll span:after {
|
||||
color: #fff;
|
||||
background: #6a1520; }
|
||||
|
||||
/*********************************************
|
||||
* IMAGES
|
||||
*********************************************/
|
||||
.reveal section img {
|
||||
margin: 15px 0px;
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
border: 4px solid #eeeeee;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.15);
|
||||
-webkit-transition: all .2s linear;
|
||||
-moz-transition: all .2s linear;
|
||||
-ms-transition: all .2s linear;
|
||||
-o-transition: all .2s linear;
|
||||
transition: all .2s linear; }
|
||||
|
||||
.reveal a:hover img {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
border-color: #aa2233;
|
||||
box-shadow: 0 0 20px rgba(0, 0, 0, 0.55); }
|
||||
|
||||
/*********************************************
|
||||
* NAVIGATION CONTROLS
|
||||
*********************************************/
|
||||
.reveal .controls div.navigate-left,
|
||||
.reveal .controls div.navigate-left.enabled {
|
||||
border-right-color: #aa2233; }
|
||||
|
||||
.reveal .controls div.navigate-right,
|
||||
.reveal .controls div.navigate-right.enabled {
|
||||
border-left-color: #aa2233; }
|
||||
|
||||
.reveal .controls div.navigate-up,
|
||||
.reveal .controls div.navigate-up.enabled {
|
||||
border-bottom-color: #aa2233; }
|
||||
|
||||
.reveal .controls div.navigate-down,
|
||||
.reveal .controls div.navigate-down.enabled {
|
||||
border-top-color: #aa2233; }
|
||||
|
||||
.reveal .controls div.navigate-left.enabled:hover {
|
||||
border-right-color: #dd5566; }
|
||||
|
||||
.reveal .controls div.navigate-right.enabled:hover {
|
||||
border-left-color: #dd5566; }
|
||||
|
||||
.reveal .controls div.navigate-up.enabled:hover {
|
||||
border-bottom-color: #dd5566; }
|
||||
|
||||
.reveal .controls div.navigate-down.enabled:hover {
|
||||
border-top-color: #dd5566; }
|
||||
|
||||
/*********************************************
|
||||
* PROGRESS BAR
|
||||
*********************************************/
|
||||
.reveal .progress {
|
||||
background: rgba(0, 0, 0, 0.2); }
|
||||
|
||||
.reveal .progress span {
|
||||
background: #aa2233;
|
||||
-webkit-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
-moz-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
-ms-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
-o-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985); }
|
||||
|
||||
/*********************************************
|
||||
* SLIDE NUMBER
|
||||
*********************************************/
|
||||
.reveal .slide-number {
|
||||
color: #aa2233; }
|
||||
|
||||
.reveal p {
|
||||
font-weight: 300;
|
||||
text-shadow: 1px 1px #222222; }
|
||||
|
||||
.reveal h1,
|
||||
.reveal h2,
|
||||
.reveal h3,
|
||||
.reveal h4,
|
||||
.reveal h5,
|
||||
.reveal h6 {
|
||||
font-weight: 700; }
|
||||
|
||||
.reveal a:not(.image),
|
||||
.reveal a:not(.image):hover {
|
||||
text-shadow: 2px 2px 2px #000; }
|
||||
|
||||
.reveal small a:not(.image),
|
||||
.reveal small a:not(.image):hover {
|
||||
text-shadow: 1px 1px 1px #000; }
|
||||
|
||||
.reveal p code {
|
||||
background-color: #23241f;
|
||||
display: inline-block;
|
||||
border-radius: 7px; }
|
||||
|
||||
.reveal small code {
|
||||
vertical-align: baseline; }
|
||||
@@ -1,144 +0,0 @@
|
||||
@import url(https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic);
|
||||
/**
|
||||
* A simple theme for reveal.js presentations, similar
|
||||
* to the default theme. The accent color is darkblue.
|
||||
*
|
||||
* This theme is Copyright (C) 2012 Owen Versteeg, https://github.com/StereotypicalApps. It is MIT licensed.
|
||||
* reveal.js is Copyright (C) 2011-2012 Hakim El Hattab, http://hakim.se
|
||||
|
||||
* Center for Biomedical Computing theme made by Hans Petter Langtangen.
|
||||
*/
|
||||
/* changed by hpl from 36px; */
|
||||
/* changed by hpl from 'League Gothic', Impact, sans-serif; */
|
||||
/* changed by hpl from uppercase; */
|
||||
/*********************************************
|
||||
* GLOBAL STYLES
|
||||
*********************************************/
|
||||
body {
|
||||
background: white;
|
||||
background-color: white; }
|
||||
|
||||
.reveal {
|
||||
font-family: "Lato", sans-serif;
|
||||
font-size: 30px;
|
||||
font-weight: normal;
|
||||
letter-spacing: -0.02em;
|
||||
color: #404040; }
|
||||
|
||||
::selection {
|
||||
color: white;
|
||||
background: rgba(0, 0, 0, 0.99);
|
||||
text-shadow: none; }
|
||||
|
||||
/*********************************************
|
||||
* HEADERS
|
||||
*********************************************/
|
||||
.reveal h1,
|
||||
.reveal h2,
|
||||
.reveal h3,
|
||||
.reveal h4,
|
||||
.reveal h5,
|
||||
.reveal h6 {
|
||||
margin: 0 0 20px 0;
|
||||
color: #8a0808;
|
||||
font-family: "Helvetica", Impact, sans-serif;
|
||||
line-height: 1.1em; /* changed (by hpl) from 0.9em */
|
||||
letter-spacing: 0.02em;
|
||||
text-transform: none;
|
||||
text-shadow: none; }
|
||||
|
||||
.reveal h1 {
|
||||
line-height: 1.2em;
|
||||
/* added by hpl */
|
||||
text-shadow: 0px 0px 6px rgba(0, 0, 0, 0.2); }
|
||||
|
||||
/*********************************************
|
||||
* LINKS
|
||||
*********************************************/
|
||||
.reveal a:not(.image) {
|
||||
color: #8a0808;
|
||||
text-decoration: none;
|
||||
-webkit-transition: color .15s ease;
|
||||
-moz-transition: color .15s ease;
|
||||
-ms-transition: color .15s ease;
|
||||
-o-transition: color .15s ease;
|
||||
transition: color .15s ease; }
|
||||
|
||||
.reveal a:not(.image):hover {
|
||||
color: #ea0e0e;
|
||||
text-shadow: none;
|
||||
border: none; }
|
||||
|
||||
.reveal .roll span:after {
|
||||
color: #fff;
|
||||
background: #420404; }
|
||||
|
||||
/*********************************************
|
||||
* IMAGES
|
||||
*********************************************/
|
||||
.reveal section img {
|
||||
margin: 15px 0px;
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
border: 4px solid #404040;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.15);
|
||||
-webkit-transition: all .2s linear;
|
||||
-moz-transition: all .2s linear;
|
||||
-ms-transition: all .2s linear;
|
||||
-o-transition: all .2s linear;
|
||||
transition: all .2s linear; }
|
||||
|
||||
.reveal a:hover img {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
border-color: #8a0808;
|
||||
box-shadow: 0 0 20px rgba(0, 0, 0, 0.55); }
|
||||
|
||||
/*********************************************
|
||||
* NAVIGATION CONTROLS
|
||||
*********************************************/
|
||||
.reveal .controls div.navigate-left,
|
||||
.reveal .controls div.navigate-left.enabled {
|
||||
border-right-color: #8a0808; }
|
||||
|
||||
.reveal .controls div.navigate-right,
|
||||
.reveal .controls div.navigate-right.enabled {
|
||||
border-left-color: #8a0808; }
|
||||
|
||||
.reveal .controls div.navigate-up,
|
||||
.reveal .controls div.navigate-up.enabled {
|
||||
border-bottom-color: #8a0808; }
|
||||
|
||||
.reveal .controls div.navigate-down,
|
||||
.reveal .controls div.navigate-down.enabled {
|
||||
border-top-color: #8a0808; }
|
||||
|
||||
.reveal .controls div.navigate-left.enabled:hover {
|
||||
border-right-color: #ea0e0e; }
|
||||
|
||||
.reveal .controls div.navigate-right.enabled:hover {
|
||||
border-left-color: #ea0e0e; }
|
||||
|
||||
.reveal .controls div.navigate-up.enabled:hover {
|
||||
border-bottom-color: #ea0e0e; }
|
||||
|
||||
.reveal .controls div.navigate-down.enabled:hover {
|
||||
border-top-color: #ea0e0e; }
|
||||
|
||||
/*********************************************
|
||||
* PROGRESS BAR
|
||||
*********************************************/
|
||||
.reveal .progress {
|
||||
background: rgba(0, 0, 0, 0.2); }
|
||||
|
||||
.reveal .progress span {
|
||||
background: #8a0808;
|
||||
-webkit-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
-moz-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
-ms-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
-o-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985); }
|
||||
|
||||
/*********************************************
|
||||
* SLIDE NUMBER
|
||||
*********************************************/
|
||||
.reveal .slide-number {
|
||||
color: #8a0808; }
|
||||
@@ -1,153 +0,0 @@
|
||||
@import url(https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic);
|
||||
/**
|
||||
* Default theme for reveal.js.
|
||||
*
|
||||
* Copyright (C) 2011-2012 Hakim El Hattab, http://hakim.se
|
||||
*/
|
||||
/* changed by hpl from 36px; */
|
||||
/* changed by hpl from 'League Gothic', Impact, sans-serif; */
|
||||
/* changed by hpl from uppercase; */
|
||||
@font-face {
|
||||
font-family: 'League Gothic';
|
||||
src: url("../../lib/font/league_gothic-webfont.eot");
|
||||
src: url("../../lib/font/league_gothic-webfont.eot?#iefix") format("embedded-opentype"), url("../../lib/font/league_gothic-webfont.woff") format("woff"), url("../../lib/font/league_gothic-webfont.ttf") format("truetype"), url("../../lib/font/league_gothic-webfont.svg#LeagueGothicRegular") format("svg");
|
||||
font-weight: normal;
|
||||
font-style: normal; }
|
||||
|
||||
/*********************************************
|
||||
* GLOBAL STYLES
|
||||
*********************************************/
|
||||
body {
|
||||
background: #1c1e20;
|
||||
background: -moz-radial-gradient(center, circle cover, #555a5f 0%, #1c1e20 100%);
|
||||
background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%, #555a5f), color-stop(100%, #1c1e20));
|
||||
background: -webkit-radial-gradient(center, circle cover, #555a5f 0%, #1c1e20 100%);
|
||||
background: -o-radial-gradient(center, circle cover, #555a5f 0%, #1c1e20 100%);
|
||||
background: -ms-radial-gradient(center, circle cover, #555a5f 0%, #1c1e20 100%);
|
||||
background: radial-gradient(center, circle cover, #555a5f 0%, #1c1e20 100%);
|
||||
background-color: #2b2b2b; }
|
||||
|
||||
.reveal {
|
||||
font-family: "Lato", sans-serif;
|
||||
font-size: 30px;
|
||||
font-weight: normal;
|
||||
letter-spacing: -0.02em;
|
||||
color: #eeeeee; }
|
||||
|
||||
::selection {
|
||||
color: white;
|
||||
background: #ff5e99;
|
||||
text-shadow: none; }
|
||||
|
||||
/*********************************************
|
||||
* HEADERS
|
||||
*********************************************/
|
||||
.reveal h1,
|
||||
.reveal h2,
|
||||
.reveal h3,
|
||||
.reveal h4,
|
||||
.reveal h5,
|
||||
.reveal h6 {
|
||||
margin: 0 0 20px 0;
|
||||
color: #eeeeee;
|
||||
font-family: "Helvetica", Impact, sans-serif;
|
||||
line-height: 1.1em; /* changed (by hpl) from 0.9em */
|
||||
letter-spacing: 0.02em;
|
||||
text-transform: none;
|
||||
text-shadow: 0px 0px 6px rgba(0, 0, 0, 0.2); }
|
||||
|
||||
.reveal h1 {
|
||||
line-height: 1.2em;
|
||||
/* added by hpl */
|
||||
text-shadow: 0 1px 0 #cccccc, 0 2px 0 #c9c9c9, 0 3px 0 #bbbbbb, 0 4px 0 #b9b9b9, 0 5px 0 #aaaaaa, 0 6px 1px rgba(0, 0, 0, 0.1), 0 0 5px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.3), 0 3px 5px rgba(0, 0, 0, 0.2), 0 5px 10px rgba(0, 0, 0, 0.25), 0 20px 20px rgba(0, 0, 0, 0.15); }
|
||||
|
||||
/*********************************************
|
||||
* LINKS
|
||||
*********************************************/
|
||||
.reveal a:not(.image) {
|
||||
color: #13daec;
|
||||
text-decoration: none;
|
||||
-webkit-transition: color .15s ease;
|
||||
-moz-transition: color .15s ease;
|
||||
-ms-transition: color .15s ease;
|
||||
-o-transition: color .15s ease;
|
||||
transition: color .15s ease; }
|
||||
|
||||
.reveal a:not(.image):hover {
|
||||
color: #71e9f4;
|
||||
text-shadow: none;
|
||||
border: none; }
|
||||
|
||||
.reveal .roll span:after {
|
||||
color: #fff;
|
||||
background: #0d99a5; }
|
||||
|
||||
/*********************************************
|
||||
* IMAGES
|
||||
*********************************************/
|
||||
.reveal section img {
|
||||
margin: 15px 0px;
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
border: 4px solid #eeeeee;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.15);
|
||||
-webkit-transition: all .2s linear;
|
||||
-moz-transition: all .2s linear;
|
||||
-ms-transition: all .2s linear;
|
||||
-o-transition: all .2s linear;
|
||||
transition: all .2s linear; }
|
||||
|
||||
.reveal a:hover img {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
border-color: #13daec;
|
||||
box-shadow: 0 0 20px rgba(0, 0, 0, 0.55); }
|
||||
|
||||
/*********************************************
|
||||
* NAVIGATION CONTROLS
|
||||
*********************************************/
|
||||
.reveal .controls div.navigate-left,
|
||||
.reveal .controls div.navigate-left.enabled {
|
||||
border-right-color: #13daec; }
|
||||
|
||||
.reveal .controls div.navigate-right,
|
||||
.reveal .controls div.navigate-right.enabled {
|
||||
border-left-color: #13daec; }
|
||||
|
||||
.reveal .controls div.navigate-up,
|
||||
.reveal .controls div.navigate-up.enabled {
|
||||
border-bottom-color: #13daec; }
|
||||
|
||||
.reveal .controls div.navigate-down,
|
||||
.reveal .controls div.navigate-down.enabled {
|
||||
border-top-color: #13daec; }
|
||||
|
||||
.reveal .controls div.navigate-left.enabled:hover {
|
||||
border-right-color: #71e9f4; }
|
||||
|
||||
.reveal .controls div.navigate-right.enabled:hover {
|
||||
border-left-color: #71e9f4; }
|
||||
|
||||
.reveal .controls div.navigate-up.enabled:hover {
|
||||
border-bottom-color: #71e9f4; }
|
||||
|
||||
.reveal .controls div.navigate-down.enabled:hover {
|
||||
border-top-color: #71e9f4; }
|
||||
|
||||
/*********************************************
|
||||
* PROGRESS BAR
|
||||
*********************************************/
|
||||
.reveal .progress {
|
||||
background: rgba(0, 0, 0, 0.2); }
|
||||
|
||||
.reveal .progress span {
|
||||
background: #13daec;
|
||||
-webkit-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
-moz-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
-ms-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
-o-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985); }
|
||||
|
||||
/*********************************************
|
||||
* SLIDE NUMBER
|
||||
*********************************************/
|
||||
.reveal .slide-number {
|
||||
color: #13daec; }
|
||||
@@ -1,153 +0,0 @@
|
||||
@import url(https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic);
|
||||
/**
|
||||
* Default theme for reveal.js.
|
||||
*
|
||||
* Copyright (C) 2011-2012 Hakim El Hattab, http://hakim.se
|
||||
*/
|
||||
/* changed by hpl from 36px; */
|
||||
/* changed by hpl from 'League Gothic', Impact, sans-serif; */
|
||||
/* changed by hpl from uppercase; */
|
||||
@font-face {
|
||||
font-family: 'League Gothic';
|
||||
src: url("../../lib/font/league_gothic-webfont.eot");
|
||||
src: url("../../lib/font/league_gothic-webfont.eot?#iefix") format("embedded-opentype"), url("../../lib/font/league_gothic-webfont.woff") format("woff"), url("../../lib/font/league_gothic-webfont.ttf") format("truetype"), url("../../lib/font/league_gothic-webfont.svg#LeagueGothicRegular") format("svg");
|
||||
font-weight: normal;
|
||||
font-style: normal; }
|
||||
|
||||
/*********************************************
|
||||
* GLOBAL STYLES
|
||||
*********************************************/
|
||||
body {
|
||||
background: #1c1e20;
|
||||
background: -moz-radial-gradient(center, circle cover, #555a5f 0%, #1c1e20 100%);
|
||||
background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%, #555a5f), color-stop(100%, #1c1e20));
|
||||
background: -webkit-radial-gradient(center, circle cover, #555a5f 0%, #1c1e20 100%);
|
||||
background: -o-radial-gradient(center, circle cover, #555a5f 0%, #1c1e20 100%);
|
||||
background: -ms-radial-gradient(center, circle cover, #555a5f 0%, #1c1e20 100%);
|
||||
background: radial-gradient(center, circle cover, #555a5f 0%, #1c1e20 100%);
|
||||
background-color: #2b2b2b; }
|
||||
|
||||
.reveal {
|
||||
font-family: "Lato", sans-serif;
|
||||
font-size: 30px;
|
||||
font-weight: normal;
|
||||
letter-spacing: -0.02em;
|
||||
color: #eeeeee; }
|
||||
|
||||
::selection {
|
||||
color: white;
|
||||
background: #ff5e99;
|
||||
text-shadow: none; }
|
||||
|
||||
/*********************************************
|
||||
* HEADERS
|
||||
*********************************************/
|
||||
.reveal h1,
|
||||
.reveal h2,
|
||||
.reveal h3,
|
||||
.reveal h4,
|
||||
.reveal h5,
|
||||
.reveal h6 {
|
||||
margin: 0 0 20px 0;
|
||||
color: #eeeeee;
|
||||
font-family: "Helvetica", Impact, sans-serif;
|
||||
line-height: 1.1em; /* changed (by hpl) from 0.9em */
|
||||
letter-spacing: 0.02em;
|
||||
text-transform: none;
|
||||
text-shadow: 0px 0px 6px rgba(0, 0, 0, 0.2); }
|
||||
|
||||
.reveal h1 {
|
||||
line-height: 1.2em;
|
||||
/* added by hpl */
|
||||
text-shadow: 0 1px 0 #cccccc, 0 2px 0 #c9c9c9, 0 3px 0 #bbbbbb, 0 4px 0 #b9b9b9, 0 5px 0 #aaaaaa, 0 6px 1px rgba(0, 0, 0, 0.1), 0 0 5px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.3), 0 3px 5px rgba(0, 0, 0, 0.2), 0 5px 10px rgba(0, 0, 0, 0.25), 0 20px 20px rgba(0, 0, 0, 0.15); }
|
||||
|
||||
/*********************************************
|
||||
* LINKS
|
||||
*********************************************/
|
||||
.reveal a:not(.image) {
|
||||
color: #13daec;
|
||||
text-decoration: none;
|
||||
-webkit-transition: color .15s ease;
|
||||
-moz-transition: color .15s ease;
|
||||
-ms-transition: color .15s ease;
|
||||
-o-transition: color .15s ease;
|
||||
transition: color .15s ease; }
|
||||
|
||||
.reveal a:not(.image):hover {
|
||||
color: #71e9f4;
|
||||
text-shadow: none;
|
||||
border: none; }
|
||||
|
||||
.reveal .roll span:after {
|
||||
color: #fff;
|
||||
background: #0d99a5; }
|
||||
|
||||
/*********************************************
|
||||
* IMAGES
|
||||
*********************************************/
|
||||
.reveal section img {
|
||||
margin: 15px 0px;
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
border: 4px solid #eeeeee;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.15);
|
||||
-webkit-transition: all .2s linear;
|
||||
-moz-transition: all .2s linear;
|
||||
-ms-transition: all .2s linear;
|
||||
-o-transition: all .2s linear;
|
||||
transition: all .2s linear; }
|
||||
|
||||
.reveal a:hover img {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
border-color: #13daec;
|
||||
box-shadow: 0 0 20px rgba(0, 0, 0, 0.55); }
|
||||
|
||||
/*********************************************
|
||||
* NAVIGATION CONTROLS
|
||||
*********************************************/
|
||||
.reveal .controls div.navigate-left,
|
||||
.reveal .controls div.navigate-left.enabled {
|
||||
border-right-color: #13daec; }
|
||||
|
||||
.reveal .controls div.navigate-right,
|
||||
.reveal .controls div.navigate-right.enabled {
|
||||
border-left-color: #13daec; }
|
||||
|
||||
.reveal .controls div.navigate-up,
|
||||
.reveal .controls div.navigate-up.enabled {
|
||||
border-bottom-color: #13daec; }
|
||||
|
||||
.reveal .controls div.navigate-down,
|
||||
.reveal .controls div.navigate-down.enabled {
|
||||
border-top-color: #13daec; }
|
||||
|
||||
.reveal .controls div.navigate-left.enabled:hover {
|
||||
border-right-color: #71e9f4; }
|
||||
|
||||
.reveal .controls div.navigate-right.enabled:hover {
|
||||
border-left-color: #71e9f4; }
|
||||
|
||||
.reveal .controls div.navigate-up.enabled:hover {
|
||||
border-bottom-color: #71e9f4; }
|
||||
|
||||
.reveal .controls div.navigate-down.enabled:hover {
|
||||
border-top-color: #71e9f4; }
|
||||
|
||||
/*********************************************
|
||||
* PROGRESS BAR
|
||||
*********************************************/
|
||||
.reveal .progress {
|
||||
background: rgba(0, 0, 0, 0.2); }
|
||||
|
||||
.reveal .progress span {
|
||||
background: #13daec;
|
||||
-webkit-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
-moz-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
-ms-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
-o-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985); }
|
||||
|
||||
/*********************************************
|
||||
* SLIDE NUMBER
|
||||
*********************************************/
|
||||
.reveal .slide-number {
|
||||
color: #13daec; }
|
||||
@@ -1,279 +0,0 @@
|
||||
@import url(../../lib/font/league-gothic/league-gothic.css);
|
||||
@import url(https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic);
|
||||
/**
|
||||
* League theme for reveal.js.
|
||||
*
|
||||
* This was the default theme pre-3.0.0.
|
||||
*
|
||||
* Copyright (C) 2011-2012 Hakim El Hattab, http://hakim.se
|
||||
*/
|
||||
/*********************************************
|
||||
* GLOBAL STYLES
|
||||
*********************************************/
|
||||
body {
|
||||
background: #1c1e20;
|
||||
background: -moz-radial-gradient(center, circle cover, #555a5f 0%, #1c1e20 100%);
|
||||
background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%, #555a5f), color-stop(100%, #1c1e20));
|
||||
background: -webkit-radial-gradient(center, circle cover, #555a5f 0%, #1c1e20 100%);
|
||||
background: -o-radial-gradient(center, circle cover, #555a5f 0%, #1c1e20 100%);
|
||||
background: -ms-radial-gradient(center, circle cover, #555a5f 0%, #1c1e20 100%);
|
||||
background: radial-gradient(center, circle cover, #555a5f 0%, #1c1e20 100%);
|
||||
background-color: #2b2b2b; }
|
||||
|
||||
.reveal {
|
||||
font-family: 'Lato', sans-serif;
|
||||
font-size: 30px; /* changed by hpl from 36px */
|
||||
font-weight: normal;
|
||||
color: #eee; }
|
||||
|
||||
::selection {
|
||||
color: #fff;
|
||||
background: #FF5E99;
|
||||
text-shadow: none; }
|
||||
|
||||
.reveal .slides > section, .reveal .slides > section > section {
|
||||
/* removed by hpl: line-height: 1.3; */
|
||||
font-weight: inherit; }
|
||||
|
||||
/*********************************************
|
||||
* HEADERS
|
||||
*********************************************/
|
||||
.reveal h1, .reveal h2, .reveal h3, .reveal h4, .reveal h5, .reveal h6 {
|
||||
margin: 0 0 20px 0;
|
||||
color: #eee;
|
||||
font-family: 'Helvetica', Impact, sans-serif;
|
||||
font-weight: normal;
|
||||
line-height: 1.1em; /* changed by hpl from 1.2; */
|
||||
letter-spacing: normal;
|
||||
/* text-transform: uppercase; removed by hpl */
|
||||
text-shadow: 0px 0px 6px rgba(0, 0, 0, 0.2);
|
||||
word-wrap: break-word; }
|
||||
|
||||
.reveal h1 {
|
||||
line-height: 1.2em;
|
||||
}
|
||||
|
||||
/* removed by hpl:
|
||||
.reveal h1 {
|
||||
font-size: 3.77em; }
|
||||
|
||||
.reveal h2 {
|
||||
font-size: 2.11em; }
|
||||
|
||||
.reveal h3 {
|
||||
font-size: 1.55em; }
|
||||
|
||||
.reveal h4 {
|
||||
font-size: 1em; }
|
||||
*/
|
||||
|
||||
.reveal h1 {
|
||||
text-shadow: 0 1px 0 #ccc, 0 2px 0 #c9c9c9, 0 3px 0 #bbb, 0 4px 0 #b9b9b9, 0 5px 0 #aaa, 0 6px 1px rgba(0, 0, 0, 0.1), 0 0 5px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.3), 0 3px 5px rgba(0, 0, 0, 0.2), 0 5px 10px rgba(0, 0, 0, 0.25), 0 20px 20px rgba(0, 0, 0, 0.15); }
|
||||
|
||||
/*********************************************
|
||||
* OTHER
|
||||
*********************************************/
|
||||
.reveal p {
|
||||
margin: 20px 0;
|
||||
line-height: 1.3; }
|
||||
|
||||
/* Ensure certain elements are never larger than the slide itself */
|
||||
.reveal img, .reveal video, .reveal iframe {
|
||||
max-width: 95%;
|
||||
max-height: 95%; }
|
||||
|
||||
.reveal strong, .reveal b {
|
||||
font-weight: bold; }
|
||||
|
||||
.reveal em {
|
||||
font-style: italic; }
|
||||
|
||||
.reveal ol, .reveal dl, .reveal ul {
|
||||
display: inline-block;
|
||||
text-align: left;
|
||||
margin: 0 0 0 1em; }
|
||||
|
||||
.reveal ol {
|
||||
list-style-type: decimal; }
|
||||
|
||||
.reveal ul {
|
||||
list-style-type: disc; }
|
||||
|
||||
.reveal ul ul {
|
||||
list-style-type: square; }
|
||||
|
||||
.reveal ul ul ul {
|
||||
list-style-type: circle; }
|
||||
|
||||
.reveal ul ul, .reveal ul ol, .reveal ol ol, .reveal ol ul {
|
||||
display: block;
|
||||
margin-left: 40px; }
|
||||
|
||||
.reveal dt {
|
||||
font-weight: bold; }
|
||||
|
||||
.reveal dd {
|
||||
margin-left: 40px; }
|
||||
|
||||
.reveal q, .reveal blockquote {
|
||||
quotes: none; }
|
||||
|
||||
.reveal blockquote {
|
||||
display: block;
|
||||
position: relative;
|
||||
width: 70%;
|
||||
margin: 20px auto;
|
||||
padding: 5px;
|
||||
font-style: italic;
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
box-shadow: 0px 0px 2px rgba(0, 0, 0, 0.2); }
|
||||
|
||||
.reveal blockquote p:first-child, .reveal blockquote p:last-child {
|
||||
display: inline-block; }
|
||||
|
||||
.reveal q {
|
||||
font-style: italic; }
|
||||
|
||||
.reveal pre {
|
||||
display: block;
|
||||
position: relative;
|
||||
width: 90%;
|
||||
margin: 20px auto;
|
||||
text-align: left;
|
||||
font-size: 0.55em;
|
||||
font-family: monospace;
|
||||
line-height: 1.2em;
|
||||
word-wrap: break-word;
|
||||
box-shadow: 0px 0px 6px rgba(0, 0, 0, 0.3); }
|
||||
|
||||
.reveal code {
|
||||
font-family: monospace; }
|
||||
|
||||
.reveal pre code {
|
||||
display: block;
|
||||
padding: 5px;
|
||||
overflow: auto;
|
||||
max-height: 400px;
|
||||
word-wrap: normal;
|
||||
background: #3F3F3F;
|
||||
color: #DCDCDC; }
|
||||
|
||||
.reveal table {
|
||||
margin: auto;
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0; }
|
||||
|
||||
.reveal table th {
|
||||
font-weight: bold; }
|
||||
|
||||
.reveal table th, .reveal table td {
|
||||
/* text-align: left; */ /* hpl modification */
|
||||
padding: 0.2em 0.5em 0.2em 0.5em;
|
||||
border-bottom: 1px solid; }
|
||||
|
||||
.reveal table th[align="center"], .reveal table td[align="center"] {
|
||||
text-align: center; }
|
||||
|
||||
.reveal table th[align="right"], .reveal table td[align="right"] {
|
||||
text-align: right; }
|
||||
|
||||
.reveal table tr:last-child td {
|
||||
border-bottom: none; }
|
||||
|
||||
.reveal sup {
|
||||
vertical-align: super; }
|
||||
|
||||
.reveal sub {
|
||||
vertical-align: sub; }
|
||||
|
||||
.reveal small {
|
||||
display: inline-block;
|
||||
font-size: 0.6em;
|
||||
line-height: 1.2em;
|
||||
vertical-align: top; }
|
||||
|
||||
.reveal small * {
|
||||
vertical-align: top; }
|
||||
|
||||
/*********************************************
|
||||
* LINKS
|
||||
*********************************************/
|
||||
.reveal a {
|
||||
color: #13DAEC;
|
||||
text-decoration: none;
|
||||
-webkit-transition: color 0.15s ease;
|
||||
-moz-transition: color 0.15s ease;
|
||||
transition: color 0.15s ease; }
|
||||
|
||||
.reveal a:hover {
|
||||
color: #71ebf4;
|
||||
text-shadow: none;
|
||||
border: none; }
|
||||
|
||||
.reveal .roll span:after {
|
||||
color: #fff;
|
||||
background: #0d9ba5; }
|
||||
|
||||
/*********************************************
|
||||
* IMAGES
|
||||
*********************************************/
|
||||
.reveal section img {
|
||||
margin: 15px 0px;
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
border: 4px solid #eee;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.15); }
|
||||
|
||||
.reveal a img {
|
||||
-webkit-transition: all 0.15s linear;
|
||||
-moz-transition: all 0.15s linear;
|
||||
transition: all 0.15s linear; }
|
||||
|
||||
.reveal a:hover img {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
border-color: #13DAEC;
|
||||
box-shadow: 0 0 20px rgba(0, 0, 0, 0.55); }
|
||||
|
||||
/*********************************************
|
||||
* NAVIGATION CONTROLS
|
||||
*********************************************/
|
||||
.reveal .controls div.navigate-left, .reveal .controls div.navigate-left.enabled {
|
||||
border-right-color: #13DAEC; }
|
||||
|
||||
.reveal .controls div.navigate-right, .reveal .controls div.navigate-right.enabled {
|
||||
border-left-color: #13DAEC; }
|
||||
|
||||
.reveal .controls div.navigate-up, .reveal .controls div.navigate-up.enabled {
|
||||
border-bottom-color: #13DAEC; }
|
||||
|
||||
.reveal .controls div.navigate-down, .reveal .controls div.navigate-down.enabled {
|
||||
border-top-color: #13DAEC; }
|
||||
|
||||
.reveal .controls div.navigate-left.enabled:hover {
|
||||
border-right-color: #71ebf4; }
|
||||
|
||||
.reveal .controls div.navigate-right.enabled:hover {
|
||||
border-left-color: #71ebf4; }
|
||||
|
||||
.reveal .controls div.navigate-up.enabled:hover {
|
||||
border-bottom-color: #71ebf4; }
|
||||
|
||||
.reveal .controls div.navigate-down.enabled:hover {
|
||||
border-top-color: #71ebf4; }
|
||||
|
||||
/*********************************************
|
||||
* PROGRESS BAR
|
||||
*********************************************/
|
||||
.reveal .progress {
|
||||
background: rgba(0, 0, 0, 0.2); }
|
||||
|
||||
.reveal .progress span {
|
||||
background: #13DAEC;
|
||||
-webkit-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
-moz-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985); }
|
||||
|
||||
/*********************************************
|
||||
* SLIDE NUMBER
|
||||
*********************************************/
|
||||
.reveal .slide-number {
|
||||
color: #13DAEC; }
|
||||
@@ -1,153 +0,0 @@
|
||||
@import url(https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic);
|
||||
/**
|
||||
* Solarized Dark theme for reveal.js.
|
||||
* Author: Achim Staebler
|
||||
*/
|
||||
/* changed by hpl from 36px; */
|
||||
/* changed by hpl from 'League Gothic', Impact, sans-serif; */
|
||||
/* changed by hpl from uppercase; */
|
||||
@font-face {
|
||||
font-family: 'League Gothic';
|
||||
src: url("../../lib/font/league_gothic-webfont.eot");
|
||||
src: url("../../lib/font/league_gothic-webfont.eot?#iefix") format("embedded-opentype"), url("../../lib/font/league_gothic-webfont.woff") format("woff"), url("../../lib/font/league_gothic-webfont.ttf") format("truetype"), url("../../lib/font/league_gothic-webfont.svg#LeagueGothicRegular") format("svg");
|
||||
font-weight: normal;
|
||||
font-style: normal; }
|
||||
|
||||
/**
|
||||
* Solarized colors by Ethan Schoonover
|
||||
*/
|
||||
html * {
|
||||
color-profile: sRGB;
|
||||
rendering-intent: auto; }
|
||||
|
||||
/*********************************************
|
||||
* GLOBAL STYLES
|
||||
*********************************************/
|
||||
body {
|
||||
background: #002b36;
|
||||
background-color: #002b36; }
|
||||
|
||||
.reveal {
|
||||
font-family: "Lato", sans-serif;
|
||||
font-size: 30px;
|
||||
font-weight: normal;
|
||||
letter-spacing: -0.02em;
|
||||
color: #93a1a1; }
|
||||
|
||||
::selection {
|
||||
color: white;
|
||||
background: #d33682;
|
||||
text-shadow: none; }
|
||||
|
||||
/*********************************************
|
||||
* HEADERS
|
||||
*********************************************/
|
||||
.reveal h1,
|
||||
.reveal h2,
|
||||
.reveal h3,
|
||||
.reveal h4,
|
||||
.reveal h5,
|
||||
.reveal h6 {
|
||||
margin: 0 0 20px 0;
|
||||
color: #eee8d5;
|
||||
font-family: "Helvetica", Impact, sans-serif;
|
||||
line-height: 1.1em; /* changed (by hpl) from 0.9em */
|
||||
letter-spacing: 0.02em;
|
||||
text-transform: none;
|
||||
text-shadow: none; }
|
||||
|
||||
.reveal h1 {
|
||||
line-height: 1.2em;
|
||||
/* added by hpl */
|
||||
text-shadow: 0px 0px 6px rgba(0, 0, 0, 0.2); }
|
||||
|
||||
/*********************************************
|
||||
* LINKS
|
||||
*********************************************/
|
||||
.reveal a:not(.image) {
|
||||
color: #268bd2;
|
||||
text-decoration: none;
|
||||
-webkit-transition: color .15s ease;
|
||||
-moz-transition: color .15s ease;
|
||||
-ms-transition: color .15s ease;
|
||||
-o-transition: color .15s ease;
|
||||
transition: color .15s ease; }
|
||||
|
||||
.reveal a:not(.image):hover {
|
||||
color: #78b9e6;
|
||||
text-shadow: none;
|
||||
border: none; }
|
||||
|
||||
.reveal .roll span:after {
|
||||
color: #fff;
|
||||
background: #1a6091; }
|
||||
|
||||
/*********************************************
|
||||
* IMAGES
|
||||
*********************************************/
|
||||
.reveal section img {
|
||||
margin: 15px 0px;
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
border: 4px solid #93a1a1;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.15);
|
||||
-webkit-transition: all .2s linear;
|
||||
-moz-transition: all .2s linear;
|
||||
-ms-transition: all .2s linear;
|
||||
-o-transition: all .2s linear;
|
||||
transition: all .2s linear; }
|
||||
|
||||
.reveal a:hover img {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
border-color: #268bd2;
|
||||
box-shadow: 0 0 20px rgba(0, 0, 0, 0.55); }
|
||||
|
||||
/*********************************************
|
||||
* NAVIGATION CONTROLS
|
||||
*********************************************/
|
||||
.reveal .controls div.navigate-left,
|
||||
.reveal .controls div.navigate-left.enabled {
|
||||
border-right-color: #268bd2; }
|
||||
|
||||
.reveal .controls div.navigate-right,
|
||||
.reveal .controls div.navigate-right.enabled {
|
||||
border-left-color: #268bd2; }
|
||||
|
||||
.reveal .controls div.navigate-up,
|
||||
.reveal .controls div.navigate-up.enabled {
|
||||
border-bottom-color: #268bd2; }
|
||||
|
||||
.reveal .controls div.navigate-down,
|
||||
.reveal .controls div.navigate-down.enabled {
|
||||
border-top-color: #268bd2; }
|
||||
|
||||
.reveal .controls div.navigate-left.enabled:hover {
|
||||
border-right-color: #78b9e6; }
|
||||
|
||||
.reveal .controls div.navigate-right.enabled:hover {
|
||||
border-left-color: #78b9e6; }
|
||||
|
||||
.reveal .controls div.navigate-up.enabled:hover {
|
||||
border-bottom-color: #78b9e6; }
|
||||
|
||||
.reveal .controls div.navigate-down.enabled:hover {
|
||||
border-top-color: #78b9e6; }
|
||||
|
||||
/*********************************************
|
||||
* PROGRESS BAR
|
||||
*********************************************/
|
||||
.reveal .progress {
|
||||
background: rgba(0, 0, 0, 0.2); }
|
||||
|
||||
.reveal .progress span {
|
||||
background: #268bd2;
|
||||
-webkit-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
-moz-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
-ms-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
-o-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985); }
|
||||
|
||||
/*********************************************
|
||||
* SLIDE NUMBER
|
||||
*********************************************/
|
||||
.reveal .slide-number {
|
||||
color: #268bd2; }
|
||||
@@ -1,141 +0,0 @@
|
||||
@import url(https://fonts.googleapis.com/css?family=Montserrat:700);
|
||||
@import url(https://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic,700italic);
|
||||
/**
|
||||
* Black theme for reveal.js.
|
||||
*
|
||||
* Copyright (C) 2011-2012 Hakim El Hattab, http://hakim.se
|
||||
*/
|
||||
/* changed by hpl from 36px; */
|
||||
/* changed by hpl from 'League Gothic', Impact, sans-serif; */
|
||||
/* changed by hpl from uppercase; */
|
||||
/*********************************************
|
||||
* GLOBAL STYLES
|
||||
*********************************************/
|
||||
body {
|
||||
background: #111111;
|
||||
background-color: #111111; }
|
||||
|
||||
.reveal {
|
||||
font-family: "Open Sans", sans-serif;
|
||||
font-size: 30px;
|
||||
font-weight: normal;
|
||||
letter-spacing: -0.02em;
|
||||
color: #eeeeee; }
|
||||
|
||||
::selection {
|
||||
color: white;
|
||||
background: #e7ad52;
|
||||
text-shadow: none; }
|
||||
|
||||
/*********************************************
|
||||
* HEADERS
|
||||
*********************************************/
|
||||
.reveal h1,
|
||||
.reveal h2,
|
||||
.reveal h3,
|
||||
.reveal h4,
|
||||
.reveal h5,
|
||||
.reveal h6 {
|
||||
margin: 0 0 20px 0;
|
||||
color: #eeeeee;
|
||||
font-family: "Montserrat", Impact, sans-serif;
|
||||
line-height: 1.1em; /* changed (by hpl) from 0.9em */
|
||||
letter-spacing: -0.03em;
|
||||
text-transform: none;
|
||||
text-shadow: none; }
|
||||
|
||||
.reveal h1 {
|
||||
line-height: 1.2em;
|
||||
/* added by hpl */
|
||||
text-shadow: 0px 0px 6px rgba(0, 0, 0, 0.2); }
|
||||
|
||||
/*********************************************
|
||||
* LINKS
|
||||
*********************************************/
|
||||
.reveal a:not(.image) {
|
||||
color: #e7ad52;
|
||||
text-decoration: none;
|
||||
-webkit-transition: color .15s ease;
|
||||
-moz-transition: color .15s ease;
|
||||
-ms-transition: color .15s ease;
|
||||
-o-transition: color .15s ease;
|
||||
transition: color .15s ease; }
|
||||
|
||||
.reveal a:not(.image):hover {
|
||||
color: #f3d7ac;
|
||||
text-shadow: none;
|
||||
border: none; }
|
||||
|
||||
.reveal .roll span:after {
|
||||
color: #fff;
|
||||
background: #d08a1d; }
|
||||
|
||||
/*********************************************
|
||||
* IMAGES
|
||||
*********************************************/
|
||||
.reveal section img {
|
||||
margin: 15px 0px;
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
border: 4px solid #eeeeee;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.15);
|
||||
-webkit-transition: all .2s linear;
|
||||
-moz-transition: all .2s linear;
|
||||
-ms-transition: all .2s linear;
|
||||
-o-transition: all .2s linear;
|
||||
transition: all .2s linear; }
|
||||
|
||||
.reveal a:hover img {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
border-color: #e7ad52;
|
||||
box-shadow: 0 0 20px rgba(0, 0, 0, 0.55); }
|
||||
|
||||
/*********************************************
|
||||
* NAVIGATION CONTROLS
|
||||
*********************************************/
|
||||
.reveal .controls div.navigate-left,
|
||||
.reveal .controls div.navigate-left.enabled {
|
||||
border-right-color: #e7ad52; }
|
||||
|
||||
.reveal .controls div.navigate-right,
|
||||
.reveal .controls div.navigate-right.enabled {
|
||||
border-left-color: #e7ad52; }
|
||||
|
||||
.reveal .controls div.navigate-up,
|
||||
.reveal .controls div.navigate-up.enabled {
|
||||
border-bottom-color: #e7ad52; }
|
||||
|
||||
.reveal .controls div.navigate-down,
|
||||
.reveal .controls div.navigate-down.enabled {
|
||||
border-top-color: #e7ad52; }
|
||||
|
||||
.reveal .controls div.navigate-left.enabled:hover {
|
||||
border-right-color: #f3d7ac; }
|
||||
|
||||
.reveal .controls div.navigate-right.enabled:hover {
|
||||
border-left-color: #f3d7ac; }
|
||||
|
||||
.reveal .controls div.navigate-up.enabled:hover {
|
||||
border-bottom-color: #f3d7ac; }
|
||||
|
||||
.reveal .controls div.navigate-down.enabled:hover {
|
||||
border-top-color: #f3d7ac; }
|
||||
|
||||
/*********************************************
|
||||
* PROGRESS BAR
|
||||
*********************************************/
|
||||
.reveal .progress {
|
||||
background: rgba(0, 0, 0, 0.2); }
|
||||
|
||||
.reveal .progress span {
|
||||
background: #e7ad52;
|
||||
-webkit-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
-moz-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
-ms-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
-o-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985); }
|
||||
|
||||
/*********************************************
|
||||
* SLIDE NUMBER
|
||||
*********************************************/
|
||||
.reveal .slide-number {
|
||||
color: #e7ad52; }
|
||||
@@ -1,143 +0,0 @@
|
||||
/**
|
||||
* A simple theme for reveal.js presentations, similar
|
||||
* to the default theme. The accent color is brown.
|
||||
*
|
||||
* This theme is Copyright (C) 2012-2013 Owen Versteeg, http://owenversteeg.com - it is MIT licensed.
|
||||
*/
|
||||
/* changed by hpl from 36px; */
|
||||
/* changed by hpl from 'League Gothic', Impact, sans-serif; */
|
||||
/* changed by hpl from uppercase; */
|
||||
.reveal a:not(.image) {
|
||||
line-height: 1.3em; }
|
||||
|
||||
/*********************************************
|
||||
* GLOBAL STYLES
|
||||
*********************************************/
|
||||
body {
|
||||
background: #f0f1eb;
|
||||
background-color: #f0f1eb; }
|
||||
|
||||
.reveal {
|
||||
font-family: "Palatino Linotype", "Book Antiqua", Palatino, FreeSerif, serif;
|
||||
font-size: 30px;
|
||||
font-weight: normal;
|
||||
letter-spacing: -0.02em;
|
||||
color: black; }
|
||||
|
||||
::selection {
|
||||
color: white;
|
||||
background: #26351c;
|
||||
text-shadow: none; }
|
||||
|
||||
/*********************************************
|
||||
* HEADERS
|
||||
*********************************************/
|
||||
.reveal h1,
|
||||
.reveal h2,
|
||||
.reveal h3,
|
||||
.reveal h4,
|
||||
.reveal h5,
|
||||
.reveal h6 {
|
||||
margin: 0 0 20px 0;
|
||||
color: #383d3d;
|
||||
font-family: "Palatino Linotype", "Book Antiqua", Palatino, FreeSerif, serif;
|
||||
line-height: 1.1em; /* changed (by hpl) from 0.9em */
|
||||
letter-spacing: 0.02em;
|
||||
text-transform: none;
|
||||
text-shadow: none; }
|
||||
|
||||
.reveal h1 {
|
||||
line-height: 1.2em;
|
||||
/* added by hpl */
|
||||
text-shadow: 0px 0px 6px rgba(0, 0, 0, 0.2); }
|
||||
|
||||
/*********************************************
|
||||
* LINKS
|
||||
*********************************************/
|
||||
.reveal a:not(.image) {
|
||||
color: #51483d;
|
||||
text-decoration: none;
|
||||
-webkit-transition: color .15s ease;
|
||||
-moz-transition: color .15s ease;
|
||||
-ms-transition: color .15s ease;
|
||||
-o-transition: color .15s ease;
|
||||
transition: color .15s ease; }
|
||||
|
||||
.reveal a:not(.image):hover {
|
||||
color: #8b7c69;
|
||||
text-shadow: none;
|
||||
border: none; }
|
||||
|
||||
.reveal .roll span:after {
|
||||
color: #fff;
|
||||
background: #25211c; }
|
||||
|
||||
/*********************************************
|
||||
* IMAGES
|
||||
*********************************************/
|
||||
.reveal section img {
|
||||
margin: 15px 0px;
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
border: 4px solid black;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.15);
|
||||
-webkit-transition: all .2s linear;
|
||||
-moz-transition: all .2s linear;
|
||||
-ms-transition: all .2s linear;
|
||||
-o-transition: all .2s linear;
|
||||
transition: all .2s linear; }
|
||||
|
||||
.reveal a:hover img {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
border-color: #51483d;
|
||||
box-shadow: 0 0 20px rgba(0, 0, 0, 0.55); }
|
||||
|
||||
/*********************************************
|
||||
* NAVIGATION CONTROLS
|
||||
*********************************************/
|
||||
.reveal .controls div.navigate-left,
|
||||
.reveal .controls div.navigate-left.enabled {
|
||||
border-right-color: #51483d; }
|
||||
|
||||
.reveal .controls div.navigate-right,
|
||||
.reveal .controls div.navigate-right.enabled {
|
||||
border-left-color: #51483d; }
|
||||
|
||||
.reveal .controls div.navigate-up,
|
||||
.reveal .controls div.navigate-up.enabled {
|
||||
border-bottom-color: #51483d; }
|
||||
|
||||
.reveal .controls div.navigate-down,
|
||||
.reveal .controls div.navigate-down.enabled {
|
||||
border-top-color: #51483d; }
|
||||
|
||||
.reveal .controls div.navigate-left.enabled:hover {
|
||||
border-right-color: #8b7c69; }
|
||||
|
||||
.reveal .controls div.navigate-right.enabled:hover {
|
||||
border-left-color: #8b7c69; }
|
||||
|
||||
.reveal .controls div.navigate-up.enabled:hover {
|
||||
border-bottom-color: #8b7c69; }
|
||||
|
||||
.reveal .controls div.navigate-down.enabled:hover {
|
||||
border-top-color: #8b7c69; }
|
||||
|
||||
/*********************************************
|
||||
* PROGRESS BAR
|
||||
*********************************************/
|
||||
.reveal .progress {
|
||||
background: rgba(0, 0, 0, 0.2); }
|
||||
|
||||
.reveal .progress span {
|
||||
background: #51483d;
|
||||
-webkit-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
-moz-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
-ms-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
-o-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985); }
|
||||
|
||||
/*********************************************
|
||||
* SLIDE NUMBER
|
||||
*********************************************/
|
||||
.reveal .slide-number {
|
||||
color: #51483d; }
|
||||
@@ -1,144 +0,0 @@
|
||||
@import url(https://fonts.googleapis.com/css?family=News+Cycle:400,700);
|
||||
@import url(https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic);
|
||||
/**
|
||||
* A simple theme for reveal.js presentations, similar
|
||||
* to the default theme. The accent color is darkblue.
|
||||
*
|
||||
* This theme is Copyright (C) 2012 Owen Versteeg, https://github.com/StereotypicalApps. It is MIT licensed.
|
||||
* reveal.js is Copyright (C) 2011-2012 Hakim El Hattab, http://hakim.se
|
||||
*/
|
||||
/* changed by hpl from 36px; */
|
||||
/* changed by hpl from 'League Gothic', Impact, sans-serif; */
|
||||
/* changed by hpl from uppercase; */
|
||||
/* changed (by hpl) from 'News Cycle', Impact, sans-serif; */
|
||||
/*********************************************
|
||||
* GLOBAL STYLES
|
||||
*********************************************/
|
||||
body {
|
||||
background: white;
|
||||
background-color: white; }
|
||||
|
||||
.reveal {
|
||||
font-family: "Lato", sans-serif;
|
||||
font-size: 30px;
|
||||
font-weight: normal;
|
||||
letter-spacing: -0.02em;
|
||||
color: black; }
|
||||
|
||||
::selection {
|
||||
color: white;
|
||||
background: rgba(0, 0, 0, 0.99);
|
||||
text-shadow: none; }
|
||||
|
||||
/*********************************************
|
||||
* HEADERS
|
||||
*********************************************/
|
||||
.reveal h1,
|
||||
.reveal h2,
|
||||
.reveal h3,
|
||||
.reveal h4,
|
||||
.reveal h5,
|
||||
.reveal h6 {
|
||||
margin: 0 0 20px 0;
|
||||
color: black;
|
||||
font-family: "Helvetica", Impact, sans-serif;
|
||||
line-height: 1.1em; /* changed (by hpl) from 0.9em */
|
||||
letter-spacing: 0.02em;
|
||||
text-transform: none;
|
||||
text-shadow: none; }
|
||||
|
||||
.reveal h1 {
|
||||
line-height: 1.2em;
|
||||
/* added by hpl */
|
||||
text-shadow: 0px 0px 6px rgba(0, 0, 0, 0.2); }
|
||||
|
||||
/*********************************************
|
||||
* LINKS
|
||||
*********************************************/
|
||||
.reveal a:not(.image) {
|
||||
color: darkblue;
|
||||
text-decoration: none;
|
||||
-webkit-transition: color .15s ease;
|
||||
-moz-transition: color .15s ease;
|
||||
-ms-transition: color .15s ease;
|
||||
-o-transition: color .15s ease;
|
||||
transition: color .15s ease; }
|
||||
|
||||
.reveal a:not(.image):hover {
|
||||
color: #0000f1;
|
||||
text-shadow: none;
|
||||
border: none; }
|
||||
|
||||
.reveal .roll span:after {
|
||||
color: #fff;
|
||||
background: #00003f; }
|
||||
|
||||
/*********************************************
|
||||
* IMAGES
|
||||
*********************************************/
|
||||
.reveal section img {
|
||||
margin: 15px 0px;
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
border: 4px solid black;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.15);
|
||||
-webkit-transition: all .2s linear;
|
||||
-moz-transition: all .2s linear;
|
||||
-ms-transition: all .2s linear;
|
||||
-o-transition: all .2s linear;
|
||||
transition: all .2s linear; }
|
||||
|
||||
.reveal a:hover img {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
border-color: darkblue;
|
||||
box-shadow: 0 0 20px rgba(0, 0, 0, 0.55); }
|
||||
|
||||
/*********************************************
|
||||
* NAVIGATION CONTROLS
|
||||
*********************************************/
|
||||
.reveal .controls div.navigate-left,
|
||||
.reveal .controls div.navigate-left.enabled {
|
||||
border-right-color: darkblue; }
|
||||
|
||||
.reveal .controls div.navigate-right,
|
||||
.reveal .controls div.navigate-right.enabled {
|
||||
border-left-color: darkblue; }
|
||||
|
||||
.reveal .controls div.navigate-up,
|
||||
.reveal .controls div.navigate-up.enabled {
|
||||
border-bottom-color: darkblue; }
|
||||
|
||||
.reveal .controls div.navigate-down,
|
||||
.reveal .controls div.navigate-down.enabled {
|
||||
border-top-color: darkblue; }
|
||||
|
||||
.reveal .controls div.navigate-left.enabled:hover {
|
||||
border-right-color: #0000f1; }
|
||||
|
||||
.reveal .controls div.navigate-right.enabled:hover {
|
||||
border-left-color: #0000f1; }
|
||||
|
||||
.reveal .controls div.navigate-up.enabled:hover {
|
||||
border-bottom-color: #0000f1; }
|
||||
|
||||
.reveal .controls div.navigate-down.enabled:hover {
|
||||
border-top-color: #0000f1; }
|
||||
|
||||
/*********************************************
|
||||
* PROGRESS BAR
|
||||
*********************************************/
|
||||
.reveal .progress {
|
||||
background: rgba(0, 0, 0, 0.2); }
|
||||
|
||||
.reveal .progress span {
|
||||
background: darkblue;
|
||||
-webkit-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
-moz-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
-ms-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
-o-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985); }
|
||||
|
||||
/*********************************************
|
||||
* SLIDE NUMBER
|
||||
*********************************************/
|
||||
.reveal .slide-number {
|
||||
color: darkblue; }
|
||||
@@ -1,144 +0,0 @@
|
||||
@import url(https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic);
|
||||
/**
|
||||
* A simple theme for reveal.js presentations, similar
|
||||
* to the default theme. The accent color is darkblue.
|
||||
*
|
||||
* This theme is Copyright (C) 2012 Owen Versteeg, https://github.com/StereotypicalApps. It is MIT licensed.
|
||||
* reveal.js is Copyright (C) 2011-2012 Hakim El Hattab, http://hakim.se
|
||||
|
||||
* Simula theme made by Hans Petter Langtangen.
|
||||
*/
|
||||
/* changed by hpl from 36px; */
|
||||
/* changed by hpl from 'League Gothic', Impact, sans-serif; */
|
||||
/* changed by hpl from uppercase; */
|
||||
/*********************************************
|
||||
* GLOBAL STYLES
|
||||
*********************************************/
|
||||
body {
|
||||
background: white;
|
||||
background-color: white; }
|
||||
|
||||
.reveal {
|
||||
font-family: "Lato", sans-serif;
|
||||
font-size: 30px;
|
||||
font-weight: normal;
|
||||
letter-spacing: -0.02em;
|
||||
color: #404040; }
|
||||
|
||||
::selection {
|
||||
color: white;
|
||||
background: rgba(0, 0, 0, 0.99);
|
||||
text-shadow: none; }
|
||||
|
||||
/*********************************************
|
||||
* HEADERS
|
||||
*********************************************/
|
||||
.reveal h1,
|
||||
.reveal h2,
|
||||
.reveal h3,
|
||||
.reveal h4,
|
||||
.reveal h5,
|
||||
.reveal h6 {
|
||||
margin: 0 0 20px 0;
|
||||
color: #ff8800;
|
||||
font-family: "Helvetica", Impact, sans-serif;
|
||||
line-height: 1.1em; /* changed (by hpl) from 0.9em */
|
||||
letter-spacing: 0.02em;
|
||||
text-transform: none;
|
||||
text-shadow: none; }
|
||||
|
||||
.reveal h1 {
|
||||
line-height: 1.2em;
|
||||
/* added by hpl */
|
||||
text-shadow: 0px 0px 6px rgba(0, 0, 0, 0.2); }
|
||||
|
||||
/*********************************************
|
||||
* LINKS
|
||||
*********************************************/
|
||||
.reveal a:not(.image) {
|
||||
color: #ff8800;
|
||||
text-decoration: none;
|
||||
-webkit-transition: color .15s ease;
|
||||
-moz-transition: color .15s ease;
|
||||
-ms-transition: color .15s ease;
|
||||
-o-transition: color .15s ease;
|
||||
transition: color .15s ease; }
|
||||
|
||||
.reveal a:not(.image):hover {
|
||||
color: #ffb866;
|
||||
text-shadow: none;
|
||||
border: none; }
|
||||
|
||||
.reveal .roll span:after {
|
||||
color: #fff;
|
||||
background: #b35f00; }
|
||||
|
||||
/*********************************************
|
||||
* IMAGES
|
||||
*********************************************/
|
||||
.reveal section img {
|
||||
margin: 15px 0px;
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
border: 4px solid #404040;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.15);
|
||||
-webkit-transition: all .2s linear;
|
||||
-moz-transition: all .2s linear;
|
||||
-ms-transition: all .2s linear;
|
||||
-o-transition: all .2s linear;
|
||||
transition: all .2s linear; }
|
||||
|
||||
.reveal a:hover img {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
border-color: #ff8800;
|
||||
box-shadow: 0 0 20px rgba(0, 0, 0, 0.55); }
|
||||
|
||||
/*********************************************
|
||||
* NAVIGATION CONTROLS
|
||||
*********************************************/
|
||||
.reveal .controls div.navigate-left,
|
||||
.reveal .controls div.navigate-left.enabled {
|
||||
border-right-color: #ff8800; }
|
||||
|
||||
.reveal .controls div.navigate-right,
|
||||
.reveal .controls div.navigate-right.enabled {
|
||||
border-left-color: #ff8800; }
|
||||
|
||||
.reveal .controls div.navigate-up,
|
||||
.reveal .controls div.navigate-up.enabled {
|
||||
border-bottom-color: #ff8800; }
|
||||
|
||||
.reveal .controls div.navigate-down,
|
||||
.reveal .controls div.navigate-down.enabled {
|
||||
border-top-color: #ff8800; }
|
||||
|
||||
.reveal .controls div.navigate-left.enabled:hover {
|
||||
border-right-color: #ffb866; }
|
||||
|
||||
.reveal .controls div.navigate-right.enabled:hover {
|
||||
border-left-color: #ffb866; }
|
||||
|
||||
.reveal .controls div.navigate-up.enabled:hover {
|
||||
border-bottom-color: #ffb866; }
|
||||
|
||||
.reveal .controls div.navigate-down.enabled:hover {
|
||||
border-top-color: #ffb866; }
|
||||
|
||||
/*********************************************
|
||||
* PROGRESS BAR
|
||||
*********************************************/
|
||||
.reveal .progress {
|
||||
background: rgba(0, 0, 0, 0.2); }
|
||||
|
||||
.reveal .progress span {
|
||||
background: #ff8800;
|
||||
-webkit-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
-moz-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
-ms-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
-o-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985); }
|
||||
|
||||
/*********************************************
|
||||
* SLIDE NUMBER
|
||||
*********************************************/
|
||||
.reveal .slide-number {
|
||||
color: #ff8800; }
|
||||
@@ -1,150 +0,0 @@
|
||||
@import url(https://fonts.googleapis.com/css?family=Quicksand:400,700,400italic,700italic);
|
||||
@import url(https://fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,400,700);
|
||||
/**
|
||||
* Sky theme for reveal.js.
|
||||
*
|
||||
* Copyright (C) 2011-2012 Hakim El Hattab, http://hakim.se
|
||||
*/
|
||||
/* changed by hpl from 36px; */
|
||||
/* changed by hpl from 'League Gothic', Impact, sans-serif; */
|
||||
/* changed by hpl from uppercase; */
|
||||
.reveal a:not(.image) {
|
||||
line-height: 1.3em; }
|
||||
|
||||
/*********************************************
|
||||
* GLOBAL STYLES
|
||||
*********************************************/
|
||||
body {
|
||||
background: #add9e4;
|
||||
background: -moz-radial-gradient(center, circle cover, #f7fbfc 0%, #add9e4 100%);
|
||||
background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%, #f7fbfc), color-stop(100%, #add9e4));
|
||||
background: -webkit-radial-gradient(center, circle cover, #f7fbfc 0%, #add9e4 100%);
|
||||
background: -o-radial-gradient(center, circle cover, #f7fbfc 0%, #add9e4 100%);
|
||||
background: -ms-radial-gradient(center, circle cover, #f7fbfc 0%, #add9e4 100%);
|
||||
background: radial-gradient(center, circle cover, #f7fbfc 0%, #add9e4 100%);
|
||||
background-color: #f7fbfc; }
|
||||
|
||||
.reveal {
|
||||
font-family: "Open Sans", sans-serif;
|
||||
font-size: 30px;
|
||||
font-weight: normal;
|
||||
letter-spacing: -0.02em;
|
||||
color: #333333; }
|
||||
|
||||
::selection {
|
||||
color: white;
|
||||
background: #134674;
|
||||
text-shadow: none; }
|
||||
|
||||
/*********************************************
|
||||
* HEADERS
|
||||
*********************************************/
|
||||
.reveal h1,
|
||||
.reveal h2,
|
||||
.reveal h3,
|
||||
.reveal h4,
|
||||
.reveal h5,
|
||||
.reveal h6 {
|
||||
margin: 0 0 20px 0;
|
||||
color: #333333;
|
||||
font-family: "Quicksand", sans-serif;
|
||||
line-height: 1.1em; /* changed (by hpl) from 0.9em */
|
||||
letter-spacing: -0.08em;
|
||||
text-transform: none;
|
||||
text-shadow: none; }
|
||||
|
||||
.reveal h1 {
|
||||
line-height: 1.2em;
|
||||
/* added by hpl */
|
||||
text-shadow: 0px 0px 6px rgba(0, 0, 0, 0.2); }
|
||||
|
||||
/*********************************************
|
||||
* LINKS
|
||||
*********************************************/
|
||||
.reveal a:not(.image) {
|
||||
color: #3b759e;
|
||||
text-decoration: none;
|
||||
-webkit-transition: color .15s ease;
|
||||
-moz-transition: color .15s ease;
|
||||
-ms-transition: color .15s ease;
|
||||
-o-transition: color .15s ease;
|
||||
transition: color .15s ease; }
|
||||
|
||||
.reveal a:not(.image):hover {
|
||||
color: #74a7cb;
|
||||
text-shadow: none;
|
||||
border: none; }
|
||||
|
||||
.reveal .roll span:after {
|
||||
color: #fff;
|
||||
background: #264c66; }
|
||||
|
||||
/*********************************************
|
||||
* IMAGES
|
||||
*********************************************/
|
||||
.reveal section img {
|
||||
margin: 15px 0px;
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
border: 4px solid #333333;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.15);
|
||||
-webkit-transition: all .2s linear;
|
||||
-moz-transition: all .2s linear;
|
||||
-ms-transition: all .2s linear;
|
||||
-o-transition: all .2s linear;
|
||||
transition: all .2s linear; }
|
||||
|
||||
.reveal a:hover img {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
border-color: #3b759e;
|
||||
box-shadow: 0 0 20px rgba(0, 0, 0, 0.55); }
|
||||
|
||||
/*********************************************
|
||||
* NAVIGATION CONTROLS
|
||||
*********************************************/
|
||||
.reveal .controls div.navigate-left,
|
||||
.reveal .controls div.navigate-left.enabled {
|
||||
border-right-color: #3b759e; }
|
||||
|
||||
.reveal .controls div.navigate-right,
|
||||
.reveal .controls div.navigate-right.enabled {
|
||||
border-left-color: #3b759e; }
|
||||
|
||||
.reveal .controls div.navigate-up,
|
||||
.reveal .controls div.navigate-up.enabled {
|
||||
border-bottom-color: #3b759e; }
|
||||
|
||||
.reveal .controls div.navigate-down,
|
||||
.reveal .controls div.navigate-down.enabled {
|
||||
border-top-color: #3b759e; }
|
||||
|
||||
.reveal .controls div.navigate-left.enabled:hover {
|
||||
border-right-color: #74a7cb; }
|
||||
|
||||
.reveal .controls div.navigate-right.enabled:hover {
|
||||
border-left-color: #74a7cb; }
|
||||
|
||||
.reveal .controls div.navigate-up.enabled:hover {
|
||||
border-bottom-color: #74a7cb; }
|
||||
|
||||
.reveal .controls div.navigate-down.enabled:hover {
|
||||
border-top-color: #74a7cb; }
|
||||
|
||||
/*********************************************
|
||||
* PROGRESS BAR
|
||||
*********************************************/
|
||||
.reveal .progress {
|
||||
background: rgba(0, 0, 0, 0.2); }
|
||||
|
||||
.reveal .progress span {
|
||||
background: #3b759e;
|
||||
-webkit-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
-moz-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
-ms-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
-o-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985); }
|
||||
|
||||
/*********************************************
|
||||
* SLIDE NUMBER
|
||||
*********************************************/
|
||||
.reveal .slide-number {
|
||||
color: #3b759e; }
|
||||
@@ -1,153 +0,0 @@
|
||||
@import url(https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic);
|
||||
/**
|
||||
* Solarized Light theme for reveal.js.
|
||||
* Author: Achim Staebler
|
||||
*/
|
||||
/* changed by hpl from 36px; */
|
||||
/* changed by hpl from 'League Gothic', Impact, sans-serif; */
|
||||
/* changed by hpl from uppercase; */
|
||||
@font-face {
|
||||
font-family: 'League Gothic';
|
||||
src: url("../../lib/font/league_gothic-webfont.eot");
|
||||
src: url("../../lib/font/league_gothic-webfont.eot?#iefix") format("embedded-opentype"), url("../../lib/font/league_gothic-webfont.woff") format("woff"), url("../../lib/font/league_gothic-webfont.ttf") format("truetype"), url("../../lib/font/league_gothic-webfont.svg#LeagueGothicRegular") format("svg");
|
||||
font-weight: normal;
|
||||
font-style: normal; }
|
||||
|
||||
/**
|
||||
* Solarized colors by Ethan Schoonover
|
||||
*/
|
||||
html * {
|
||||
color-profile: sRGB;
|
||||
rendering-intent: auto; }
|
||||
|
||||
/*********************************************
|
||||
* GLOBAL STYLES
|
||||
*********************************************/
|
||||
body {
|
||||
background: #fdf6e3;
|
||||
background-color: #fdf6e3; }
|
||||
|
||||
.reveal {
|
||||
font-family: "Lato", sans-serif;
|
||||
font-size: 30px;
|
||||
font-weight: normal;
|
||||
letter-spacing: -0.02em;
|
||||
color: #657b83; }
|
||||
|
||||
::selection {
|
||||
color: white;
|
||||
background: #d33682;
|
||||
text-shadow: none; }
|
||||
|
||||
/*********************************************
|
||||
* HEADERS
|
||||
*********************************************/
|
||||
.reveal h1,
|
||||
.reveal h2,
|
||||
.reveal h3,
|
||||
.reveal h4,
|
||||
.reveal h5,
|
||||
.reveal h6 {
|
||||
margin: 0 0 20px 0;
|
||||
color: #586e75;
|
||||
font-family: "Helvetica", Impact, sans-serif;
|
||||
line-height: 1.1em; /* changed (by hpl) from 0.9em */
|
||||
letter-spacing: 0.02em;
|
||||
text-transform: none;
|
||||
text-shadow: none; }
|
||||
|
||||
.reveal h1 {
|
||||
line-height: 1.2em;
|
||||
/* added by hpl */
|
||||
text-shadow: 0px 0px 6px rgba(0, 0, 0, 0.2); }
|
||||
|
||||
/*********************************************
|
||||
* LINKS
|
||||
*********************************************/
|
||||
.reveal a:not(.image) {
|
||||
color: #268bd2;
|
||||
text-decoration: none;
|
||||
-webkit-transition: color .15s ease;
|
||||
-moz-transition: color .15s ease;
|
||||
-ms-transition: color .15s ease;
|
||||
-o-transition: color .15s ease;
|
||||
transition: color .15s ease; }
|
||||
|
||||
.reveal a:not(.image):hover {
|
||||
color: #78b9e6;
|
||||
text-shadow: none;
|
||||
border: none; }
|
||||
|
||||
.reveal .roll span:after {
|
||||
color: #fff;
|
||||
background: #1a6091; }
|
||||
|
||||
/*********************************************
|
||||
* IMAGES
|
||||
*********************************************/
|
||||
.reveal section img {
|
||||
margin: 15px 0px;
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
border: 4px solid #657b83;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.15);
|
||||
-webkit-transition: all .2s linear;
|
||||
-moz-transition: all .2s linear;
|
||||
-ms-transition: all .2s linear;
|
||||
-o-transition: all .2s linear;
|
||||
transition: all .2s linear; }
|
||||
|
||||
.reveal a:hover img {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
border-color: #268bd2;
|
||||
box-shadow: 0 0 20px rgba(0, 0, 0, 0.55); }
|
||||
|
||||
/*********************************************
|
||||
* NAVIGATION CONTROLS
|
||||
*********************************************/
|
||||
.reveal .controls div.navigate-left,
|
||||
.reveal .controls div.navigate-left.enabled {
|
||||
border-right-color: #268bd2; }
|
||||
|
||||
.reveal .controls div.navigate-right,
|
||||
.reveal .controls div.navigate-right.enabled {
|
||||
border-left-color: #268bd2; }
|
||||
|
||||
.reveal .controls div.navigate-up,
|
||||
.reveal .controls div.navigate-up.enabled {
|
||||
border-bottom-color: #268bd2; }
|
||||
|
||||
.reveal .controls div.navigate-down,
|
||||
.reveal .controls div.navigate-down.enabled {
|
||||
border-top-color: #268bd2; }
|
||||
|
||||
.reveal .controls div.navigate-left.enabled:hover {
|
||||
border-right-color: #78b9e6; }
|
||||
|
||||
.reveal .controls div.navigate-right.enabled:hover {
|
||||
border-left-color: #78b9e6; }
|
||||
|
||||
.reveal .controls div.navigate-up.enabled:hover {
|
||||
border-bottom-color: #78b9e6; }
|
||||
|
||||
.reveal .controls div.navigate-down.enabled:hover {
|
||||
border-top-color: #78b9e6; }
|
||||
|
||||
/*********************************************
|
||||
* PROGRESS BAR
|
||||
*********************************************/
|
||||
.reveal .progress {
|
||||
background: rgba(0, 0, 0, 0.2); }
|
||||
|
||||
.reveal .progress span {
|
||||
background: #268bd2;
|
||||
-webkit-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
-moz-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
-ms-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
-o-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985); }
|
||||
|
||||
/*********************************************
|
||||
* SLIDE NUMBER
|
||||
*********************************************/
|
||||
.reveal .slide-number {
|
||||
color: #268bd2; }
|
||||
@@ -1,50 +0,0 @@
|
||||
/**
|
||||
* Beige theme for reveal.js.
|
||||
*
|
||||
* Copyright (C) 2011-2012 Hakim El Hattab, http://hakim.se
|
||||
*/
|
||||
|
||||
|
||||
// Default mixins and settings -----------------
|
||||
@import "../template/mixins";
|
||||
@import "../template/settings";
|
||||
// ---------------------------------------------
|
||||
|
||||
|
||||
|
||||
// Include theme-specific fonts
|
||||
@font-face {
|
||||
font-family: 'League Gothic';
|
||||
src: url('../../lib/font/league_gothic-webfont.eot');
|
||||
src: url('../../lib/font/league_gothic-webfont.eot?#iefix') format('embedded-opentype'),
|
||||
url('../../lib/font/league_gothic-webfont.woff') format('woff'),
|
||||
url('../../lib/font/league_gothic-webfont.ttf') format('truetype'),
|
||||
url('../../lib/font/league_gothic-webfont.svg#LeagueGothicRegular') format('svg');
|
||||
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
@import url(https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic);
|
||||
|
||||
|
||||
// Override theme settings (see ../template/settings.scss)
|
||||
$mainColor: #333;
|
||||
$headingColor: #222; /* changed (by hpl) from #333; */
|
||||
$headingTextShadow: none;
|
||||
$backgroundColor: #f7f3de;
|
||||
$linkColor: #8b743d;
|
||||
$linkColorHover: lighten( $linkColor, 20% );
|
||||
$selectionBackgroundColor: rgba(79, 64, 28, 0.99);
|
||||
$heading1TextShadow: 0 1px 0 #ccc, 0 2px 0 #c9c9c9, 0 3px 0 #bbb, 0 4px 0 #b9b9b9, 0 5px 0 #aaa, 0 6px 1px rgba(0,0,0,.1), 0 0 5px rgba(0,0,0,.1), 0 1px 3px rgba(0,0,0,.3), 0 3px 5px rgba(0,0,0,.2), 0 5px 10px rgba(0,0,0,.25), 0 20px 20px rgba(0,0,0,.15);
|
||||
|
||||
// Background generator
|
||||
@mixin bodyBackground() {
|
||||
@include radial-gradient( rgba(247,242,211,1), rgba(255,255,255,1) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Theme template ------------------------------
|
||||
@import "../template/theme";
|
||||
// ---------------------------------------------
|
||||
@@ -1,51 +0,0 @@
|
||||
/**
|
||||
* Beige theme for reveal.js.
|
||||
*
|
||||
* Copyright (C) 2011-2012 Hakim El Hattab, http://hakim.se
|
||||
*/
|
||||
|
||||
|
||||
// Default mixins and settings -----------------
|
||||
@import "../template/mixins";
|
||||
@import "../template/settings";
|
||||
// ---------------------------------------------
|
||||
|
||||
|
||||
|
||||
// Include theme-specific fonts
|
||||
@font-face {
|
||||
font-family: 'League Gothic';
|
||||
src: url('../../lib/font/league_gothic-webfont.eot');
|
||||
src: url('../../lib/font/league_gothic-webfont.eot?#iefix') format('embedded-opentype'),
|
||||
url('../../lib/font/league_gothic-webfont.woff') format('woff'),
|
||||
url('../../lib/font/league_gothic-webfont.ttf') format('truetype'),
|
||||
url('../../lib/font/league_gothic-webfont.svg#LeagueGothicRegular') format('svg');
|
||||
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
@import url(https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic);
|
||||
|
||||
|
||||
// Override theme settings (see ../template/settings.scss)
|
||||
$mainColor: #333;
|
||||
$mainFontSize: 25px; /* added/changed by hpl */
|
||||
$headingColor: #222; /* changed (by hpl) from #333; */
|
||||
$headingTextShadow: none;
|
||||
$backgroundColor: #f7f3de;
|
||||
$linkColor: #8b743d;
|
||||
$linkColorHover: lighten( $linkColor, 20% );
|
||||
$selectionBackgroundColor: rgba(79, 64, 28, 0.99);
|
||||
$heading1TextShadow: 0 1px 0 #ccc, 0 2px 0 #c9c9c9, 0 3px 0 #bbb, 0 4px 0 #b9b9b9, 0 5px 0 #aaa, 0 6px 1px rgba(0,0,0,.1), 0 0 5px rgba(0,0,0,.1), 0 1px 3px rgba(0,0,0,.3), 0 3px 5px rgba(0,0,0,.2), 0 5px 10px rgba(0,0,0,.25), 0 20px 20px rgba(0,0,0,.15);
|
||||
|
||||
// Background generator
|
||||
@mixin bodyBackground() {
|
||||
@include radial-gradient( rgba(247,242,211,1), rgba(255,255,255,1) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Theme template ------------------------------
|
||||
@import "../template/theme";
|
||||
// ---------------------------------------------
|
||||
@@ -1,49 +0,0 @@
|
||||
/**
|
||||
* Black theme for reveal.js. This is the opposite of the 'white' theme.
|
||||
*
|
||||
* Copyright (C) 2015 Hakim El Hattab, http://hakim.se
|
||||
*/
|
||||
|
||||
|
||||
// Default mixins and settings -----------------
|
||||
@import "../template/mixins";
|
||||
@import "../template/settings";
|
||||
// ---------------------------------------------
|
||||
|
||||
|
||||
// Include theme-specific fonts
|
||||
@import url(../../lib/font/source-sans-pro/source-sans-pro.css);
|
||||
|
||||
|
||||
// Override theme settings (see ../template/settings.scss)
|
||||
$backgroundColor: #222;
|
||||
|
||||
$mainColor: #fff;
|
||||
$headingColor: #fff;
|
||||
|
||||
$mainFontSize: 38px;
|
||||
$mainFont: 'Source Sans Pro', Helvetica, sans-serif;
|
||||
$headingFont: 'Source Sans Pro', Helvetica, sans-serif;
|
||||
$headingTextShadow: none;
|
||||
$headingLetterSpacing: normal;
|
||||
$headingTextTransform: uppercase;
|
||||
$headingFontWeight: 600;
|
||||
$linkColor: #42affa;
|
||||
$linkColorHover: lighten( $linkColor, 15% );
|
||||
$selectionBackgroundColor: lighten( $linkColor, 25% );
|
||||
|
||||
$heading1Size: 2.5em;
|
||||
$heading2Size: 1.6em;
|
||||
$heading3Size: 1.3em;
|
||||
$heading4Size: 1.0em;
|
||||
|
||||
section.has-light-background {
|
||||
&, h1, h2, h3, h4, h5, h6 {
|
||||
color: #222;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Theme template ------------------------------
|
||||
@import "../template/theme";
|
||||
// ---------------------------------------------
|
||||
@@ -1,91 +0,0 @@
|
||||
/**
|
||||
* Blood theme for reveal.js
|
||||
* Author: Walther http://github.com/Walther
|
||||
*
|
||||
* Designed to be used with highlight.js theme
|
||||
* "monokai_sublime.css" available from
|
||||
* https://github.com/isagalaev/highlight.js/
|
||||
*
|
||||
* For other themes, change $codeBackground accordingly.
|
||||
*
|
||||
*/
|
||||
|
||||
// Default mixins and settings -----------------
|
||||
@import "../template/mixins";
|
||||
@import "../template/settings";
|
||||
// ---------------------------------------------
|
||||
|
||||
// Include theme-specific fonts
|
||||
|
||||
@import url(https://fonts.googleapis.com/css?family=Ubuntu:300,700,300italic,700italic);
|
||||
|
||||
// Colors used in the theme
|
||||
$blood: #a23;
|
||||
$coal: #222;
|
||||
$codeBackground: #23241f;
|
||||
|
||||
// Main text
|
||||
$mainFont: Ubuntu, 'sans-serif';
|
||||
$mainFontSize: 30px;
|
||||
$mainColor: #eee;
|
||||
|
||||
// Headings
|
||||
$headingFont: Ubuntu, 'sans-serif';
|
||||
$headingTextShadow: 2px 2px 2px $coal;
|
||||
|
||||
// h1 shadow, borrowed humbly from
|
||||
// (c) Default theme by Hakim El Hattab
|
||||
$heading1TextShadow: 0 1px 0 #ccc, 0 2px 0 #c9c9c9, 0 3px 0 #bbb, 0 4px 0 #b9b9b9, 0 5px 0 #aaa, 0 6px 1px rgba(0,0,0,.1), 0 0 5px rgba(0,0,0,.1), 0 1px 3px rgba(0,0,0,.3), 0 3px 5px rgba(0,0,0,.2), 0 5px 10px rgba(0,0,0,.25), 0 20px 20px rgba(0,0,0,.15);
|
||||
|
||||
// Links
|
||||
$linkColor: $blood;
|
||||
$linkColorHover: lighten( $linkColor, 20% );
|
||||
|
||||
// Text selection
|
||||
$selectionBackgroundColor: $blood;
|
||||
$selectionColor: #fff;
|
||||
|
||||
// Background generator
|
||||
@mixin bodyBackground() {
|
||||
@include radial-gradient( $coal, lighten( $coal, 25% ) );
|
||||
}
|
||||
|
||||
// Theme template ------------------------------
|
||||
@import "../template/theme";
|
||||
// ---------------------------------------------
|
||||
|
||||
// some overrides after theme template import
|
||||
|
||||
.reveal p {
|
||||
font-weight: 300;
|
||||
text-shadow: 1px 1px $coal;
|
||||
}
|
||||
|
||||
.reveal h1,
|
||||
.reveal h2,
|
||||
.reveal h3,
|
||||
.reveal h4,
|
||||
.reveal h5,
|
||||
.reveal h6 {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.reveal a:not(.image),
|
||||
.reveal a:not(.image):hover {
|
||||
text-shadow: 2px 2px 2px #000;
|
||||
}
|
||||
|
||||
.reveal small a:not(.image),
|
||||
.reveal small a:not(.image):hover {
|
||||
text-shadow: 1px 1px 1px #000;
|
||||
}
|
||||
|
||||
.reveal p code {
|
||||
background-color: $codeBackground;
|
||||
display: inline-block;
|
||||
border-radius: 7px;
|
||||
}
|
||||
|
||||
.reveal small code {
|
||||
vertical-align: baseline;
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
/**
|
||||
* A simple theme for reveal.js presentations, similar
|
||||
* to the default theme. The accent color is darkblue.
|
||||
*
|
||||
* This theme is Copyright (C) 2012 Owen Versteeg, https://github.com/StereotypicalApps. It is MIT licensed.
|
||||
* reveal.js is Copyright (C) 2011-2012 Hakim El Hattab, http://hakim.se
|
||||
|
||||
* Center for Biomedical Computing theme made by Hans Petter Langtangen.
|
||||
*/
|
||||
|
||||
|
||||
// Default mixins and settings -----------------
|
||||
@import "../template/mixins";
|
||||
@import "../template/settings";
|
||||
// ---------------------------------------------
|
||||
|
||||
|
||||
|
||||
// Include theme-specific fonts
|
||||
@import url(https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic);
|
||||
|
||||
|
||||
// Override theme settings (see ../template/settings.scss)
|
||||
$mainFont: 'Lato', sans-serif;
|
||||
$mainColor: #404040;
|
||||
$headingFont: 'Helvetica', Impact, sans-serif;
|
||||
$headingColor: #8A0808;
|
||||
$headingTextShadow: none;
|
||||
$headingTextTransform: none;
|
||||
$backgroundColor: #fff;
|
||||
$linkColor: #8A0808;
|
||||
$linkColorHover: lighten( $linkColor, 20% );
|
||||
$selectionBackgroundColor: rgba(0, 0, 0, 0.99);
|
||||
|
||||
|
||||
|
||||
// Theme template ------------------------------
|
||||
@import "../template/theme";
|
||||
// ---------------------------------------------
|
||||
@@ -1,42 +0,0 @@
|
||||
/**
|
||||
* Default theme for reveal.js.
|
||||
*
|
||||
* Copyright (C) 2011-2012 Hakim El Hattab, http://hakim.se
|
||||
*/
|
||||
|
||||
|
||||
// Default mixins and settings -----------------
|
||||
@import "../template/mixins";
|
||||
@import "../template/settings";
|
||||
// ---------------------------------------------
|
||||
|
||||
|
||||
|
||||
// Include theme-specific fonts
|
||||
@font-face {
|
||||
font-family: 'League Gothic';
|
||||
src: url('../../lib/font/league_gothic-webfont.eot');
|
||||
src: url('../../lib/font/league_gothic-webfont.eot?#iefix') format('embedded-opentype'),
|
||||
url('../../lib/font/league_gothic-webfont.woff') format('woff'),
|
||||
url('../../lib/font/league_gothic-webfont.ttf') format('truetype'),
|
||||
url('../../lib/font/league_gothic-webfont.svg#LeagueGothicRegular') format('svg');
|
||||
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
@import url(https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic);
|
||||
|
||||
// Override theme settings (see ../template/settings.scss)
|
||||
$heading1TextShadow: 0 1px 0 #ccc, 0 2px 0 #c9c9c9, 0 3px 0 #bbb, 0 4px 0 #b9b9b9, 0 5px 0 #aaa, 0 6px 1px rgba(0,0,0,.1), 0 0 5px rgba(0,0,0,.1), 0 1px 3px rgba(0,0,0,.3), 0 3px 5px rgba(0,0,0,.2), 0 5px 10px rgba(0,0,0,.25), 0 20px 20px rgba(0,0,0,.15);
|
||||
|
||||
// Background generator
|
||||
@mixin bodyBackground() {
|
||||
@include radial-gradient( rgba(28,30,32,1), rgba(85,90,95,1) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Theme template ------------------------------
|
||||
@import "../template/theme";
|
||||
// ---------------------------------------------
|
||||
@@ -1,42 +0,0 @@
|
||||
/**
|
||||
* Default theme for reveal.js.
|
||||
*
|
||||
* Copyright (C) 2011-2012 Hakim El Hattab, http://hakim.se
|
||||
*/
|
||||
|
||||
|
||||
// Default mixins and settings -----------------
|
||||
@import "../template/mixins";
|
||||
@import "../template/settings";
|
||||
// ---------------------------------------------
|
||||
|
||||
|
||||
|
||||
// Include theme-specific fonts
|
||||
@font-face {
|
||||
font-family: 'League Gothic';
|
||||
src: url('../../lib/font/league_gothic-webfont.eot');
|
||||
src: url('../../lib/font/league_gothic-webfont.eot?#iefix') format('embedded-opentype'),
|
||||
url('../../lib/font/league_gothic-webfont.woff') format('woff'),
|
||||
url('../../lib/font/league_gothic-webfont.ttf') format('truetype'),
|
||||
url('../../lib/font/league_gothic-webfont.svg#LeagueGothicRegular') format('svg');
|
||||
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
@import url(https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic);
|
||||
|
||||
// Override theme settings (see ../template/settings.scss)
|
||||
$heading1TextShadow: 0 1px 0 #ccc, 0 2px 0 #c9c9c9, 0 3px 0 #bbb, 0 4px 0 #b9b9b9, 0 5px 0 #aaa, 0 6px 1px rgba(0,0,0,.1), 0 0 5px rgba(0,0,0,.1), 0 1px 3px rgba(0,0,0,.3), 0 3px 5px rgba(0,0,0,.2), 0 5px 10px rgba(0,0,0,.25), 0 20px 20px rgba(0,0,0,.15);
|
||||
|
||||
// Background generator
|
||||
@mixin bodyBackground() {
|
||||
@include radial-gradient( rgba(28,30,32,1), rgba(85,90,95,1) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Theme template ------------------------------
|
||||
@import "../template/theme";
|
||||
// ---------------------------------------------
|
||||
@@ -1,34 +0,0 @@
|
||||
/**
|
||||
* League theme for reveal.js.
|
||||
*
|
||||
* This was the default theme pre-3.0.0.
|
||||
*
|
||||
* Copyright (C) 2011-2012 Hakim El Hattab, http://hakim.se
|
||||
*/
|
||||
|
||||
|
||||
// Default mixins and settings -----------------
|
||||
@import "../template/mixins";
|
||||
@import "../template/settings";
|
||||
// ---------------------------------------------
|
||||
|
||||
|
||||
|
||||
// Include theme-specific fonts
|
||||
@import url(../../lib/font/league-gothic/league-gothic.css);
|
||||
@import url(https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic);
|
||||
|
||||
// Override theme settings (see ../template/settings.scss)
|
||||
$headingTextShadow: 0px 0px 6px rgba(0,0,0,0.2);
|
||||
$heading1TextShadow: 0 1px 0 #ccc, 0 2px 0 #c9c9c9, 0 3px 0 #bbb, 0 4px 0 #b9b9b9, 0 5px 0 #aaa, 0 6px 1px rgba(0,0,0,.1), 0 0 5px rgba(0,0,0,.1), 0 1px 3px rgba(0,0,0,.3), 0 3px 5px rgba(0,0,0,.2), 0 5px 10px rgba(0,0,0,.25), 0 20px 20px rgba(0,0,0,.15);
|
||||
|
||||
// Background generator
|
||||
@mixin bodyBackground() {
|
||||
@include radial-gradient( rgba(28,30,32,1), rgba(85,90,95,1) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Theme template ------------------------------
|
||||
@import "../template/theme";
|
||||
// ---------------------------------------------
|
||||
@@ -1,68 +0,0 @@
|
||||
/**
|
||||
* Solarized Dark theme for reveal.js.
|
||||
* Author: Achim Staebler
|
||||
*/
|
||||
|
||||
|
||||
// Default mixins and settings -----------------
|
||||
@import "../template/mixins";
|
||||
@import "../template/settings";
|
||||
// ---------------------------------------------
|
||||
|
||||
|
||||
|
||||
// Include theme-specific fonts
|
||||
@font-face {
|
||||
font-family: 'League Gothic';
|
||||
src: url('../../lib/font/league_gothic-webfont.eot');
|
||||
src: url('../../lib/font/league_gothic-webfont.eot?#iefix') format('embedded-opentype'),
|
||||
url('../../lib/font/league_gothic-webfont.woff') format('woff'),
|
||||
url('../../lib/font/league_gothic-webfont.ttf') format('truetype'),
|
||||
url('../../lib/font/league_gothic-webfont.svg#LeagueGothicRegular') format('svg');
|
||||
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
@import url(https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic);
|
||||
|
||||
/**
|
||||
* Solarized colors by Ethan Schoonover
|
||||
*/
|
||||
html * {
|
||||
color-profile: sRGB;
|
||||
rendering-intent: auto;
|
||||
}
|
||||
|
||||
// Solarized colors
|
||||
$base03: #002b36;
|
||||
$base02: #073642;
|
||||
$base01: #586e75;
|
||||
$base00: #657b83;
|
||||
$base0: #839496;
|
||||
$base1: #93a1a1;
|
||||
$base2: #eee8d5;
|
||||
$base3: #fdf6e3;
|
||||
$yellow: #b58900;
|
||||
$orange: #cb4b16;
|
||||
$red: #dc322f;
|
||||
$magenta: #d33682;
|
||||
$violet: #6c71c4;
|
||||
$blue: #268bd2;
|
||||
$cyan: #2aa198;
|
||||
$green: #859900;
|
||||
|
||||
// Override theme settings (see ../template/settings.scss)
|
||||
$mainColor: $base1;
|
||||
$headingColor: $base2;
|
||||
$headingTextShadow: none;
|
||||
$backgroundColor: $base03;
|
||||
$linkColor: $blue;
|
||||
$linkColorHover: lighten( $linkColor, 20% );
|
||||
$selectionBackgroundColor: $magenta;
|
||||
|
||||
|
||||
|
||||
// Theme template ------------------------------
|
||||
@import "../template/theme";
|
||||
// ---------------------------------------------
|
||||
@@ -1,35 +0,0 @@
|
||||
/**
|
||||
* Black theme for reveal.js.
|
||||
*
|
||||
* Copyright (C) 2011-2012 Hakim El Hattab, http://hakim.se
|
||||
*/
|
||||
|
||||
|
||||
// Default mixins and settings -----------------
|
||||
@import "../template/mixins";
|
||||
@import "../template/settings";
|
||||
// ---------------------------------------------
|
||||
|
||||
|
||||
// Include theme-specific fonts
|
||||
@import url(https://fonts.googleapis.com/css?family=Montserrat:700);
|
||||
@import url(https://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic,700italic);
|
||||
|
||||
|
||||
// Override theme settings (see ../template/settings.scss)
|
||||
$backgroundColor: #111;
|
||||
|
||||
$mainFont: 'Open Sans', sans-serif;
|
||||
$linkColor: #e7ad52;
|
||||
$linkColorHover: lighten( $linkColor, 20% );
|
||||
$headingFont: 'Montserrat', Impact, sans-serif;
|
||||
$headingTextShadow: none;
|
||||
$headingLetterSpacing: -0.03em;
|
||||
$headingTextTransform: none;
|
||||
$selectionBackgroundColor: #e7ad52;
|
||||
$mainFontSize: 30px;
|
||||
|
||||
|
||||
// Theme template ------------------------------
|
||||
@import "../template/theme";
|
||||
// ---------------------------------------------
|
||||
@@ -1,35 +0,0 @@
|
||||
/**
|
||||
* A simple theme for reveal.js presentations, similar
|
||||
* to the default theme. The accent color is brown.
|
||||
*
|
||||
* This theme is Copyright (C) 2012-2013 Owen Versteeg, http://owenversteeg.com - it is MIT licensed.
|
||||
*/
|
||||
|
||||
|
||||
// Default mixins and settings -----------------
|
||||
@import "../template/mixins";
|
||||
@import "../template/settings";
|
||||
// ---------------------------------------------
|
||||
|
||||
|
||||
|
||||
// Override theme settings (see ../template/settings.scss)
|
||||
$mainFont: 'Palatino Linotype', 'Book Antiqua', Palatino, FreeSerif, serif;
|
||||
$mainColor: #000;
|
||||
$headingFont: 'Palatino Linotype', 'Book Antiqua', Palatino, FreeSerif, serif;
|
||||
$headingColor: #383D3D;
|
||||
$headingTextShadow: none;
|
||||
$headingTextTransform: none;
|
||||
$backgroundColor: #F0F1EB;
|
||||
$linkColor: #51483D;
|
||||
$linkColorHover: lighten( $linkColor, 20% );
|
||||
$selectionBackgroundColor: #26351C;
|
||||
|
||||
.reveal a:not(.image) {
|
||||
line-height: 1.3em;
|
||||
}
|
||||
|
||||
|
||||
// Theme template ------------------------------
|
||||
@import "../template/theme";
|
||||
// ---------------------------------------------
|
||||
@@ -1,38 +0,0 @@
|
||||
/**
|
||||
* A simple theme for reveal.js presentations, similar
|
||||
* to the default theme. The accent color is darkblue.
|
||||
*
|
||||
* This theme is Copyright (C) 2012 Owen Versteeg, https://github.com/StereotypicalApps. It is MIT licensed.
|
||||
* reveal.js is Copyright (C) 2011-2012 Hakim El Hattab, http://hakim.se
|
||||
*/
|
||||
|
||||
|
||||
// Default mixins and settings -----------------
|
||||
@import "../template/mixins";
|
||||
@import "../template/settings";
|
||||
// ---------------------------------------------
|
||||
|
||||
|
||||
|
||||
// Include theme-specific fonts
|
||||
@import url(https://fonts.googleapis.com/css?family=News+Cycle:400,700);
|
||||
@import url(https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic);
|
||||
|
||||
|
||||
// Override theme settings (see ../template/settings.scss)
|
||||
$mainFont: 'Lato', sans-serif;
|
||||
$mainColor: #000;
|
||||
$headingFont: 'Helvetica', Impact, sans-serif; /* changed (by hpl) from 'News Cycle', Impact, sans-serif; */
|
||||
$headingColor: #000;
|
||||
$headingTextShadow: none;
|
||||
$headingTextTransform: none;
|
||||
$backgroundColor: #fff;
|
||||
$linkColor: #00008B;
|
||||
$linkColorHover: lighten( $linkColor, 20% );
|
||||
$selectionBackgroundColor: rgba(0, 0, 0, 0.99);
|
||||
|
||||
|
||||
|
||||
// Theme template ------------------------------
|
||||
@import "../template/theme";
|
||||
// ---------------------------------------------
|
||||
@@ -1,39 +0,0 @@
|
||||
/**
|
||||
* A simple theme for reveal.js presentations, similar
|
||||
* to the default theme. The accent color is darkblue.
|
||||
*
|
||||
* This theme is Copyright (C) 2012 Owen Versteeg, https://github.com/StereotypicalApps. It is MIT licensed.
|
||||
* reveal.js is Copyright (C) 2011-2012 Hakim El Hattab, http://hakim.se
|
||||
|
||||
* Simula theme made by Hans Petter Langtangen.
|
||||
*/
|
||||
|
||||
|
||||
// Default mixins and settings -----------------
|
||||
@import "../template/mixins";
|
||||
@import "../template/settings";
|
||||
// ---------------------------------------------
|
||||
|
||||
|
||||
|
||||
// Include theme-specific fonts
|
||||
@import url(https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic);
|
||||
|
||||
|
||||
// Override theme settings (see ../template/settings.scss)
|
||||
$mainFont: 'Lato', sans-serif;
|
||||
$mainColor: #404040;
|
||||
$headingFont: 'Helvetica', Impact, sans-serif;
|
||||
$headingColor: #ff8800;
|
||||
$headingTextShadow: none;
|
||||
$headingTextTransform: none;
|
||||
$backgroundColor: #fff;
|
||||
$linkColor: #ff8800;
|
||||
$linkColorHover: lighten( $linkColor, 20% );
|
||||
$selectionBackgroundColor: rgba(0, 0, 0, 0.99);
|
||||
|
||||
|
||||
|
||||
// Theme template ------------------------------
|
||||
@import "../template/theme";
|
||||
// ---------------------------------------------
|
||||
@@ -1,46 +0,0 @@
|
||||
/**
|
||||
* Sky theme for reveal.js.
|
||||
*
|
||||
* Copyright (C) 2011-2012 Hakim El Hattab, http://hakim.se
|
||||
*/
|
||||
|
||||
|
||||
// Default mixins and settings -----------------
|
||||
@import "../template/mixins";
|
||||
@import "../template/settings";
|
||||
// ---------------------------------------------
|
||||
|
||||
|
||||
|
||||
// Include theme-specific fonts
|
||||
@import url(https://fonts.googleapis.com/css?family=Quicksand:400,700,400italic,700italic);
|
||||
@import url(https://fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,400,700);
|
||||
|
||||
|
||||
// Override theme settings (see ../template/settings.scss)
|
||||
$mainFont: 'Open Sans', sans-serif;
|
||||
$mainColor: #333;
|
||||
$headingFont: 'Quicksand', sans-serif;
|
||||
$headingColor: #333;
|
||||
$headingLetterSpacing: -0.08em;
|
||||
$headingTextShadow: none;
|
||||
$backgroundColor: #f7fbfc;
|
||||
$linkColor: #3b759e;
|
||||
$linkColorHover: lighten( $linkColor, 20% );
|
||||
$selectionBackgroundColor: #134674;
|
||||
|
||||
// Fix links so they are not cut off
|
||||
.reveal a:not(.image) {
|
||||
line-height: 1.3em;
|
||||
}
|
||||
|
||||
// Background generator
|
||||
@mixin bodyBackground() {
|
||||
@include radial-gradient( #add9e4, #f7fbfc );
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Theme template ------------------------------
|
||||
@import "../template/theme";
|
||||
// ---------------------------------------------
|
||||
@@ -1,74 +0,0 @@
|
||||
/**
|
||||
* Solarized Light theme for reveal.js.
|
||||
* Author: Achim Staebler
|
||||
*/
|
||||
|
||||
|
||||
// Default mixins and settings -----------------
|
||||
@import "../template/mixins";
|
||||
@import "../template/settings";
|
||||
// ---------------------------------------------
|
||||
|
||||
|
||||
|
||||
// Include theme-specific fonts
|
||||
@font-face {
|
||||
font-family: 'League Gothic';
|
||||
src: url('../../lib/font/league_gothic-webfont.eot');
|
||||
src: url('../../lib/font/league_gothic-webfont.eot?#iefix') format('embedded-opentype'),
|
||||
url('../../lib/font/league_gothic-webfont.woff') format('woff'),
|
||||
url('../../lib/font/league_gothic-webfont.ttf') format('truetype'),
|
||||
url('../../lib/font/league_gothic-webfont.svg#LeagueGothicRegular') format('svg');
|
||||
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
@import url(https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic);
|
||||
|
||||
|
||||
/**
|
||||
* Solarized colors by Ethan Schoonover
|
||||
*/
|
||||
html * {
|
||||
color-profile: sRGB;
|
||||
rendering-intent: auto;
|
||||
}
|
||||
|
||||
// Solarized colors
|
||||
$base03: #002b36;
|
||||
$base02: #073642;
|
||||
$base01: #586e75;
|
||||
$base00: #657b83;
|
||||
$base0: #839496;
|
||||
$base1: #93a1a1;
|
||||
$base2: #eee8d5;
|
||||
$base3: #fdf6e3;
|
||||
$yellow: #b58900;
|
||||
$orange: #cb4b16;
|
||||
$red: #dc322f;
|
||||
$magenta: #d33682;
|
||||
$violet: #6c71c4;
|
||||
$blue: #268bd2;
|
||||
$cyan: #2aa198;
|
||||
$green: #859900;
|
||||
|
||||
// Override theme settings (see ../template/settings.scss)
|
||||
$mainColor: $base00;
|
||||
$headingColor: $base01;
|
||||
$headingTextShadow: none;
|
||||
$backgroundColor: $base3;
|
||||
$linkColor: $blue;
|
||||
$linkColorHover: lighten( $linkColor, 20% );
|
||||
$selectionBackgroundColor: $magenta;
|
||||
|
||||
// Background generator
|
||||
// @mixin bodyBackground() {
|
||||
// @include radial-gradient( rgba($base3,1), rgba(lighten($base3, 20%),1) );
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// Theme template ------------------------------
|
||||
@import "../template/theme";
|
||||
// ---------------------------------------------
|
||||
@@ -1,49 +0,0 @@
|
||||
/**
|
||||
* White theme for reveal.js. This is the opposite of the 'black' theme.
|
||||
*
|
||||
* Copyright (C) 2015 Hakim El Hattab, http://hakim.se
|
||||
*/
|
||||
|
||||
|
||||
// Default mixins and settings -----------------
|
||||
@import "../template/mixins";
|
||||
@import "../template/settings";
|
||||
// ---------------------------------------------
|
||||
|
||||
|
||||
// Include theme-specific fonts
|
||||
@import url(../../lib/font/source-sans-pro/source-sans-pro.css);
|
||||
|
||||
|
||||
// Override theme settings (see ../template/settings.scss)
|
||||
$backgroundColor: #fff;
|
||||
|
||||
$mainColor: #222;
|
||||
$headingColor: #222;
|
||||
|
||||
$mainFontSize: 38px;
|
||||
$mainFont: 'Source Sans Pro', Helvetica, sans-serif;
|
||||
$headingFont: 'Source Sans Pro', Helvetica, sans-serif;
|
||||
$headingTextShadow: none;
|
||||
$headingLetterSpacing: normal;
|
||||
$headingTextTransform: uppercase;
|
||||
$headingFontWeight: 600;
|
||||
$linkColor: #2a76dd;
|
||||
$linkColorHover: lighten( $linkColor, 15% );
|
||||
$selectionBackgroundColor: lighten( $linkColor, 25% );
|
||||
|
||||
$heading1Size: 2.5em;
|
||||
$heading2Size: 1.6em;
|
||||
$heading3Size: 1.3em;
|
||||
$heading4Size: 1.0em;
|
||||
|
||||
section.has-dark-background {
|
||||
&, h1, h2, h3, h4, h5, h6 {
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Theme template ------------------------------
|
||||
@import "../template/theme";
|
||||
// ---------------------------------------------
|
||||
@@ -1,273 +0,0 @@
|
||||
@import url(../../lib/font/source-sans-pro/source-sans-pro.css);
|
||||
/**
|
||||
* White theme for reveal.js. This is the opposite of the 'black' theme.
|
||||
*
|
||||
* Copyright (C) 2015 Hakim El Hattab, http://hakim.se
|
||||
*/
|
||||
section.has-dark-background, section.has-dark-background h1, section.has-dark-background h2, section.has-dark-background h3, section.has-dark-background h4, section.has-dark-background h5, section.has-dark-background h6 {
|
||||
color: #fff; }
|
||||
|
||||
/*********************************************
|
||||
* GLOBAL STYLES
|
||||
*********************************************/
|
||||
body {
|
||||
background: #fff;
|
||||
background-color: #fff; }
|
||||
|
||||
.reveal {
|
||||
font-family: 'Source Sans Pro', Helvetica, sans-serif;
|
||||
font-size: 30px; /* changed by hpl from 38px */
|
||||
font-weight: normal;
|
||||
color: #222; }
|
||||
|
||||
::selection {
|
||||
color: #fff;
|
||||
background: #98bdef;
|
||||
text-shadow: none; }
|
||||
|
||||
.reveal .slides > section, .reveal .slides > section > section {
|
||||
line-height: 1.1em; /* changed by hpl from 1.2; */
|
||||
font-weight: inherit; }
|
||||
|
||||
/*********************************************
|
||||
* HEADERS
|
||||
*********************************************/
|
||||
.reveal h1, .reveal h2, .reveal h3, .reveal h4, .reveal h5, .reveal h6 {
|
||||
margin: 0 0 20px 0;
|
||||
color: #222;
|
||||
font-family: 'Source Sans Pro', Helvetica, sans-serif;
|
||||
font-weight: 600;
|
||||
line-height: 1.1em; /* changed by hpl from 1.2; */
|
||||
letter-spacing: normal;
|
||||
/* text-transform: uppercase; removed by hpl */
|
||||
text-shadow: none;
|
||||
word-wrap: break-word; }
|
||||
|
||||
.reveal h1 {
|
||||
line-height: 1.2em;
|
||||
}
|
||||
|
||||
/* removed by hpl
|
||||
.reveal h1 {
|
||||
font-size: 2.5em; }
|
||||
|
||||
.reveal h2 {
|
||||
font-size: 1.6em; }
|
||||
|
||||
.reveal h3 {
|
||||
font-size: 1.3em; }
|
||||
|
||||
.reveal h4 {
|
||||
font-size: 1em; }
|
||||
*/
|
||||
|
||||
.reveal h1 {
|
||||
text-shadow: none; }
|
||||
|
||||
/*********************************************
|
||||
* OTHER
|
||||
*********************************************/
|
||||
.reveal p {
|
||||
margin: 20px 0;
|
||||
line-height: 1.3; }
|
||||
|
||||
/* Ensure certain elements are never larger than the slide itself */
|
||||
.reveal img, .reveal video, .reveal iframe {
|
||||
max-width: 95%;
|
||||
max-height: 95%; }
|
||||
|
||||
.reveal strong, .reveal b {
|
||||
font-weight: bold; }
|
||||
|
||||
.reveal em {
|
||||
font-style: italic; }
|
||||
|
||||
.reveal ol, .reveal dl, .reveal ul {
|
||||
display: inline-block;
|
||||
text-align: left;
|
||||
margin: 0 0 0 1em; }
|
||||
|
||||
.reveal ol {
|
||||
list-style-type: decimal; }
|
||||
|
||||
.reveal ul {
|
||||
list-style-type: disc; }
|
||||
|
||||
.reveal ul ul {
|
||||
list-style-type: square; }
|
||||
|
||||
.reveal ul ul ul {
|
||||
list-style-type: circle; }
|
||||
|
||||
.reveal ul ul, .reveal ul ol, .reveal ol ol, .reveal ol ul {
|
||||
display: block;
|
||||
margin-left: 40px; }
|
||||
|
||||
.reveal dt {
|
||||
font-weight: bold; }
|
||||
|
||||
.reveal dd {
|
||||
margin-left: 40px; }
|
||||
|
||||
.reveal q, .reveal blockquote {
|
||||
quotes: none; }
|
||||
|
||||
.reveal blockquote {
|
||||
display: block;
|
||||
position: relative;
|
||||
width: 70%;
|
||||
margin: 20px auto;
|
||||
padding: 5px;
|
||||
font-style: italic;
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
box-shadow: 0px 0px 2px rgba(0, 0, 0, 0.2); }
|
||||
|
||||
.reveal blockquote p:first-child, .reveal blockquote p:last-child {
|
||||
display: inline-block; }
|
||||
|
||||
.reveal q {
|
||||
font-style: italic; }
|
||||
|
||||
.reveal pre {
|
||||
display: block;
|
||||
position: relative;
|
||||
width: 90%;
|
||||
margin: 20px auto;
|
||||
text-align: left;
|
||||
font-size: 0.55em;
|
||||
font-family: monospace;
|
||||
line-height: 1.2em;
|
||||
word-wrap: break-word;
|
||||
box-shadow: 0px 0px 6px rgba(0, 0, 0, 0.3); }
|
||||
|
||||
.reveal code {
|
||||
font-family: monospace; }
|
||||
|
||||
.reveal pre code {
|
||||
display: block;
|
||||
padding: 5px;
|
||||
overflow: auto;
|
||||
max-height: 400px;
|
||||
word-wrap: normal;
|
||||
background: #3F3F3F;
|
||||
color: #DCDCDC; }
|
||||
|
||||
.reveal table {
|
||||
margin: auto;
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0; }
|
||||
|
||||
.reveal table th {
|
||||
font-weight: bold; }
|
||||
|
||||
.reveal table th, .reveal table td {
|
||||
/* text-align: left; */ /* hpl modification */
|
||||
padding: 0.2em 0.5em 0.2em 0.5em;
|
||||
border-bottom: 1px solid; }
|
||||
|
||||
.reveal table th[align="center"], .reveal table td[align="center"] {
|
||||
text-align: center; }
|
||||
|
||||
.reveal table th[align="right"], .reveal table td[align="right"] {
|
||||
text-align: right; }
|
||||
|
||||
.reveal table tr:last-child td {
|
||||
border-bottom: none; }
|
||||
|
||||
.reveal sup {
|
||||
vertical-align: super; }
|
||||
|
||||
.reveal sub {
|
||||
vertical-align: sub; }
|
||||
|
||||
.reveal small {
|
||||
display: inline-block;
|
||||
font-size: 0.6em;
|
||||
line-height: 1.2em;
|
||||
vertical-align: top; }
|
||||
|
||||
.reveal small * {
|
||||
vertical-align: top; }
|
||||
|
||||
/*********************************************
|
||||
* LINKS
|
||||
*********************************************/
|
||||
.reveal a {
|
||||
color: #2a76dd;
|
||||
text-decoration: none;
|
||||
-webkit-transition: color 0.15s ease;
|
||||
-moz-transition: color 0.15s ease;
|
||||
transition: color 0.15s ease; }
|
||||
|
||||
.reveal a:hover {
|
||||
color: #6ca2e8;
|
||||
text-shadow: none;
|
||||
border: none; }
|
||||
|
||||
.reveal .roll span:after {
|
||||
color: #fff;
|
||||
background: #1a54a1; }
|
||||
|
||||
/*********************************************
|
||||
* IMAGES
|
||||
*********************************************/
|
||||
.reveal section img {
|
||||
margin: 15px 0px;
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
border: 4px solid #222;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.15); }
|
||||
|
||||
.reveal a img {
|
||||
-webkit-transition: all 0.15s linear;
|
||||
-moz-transition: all 0.15s linear;
|
||||
transition: all 0.15s linear; }
|
||||
|
||||
.reveal a:hover img {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
border-color: #2a76dd;
|
||||
box-shadow: 0 0 20px rgba(0, 0, 0, 0.55); }
|
||||
|
||||
/*********************************************
|
||||
* NAVIGATION CONTROLS
|
||||
*********************************************/
|
||||
.reveal .controls div.navigate-left, .reveal .controls div.navigate-left.enabled {
|
||||
border-right-color: #2a76dd; }
|
||||
|
||||
.reveal .controls div.navigate-right, .reveal .controls div.navigate-right.enabled {
|
||||
border-left-color: #2a76dd; }
|
||||
|
||||
.reveal .controls div.navigate-up, .reveal .controls div.navigate-up.enabled {
|
||||
border-bottom-color: #2a76dd; }
|
||||
|
||||
.reveal .controls div.navigate-down, .reveal .controls div.navigate-down.enabled {
|
||||
border-top-color: #2a76dd; }
|
||||
|
||||
.reveal .controls div.navigate-left.enabled:hover {
|
||||
border-right-color: #6ca2e8; }
|
||||
|
||||
.reveal .controls div.navigate-right.enabled:hover {
|
||||
border-left-color: #6ca2e8; }
|
||||
|
||||
.reveal .controls div.navigate-up.enabled:hover {
|
||||
border-bottom-color: #6ca2e8; }
|
||||
|
||||
.reveal .controls div.navigate-down.enabled:hover {
|
||||
border-top-color: #6ca2e8; }
|
||||
|
||||
/*********************************************
|
||||
* PROGRESS BAR
|
||||
*********************************************/
|
||||
.reveal .progress {
|
||||
background: rgba(0, 0, 0, 0.2); }
|
||||
|
||||
.reveal .progress span {
|
||||
background: #2a76dd;
|
||||
-webkit-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
-moz-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985); }
|
||||
|
||||
/*********************************************
|
||||
* SLIDE NUMBER
|
||||
*********************************************/
|
||||
.reveal .slide-number {
|
||||
color: #2a76dd; }
|
||||
@@ -1,411 +0,0 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
||||
<title>reveal.js - The HTML Presentation Framework</title>
|
||||
|
||||
<meta name="description" content="A framework for easily creating beautiful presentations using HTML">
|
||||
<meta name="author" content="Hakim El Hattab">
|
||||
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
|
||||
|
||||
<link rel="stylesheet" href="css/reveal.css">
|
||||
<link rel="stylesheet" href="css/theme/black.css" id="theme">
|
||||
|
||||
<!-- Code syntax highlighting -->
|
||||
<link rel="stylesheet" href="lib/css/zenburn.css">
|
||||
|
||||
<!-- Printing and PDF exports -->
|
||||
<script>
|
||||
var link = document.createElement( 'link' );
|
||||
link.rel = 'stylesheet';
|
||||
link.type = 'text/css';
|
||||
link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css';
|
||||
document.getElementsByTagName( 'head' )[0].appendChild( link );
|
||||
</script>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="lib/js/html5shiv.js"></script>
|
||||
<![endif]-->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="reveal">
|
||||
|
||||
<!-- Any section element inside of this container is displayed as a slide -->
|
||||
<div class="slides">
|
||||
<section>
|
||||
<h1>Reveal.js</h1>
|
||||
<h3>The HTML Presentation Framework</h3>
|
||||
<p>
|
||||
<small>Created by <a href="http://hakim.se">Hakim El Hattab</a> / <a href="http://twitter.com/hakimel">@hakimel</a></small>
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2>Hello There</h2>
|
||||
<p>
|
||||
reveal.js enables you to create beautiful interactive slide decks using HTML. This presentation will show you examples of what it can do.
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<!-- Example of nested vertical slides -->
|
||||
<section>
|
||||
<section>
|
||||
<h2>Vertical Slides</h2>
|
||||
<p>Slides can be nested inside of each other.</p>
|
||||
<p>Use the <em>Space</em> key to navigate through all slides.</p>
|
||||
<br>
|
||||
<a href="#" class="navigate-down">
|
||||
<img width="178" height="238" data-src="https://s3.amazonaws.com/hakim-static/reveal-js/arrow.png" alt="Down arrow">
|
||||
</a>
|
||||
</section>
|
||||
<section>
|
||||
<h2>Basement Level 1</h2>
|
||||
<p>Nested slides are useful for adding additional detail underneath a high level horizontal slide.</p>
|
||||
</section>
|
||||
<section>
|
||||
<h2>Basement Level 2</h2>
|
||||
<p>That's it, time to go back up.</p>
|
||||
<br>
|
||||
<a href="#/2">
|
||||
<img width="178" height="238" data-src="https://s3.amazonaws.com/hakim-static/reveal-js/arrow.png" alt="Up arrow" style="transform: rotate(180deg); -webkit-transform: rotate(180deg);">
|
||||
</a>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2>Slides</h2>
|
||||
<p>
|
||||
Not a coder? Not a problem. There's a fully-featured visual editor for authoring these, try it out at <a href="http://slides.com" target="_blank">http://slides.com</a>.
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2>Point of View</h2>
|
||||
<p>
|
||||
Press <strong>ESC</strong> to enter the slide overview.
|
||||
</p>
|
||||
<p>
|
||||
Hold down alt and click on any element to zoom in on it using <a href="http://lab.hakim.se/zoom-js">zoom.js</a>. Alt + click anywhere to zoom back out.
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2>Touch Optimized</h2>
|
||||
<p>
|
||||
Presentations look great on touch devices, like mobile phones and tablets. Simply swipe through your slides.
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<section data-markdown>
|
||||
<script type="text/template">
|
||||
## Markdown support
|
||||
|
||||
Write content using inline or external Markdown.
|
||||
Instructions and more info available in the [readme](https://github.com/hakimel/reveal.js#markdown).
|
||||
|
||||
```
|
||||
<section data-markdown>
|
||||
## Markdown support
|
||||
|
||||
Write content using inline or external Markdown.
|
||||
Instructions and more info available in the [readme](https://github.com/hakimel/reveal.js#markdown).
|
||||
</section>
|
||||
```
|
||||
</script>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<section id="fragments">
|
||||
<h2>Fragments</h2>
|
||||
<p>Hit the next arrow...</p>
|
||||
<p class="fragment">... to step through ...</p>
|
||||
<p><span class="fragment">... a</span> <span class="fragment">fragmented</span> <span class="fragment">slide.</span></p>
|
||||
|
||||
<aside class="notes">
|
||||
This slide has fragments which are also stepped through in the notes window.
|
||||
</aside>
|
||||
</section>
|
||||
<section>
|
||||
<h2>Fragment Styles</h2>
|
||||
<p>There's different types of fragments, like:</p>
|
||||
<p class="fragment grow">grow</p>
|
||||
<p class="fragment shrink">shrink</p>
|
||||
<p class="fragment fade-out">fade-out</p>
|
||||
<p class="fragment current-visible">current-visible</p>
|
||||
<p class="fragment highlight-red">highlight-red</p>
|
||||
<p class="fragment highlight-blue">highlight-blue</p>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<section id="transitions">
|
||||
<h2>Transition Styles</h2>
|
||||
<p>
|
||||
You can select from different transitions, like: <br>
|
||||
<a href="?transition=none#/transitions">None</a> -
|
||||
<a href="?transition=fade#/transitions">Fade</a> -
|
||||
<a href="?transition=slide#/transitions">Slide</a> -
|
||||
<a href="?transition=convex#/transitions">Convex</a> -
|
||||
<a href="?transition=concave#/transitions">Concave</a> -
|
||||
<a href="?transition=zoom#/transitions">Zoom</a>
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<section id="themes">
|
||||
<h2>Themes</h2>
|
||||
<p>
|
||||
reveal.js comes with a few themes built in: <br>
|
||||
<!-- Hacks to swap themes after the page has loaded. Not flexible and only intended for the reveal.js demo deck. -->
|
||||
<a href="#" onclick="document.getElementById('theme').setAttribute('href','css/theme/black.css'); return false;">Black (default)</a> -
|
||||
<a href="#" onclick="document.getElementById('theme').setAttribute('href','css/theme/white.css'); return false;">White</a> -
|
||||
<a href="#" onclick="document.getElementById('theme').setAttribute('href','css/theme/league.css'); return false;">League</a> -
|
||||
<a href="#" onclick="document.getElementById('theme').setAttribute('href','css/theme/sky.css'); return false;">Sky</a> -
|
||||
<a href="#" onclick="document.getElementById('theme').setAttribute('href','css/theme/beige.css'); return false;">Beige</a> -
|
||||
<a href="#" onclick="document.getElementById('theme').setAttribute('href','css/theme/simple.css'); return false;">Simple</a> <br>
|
||||
<a href="#" onclick="document.getElementById('theme').setAttribute('href','css/theme/serif.css'); return false;">Serif</a> -
|
||||
<a href="#" onclick="document.getElementById('theme').setAttribute('href','css/theme/blood.css'); return false;">Blood</a> -
|
||||
<a href="#" onclick="document.getElementById('theme').setAttribute('href','css/theme/night.css'); return false;">Night</a> -
|
||||
<a href="#" onclick="document.getElementById('theme').setAttribute('href','css/theme/moon.css'); return false;">Moon</a> -
|
||||
<a href="#" onclick="document.getElementById('theme').setAttribute('href','css/theme/solarized.css'); return false;">Solarized</a>
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<section data-background="#dddddd">
|
||||
<h2>Slide Backgrounds</h2>
|
||||
<p>
|
||||
Set <code>data-background="#dddddd"</code> on a slide to change the background color. All CSS color formats are supported.
|
||||
</p>
|
||||
<a href="#" class="navigate-down">
|
||||
<img width="178" height="238" data-src="https://s3.amazonaws.com/hakim-static/reveal-js/arrow.png" alt="Down arrow">
|
||||
</a>
|
||||
</section>
|
||||
<section data-background="https://s3.amazonaws.com/hakim-static/reveal-js/image-placeholder.png">
|
||||
<h2>Image Backgrounds</h2>
|
||||
<pre><code><section data-background="image.png"></code></pre>
|
||||
</section>
|
||||
<section data-background="https://s3.amazonaws.com/hakim-static/reveal-js/image-placeholder.png" data-background-repeat="repeat" data-background-size="100px">
|
||||
<h2>Tiled Backgrounds</h2>
|
||||
<pre><code style="word-wrap: break-word;"><section data-background="image.png" data-background-repeat="repeat" data-background-size="100px"></code></pre>
|
||||
</section>
|
||||
<section data-background-video="https://s3.amazonaws.com/static.slid.es/site/homepage/v1/homepage-video-editor.mp4,https://s3.amazonaws.com/static.slid.es/site/homepage/v1/homepage-video-editor.webm" data-background-color="#000000">
|
||||
<div style="background-color: rgba(0, 0, 0, 0.9); color: #fff; padding: 20px;">
|
||||
<h2>Video Backgrounds</h2>
|
||||
<pre><code style="word-wrap: break-word;"><section data-background-video="video.mp4,video.webm"></code></pre>
|
||||
</div>
|
||||
</section>
|
||||
<section data-background="http://i.giphy.com/90F8aUepslB84.gif">
|
||||
<h2>... and GIFs!</h2>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<section data-transition="slide" data-background="#4d7e65" data-background-transition="zoom">
|
||||
<h2>Background Transitions</h2>
|
||||
<p>
|
||||
Different background transitions are available via the backgroundTransition option. This one's called "zoom".
|
||||
</p>
|
||||
<pre><code>Reveal.configure({ backgroundTransition: 'zoom' })</code></pre>
|
||||
</section>
|
||||
|
||||
<section data-transition="slide" data-background="#b5533c" data-background-transition="zoom">
|
||||
<h2>Background Transitions</h2>
|
||||
<p>
|
||||
You can override background transitions per-slide.
|
||||
</p>
|
||||
<pre><code style="word-wrap: break-word;"><section data-background-transition="zoom"></code></pre>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2>Pretty Code</h2>
|
||||
<pre><code data-trim contenteditable>
|
||||
function linkify( selector ) {
|
||||
if( supports3DTransforms ) {
|
||||
|
||||
var nodes = document.querySelectorAll( selector );
|
||||
|
||||
for( var i = 0, len = nodes.length; i < len; i++ ) {
|
||||
var node = nodes[i];
|
||||
|
||||
if( !node.className ) {
|
||||
node.className += ' roll';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
<p>Code syntax highlighting courtesy of <a href="http://softwaremaniacs.org/soft/highlight/en/description/">highlight.js</a>.</p>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2>Marvelous List</h2>
|
||||
<ul>
|
||||
<li>No order here</li>
|
||||
<li>Or here</li>
|
||||
<li>Or here</li>
|
||||
<li>Or here</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2>Fantastic Ordered List</h2>
|
||||
<ol>
|
||||
<li>One is smaller than...</li>
|
||||
<li>Two is smaller than...</li>
|
||||
<li>Three!</li>
|
||||
</ol>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2>Tabular Tables</h2>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Item</th>
|
||||
<th>Value</th>
|
||||
<th>Quantity</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Apples</td>
|
||||
<td>$1</td>
|
||||
<td>7</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Lemonade</td>
|
||||
<td>$2</td>
|
||||
<td>18</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Bread</td>
|
||||
<td>$3</td>
|
||||
<td>2</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2>Clever Quotes</h2>
|
||||
<p>
|
||||
These guys come in two forms, inline: <q cite="http://searchservervirtualization.techtarget.com/definition/Our-Favorite-Technology-Quotations">
|
||||
“The nice thing about standards is that there are so many to choose from”</q> and block:
|
||||
</p>
|
||||
<blockquote cite="http://searchservervirtualization.techtarget.com/definition/Our-Favorite-Technology-Quotations">
|
||||
“For years there has been a theory that millions of monkeys typing at random on millions of typewriters would
|
||||
reproduce the entire works of Shakespeare. The Internet has proven this theory to be untrue.”
|
||||
</blockquote>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2>Intergalactic Interconnections</h2>
|
||||
<p>
|
||||
You can link between slides internally,
|
||||
<a href="#/2/3">like this</a>.
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2>Speaker View</h2>
|
||||
<p>There's a <a href="https://github.com/hakimel/reveal.js#speaker-notes">speaker view</a>. It includes a timer, preview of the upcoming slide as well as your speaker notes.</p>
|
||||
<p>Press the <em>S</em> key to try it out.</p>
|
||||
|
||||
<aside class="notes">
|
||||
Oh hey, these are some notes. They'll be hidden in your presentation, but you can see them if you open the speaker notes window (hit 's' on your keyboard).
|
||||
</aside>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2>Export to PDF</h2>
|
||||
<p>Presentations can be <a href="https://github.com/hakimel/reveal.js#pdf-export">exported to PDF</a>, here's an example:</p>
|
||||
<iframe src="//www.slideshare.net/slideshow/embed_code/42840540" width="445" height="355" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" style="border:3px solid #666; margin-bottom:5px; max-width: 100%;" allowfullscreen> </iframe>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2>Global State</h2>
|
||||
<p>
|
||||
Set <code>data-state="something"</code> on a slide and <code>"something"</code>
|
||||
will be added as a class to the document element when the slide is open. This lets you
|
||||
apply broader style changes, like switching the page background.
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<section data-state="customevent">
|
||||
<h2>State Events</h2>
|
||||
<p>
|
||||
Additionally custom events can be triggered on a per slide basis by binding to the <code>data-state</code> name.
|
||||
</p>
|
||||
<pre><code class="javascript" data-trim contenteditable style="font-size: 18px;">
|
||||
Reveal.addEventListener( 'customevent', function() {
|
||||
console.log( '"customevent" has fired' );
|
||||
} );
|
||||
</code></pre>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2>Take a Moment</h2>
|
||||
<p>
|
||||
Press B or . on your keyboard to pause the presentation. This is helpful when you're on stage and want to take distracting slides off the screen.
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2>Much more</h2>
|
||||
<ul>
|
||||
<li>Right-to-left support</li>
|
||||
<li><a href="https://github.com/hakimel/reveal.js#api">Extensive JavaScript API</a></li>
|
||||
<li><a href="https://github.com/hakimel/reveal.js#auto-sliding">Auto-progression</a></li>
|
||||
<li><a href="https://github.com/hakimel/reveal.js#parallax-background">Parallax backgrounds</a></li>
|
||||
<li><a href="https://github.com/hakimel/reveal.js#keyboard-bindings">Custom keyboard bindings</a></li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<section style="text-align: left;">
|
||||
<h1>THE END</h1>
|
||||
<p>
|
||||
- <a href="http://slides.com">Try the online editor</a> <br>
|
||||
- <a href="https://github.com/hakimel/reveal.js">Source code & documentation</a>
|
||||
</p>
|
||||
</section>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script src="lib/js/head.min.js"></script>
|
||||
<script src="js/reveal.js"></script>
|
||||
|
||||
<script>
|
||||
|
||||
// Full list of configuration options available at:
|
||||
// https://github.com/hakimel/reveal.js#configuration
|
||||
Reveal.initialize({
|
||||
controls: true,
|
||||
progress: true,
|
||||
history: true,
|
||||
center: true,
|
||||
|
||||
transition: 'slide', // none/fade/slide/convex/concave/zoom
|
||||
|
||||
// Optional reveal.js plugins
|
||||
dependencies: [
|
||||
{ src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } },
|
||||
{ src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
|
||||
{ src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
|
||||
{ src: 'plugin/highlight/highlight.js', async: true, condition: function() { return !!document.querySelector( 'pre code' ); }, callback: function() { hljs.initHighlightingOnLoad(); } },
|
||||
{ src: 'plugin/zoom-js/zoom.js', async: true },
|
||||
{ src: 'plugin/notes/notes.js', async: true }
|
||||
]
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,117 +0,0 @@
|
||||
/*
|
||||
|
||||
Zenburn style from voldmar.ru (c) Vladimir Epifanov <voldmar@voldmar.ru>
|
||||
based on dark.css by Ivan Sagalaev
|
||||
|
||||
*/
|
||||
|
||||
.hljs {
|
||||
display: block; padding: 0.5em;
|
||||
background: #3F3F3F;
|
||||
color: #DCDCDC;
|
||||
}
|
||||
|
||||
.hljs-keyword,
|
||||
.hljs-tag,
|
||||
.css .hljs-class,
|
||||
.css .hljs-id,
|
||||
.lisp .hljs-title,
|
||||
.nginx .hljs-title,
|
||||
.hljs-request,
|
||||
.hljs-status,
|
||||
.clojure .hljs-attribute {
|
||||
color: #E3CEAB;
|
||||
}
|
||||
|
||||
.django .hljs-template_tag,
|
||||
.django .hljs-variable,
|
||||
.django .hljs-filter .hljs-argument {
|
||||
color: #DCDCDC;
|
||||
}
|
||||
|
||||
.hljs-number,
|
||||
.hljs-date {
|
||||
color: #8CD0D3;
|
||||
}
|
||||
|
||||
.dos .hljs-envvar,
|
||||
.dos .hljs-stream,
|
||||
.hljs-variable,
|
||||
.apache .hljs-sqbracket {
|
||||
color: #EFDCBC;
|
||||
}
|
||||
|
||||
.dos .hljs-flow,
|
||||
.diff .hljs-change,
|
||||
.python .exception,
|
||||
.python .hljs-built_in,
|
||||
.hljs-literal,
|
||||
.tex .hljs-special {
|
||||
color: #EFEFAF;
|
||||
}
|
||||
|
||||
.diff .hljs-chunk,
|
||||
.hljs-subst {
|
||||
color: #8F8F8F;
|
||||
}
|
||||
|
||||
.dos .hljs-keyword,
|
||||
.python .hljs-decorator,
|
||||
.hljs-title,
|
||||
.haskell .hljs-type,
|
||||
.diff .hljs-header,
|
||||
.ruby .hljs-class .hljs-parent,
|
||||
.apache .hljs-tag,
|
||||
.nginx .hljs-built_in,
|
||||
.tex .hljs-command,
|
||||
.hljs-prompt {
|
||||
color: #efef8f;
|
||||
}
|
||||
|
||||
.dos .hljs-winutils,
|
||||
.ruby .hljs-symbol,
|
||||
.ruby .hljs-symbol .hljs-string,
|
||||
.ruby .hljs-string {
|
||||
color: #DCA3A3;
|
||||
}
|
||||
|
||||
.diff .hljs-deletion,
|
||||
.hljs-string,
|
||||
.hljs-tag .hljs-value,
|
||||
.hljs-preprocessor,
|
||||
.hljs-pragma,
|
||||
.hljs-built_in,
|
||||
.sql .hljs-aggregate,
|
||||
.hljs-javadoc,
|
||||
.smalltalk .hljs-class,
|
||||
.smalltalk .hljs-localvars,
|
||||
.smalltalk .hljs-array,
|
||||
.css .hljs-rules .hljs-value,
|
||||
.hljs-attr_selector,
|
||||
.hljs-pseudo,
|
||||
.apache .hljs-cbracket,
|
||||
.tex .hljs-formula,
|
||||
.coffeescript .hljs-attribute {
|
||||
color: #CC9393;
|
||||
}
|
||||
|
||||
.hljs-shebang,
|
||||
.diff .hljs-addition,
|
||||
.hljs-comment,
|
||||
.java .hljs-annotation,
|
||||
.hljs-template_comment,
|
||||
.hljs-pi,
|
||||
.hljs-doctype {
|
||||
color: #7F9F7F;
|
||||
}
|
||||
|
||||
.coffeescript .javascript,
|
||||
.javascript .xml,
|
||||
.tex .hljs-formula,
|
||||
.xml .javascript,
|
||||
.xml .vbscript,
|
||||
.xml .css,
|
||||
.xml .hljs-cdata {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
SIL Open Font License (OFL)
|
||||
http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=OFL
|
||||
@@ -1,10 +0,0 @@
|
||||
@font-face {
|
||||
font-family: 'League Gothic';
|
||||
src: url('league-gothic.eot');
|
||||
src: url('league-gothic.eot?#iefix') format('embedded-opentype'),
|
||||
url('league-gothic.woff') format('woff'),
|
||||
url('league-gothic.ttf') format('truetype');
|
||||
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
SIL Open Font License
|
||||
|
||||
Copyright 2010, 2012 Adobe Systems Incorporated (http://www.adobe.com/), with Reserved Font Name ‘Source’. All Rights Reserved. Source is a trademark of Adobe Systems Incorporated in the United States and/or other countries.
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL
|
||||
|
||||
—————————————————————————————-
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
—————————————————————————————-
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide development of collaborative font projects, to support the font creation efforts of academic and linguistic communities, and to provide a free and open framework in which fonts may be shared and improved in partnership with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and redistributed freely as long as they are not sold by themselves. The fonts, including any derivative works, can be bundled, embedded, redistributed and/or sold with any software provided that any reserved names are not used by derivative works. The fonts and derivatives, however, cannot be released under any other type of license. The requirement for fonts to remain under this license does not apply to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
“Font Software” refers to the set of files released by the Copyright Holder(s) under this license and clearly marked as such. This may include source files, build scripts and documentation.
|
||||
|
||||
“Reserved Font Name” refers to any names specified as such after the copyright statement(s).
|
||||
|
||||
“Original Version” refers to the collection of Font Software components as distributed by the Copyright Holder(s).
|
||||
|
||||
“Modified Version” refers to any derivative made by adding to, deleting, or substituting—in part or in whole—any of the components of the Original Version, by changing formats or by porting the Font Software to a new environment.
|
||||
|
||||
“Author” refers to any designer, engineer, programmer, technical writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of the Font Software, to use, study, copy, merge, embed, modify, redistribute, and sell modified and unmodified copies of the Font Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components, in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled, redistributed and/or sold with any software, provided that each copy contains the above copyright notice and this license. These can be included either as stand-alone text files, human-readable headers or in the appropriate machine-readable metadata fields within text or binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font Name(s) unless explicit written permission is granted by the corresponding Copyright Holder. This restriction only applies to the primary font name as presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font Software shall not be used to promote, endorse or advertise any Modified Version, except to acknowledge the contribution(s) of the Copyright Holder(s) and the Author(s) or with their explicit written permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole, must be distributed entirely under this license, and must not be distributed under any other license. The requirement for fonts to remain under this license does not apply to any document created using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
@@ -1,39 +0,0 @@
|
||||
@font-face {
|
||||
font-family: 'Source Sans Pro';
|
||||
src: url('source-sans-pro-regular.eot');
|
||||
src: url('source-sans-pro-regular.eot?#iefix') format('embedded-opentype'),
|
||||
url('source-sans-pro-regular.woff') format('woff'),
|
||||
url('source-sans-pro-regular.ttf') format('truetype');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Source Sans Pro';
|
||||
src: url('source-sans-pro-italic.eot');
|
||||
src: url('source-sans-pro-italic.eot?#iefix') format('embedded-opentype'),
|
||||
url('source-sans-pro-italic.woff') format('woff'),
|
||||
url('source-sans-pro-italic.ttf') format('truetype');
|
||||
font-weight: normal;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Source Sans Pro';
|
||||
src: url('source-sans-pro-semibold.eot');
|
||||
src: url('source-sans-pro-semibold.eot?#iefix') format('embedded-opentype'),
|
||||
url('source-sans-pro-semibold.woff') format('woff'),
|
||||
url('source-sans-pro-semibold.ttf') format('truetype');
|
||||
font-weight: 600;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Source Sans Pro';
|
||||
src: url('source-sans-pro-semibolditalic.eot');
|
||||
src: url('source-sans-pro-semibolditalic.eot?#iefix') format('embedded-opentype'),
|
||||
url('source-sans-pro-semibolditalic.woff') format('woff'),
|
||||
url('source-sans-pro-semibolditalic.ttf') format('truetype');
|
||||
font-weight: 600;
|
||||
font-style: italic;
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
/*! @source http://purl.eligrey.com/github/classList.js/blob/master/classList.js*/
|
||||
if(typeof document!=="undefined"&&!("classList" in document.createElement("a"))){(function(j){var a="classList",f="prototype",m=(j.HTMLElement||j.Element)[f],b=Object,k=String[f].trim||function(){return this.replace(/^\s+|\s+$/g,"")},c=Array[f].indexOf||function(q){var p=0,o=this.length;for(;p<o;p++){if(p in this&&this[p]===q){return p}}return -1},n=function(o,p){this.name=o;this.code=DOMException[o];this.message=p},g=function(p,o){if(o===""){throw new n("SYNTAX_ERR","An invalid or illegal string was specified")}if(/\s/.test(o)){throw new n("INVALID_CHARACTER_ERR","String contains an invalid character")}return c.call(p,o)},d=function(s){var r=k.call(s.className),q=r?r.split(/\s+/):[],p=0,o=q.length;for(;p<o;p++){this.push(q[p])}this._updateClassName=function(){s.className=this.toString()}},e=d[f]=[],i=function(){return new d(this)};n[f]=Error[f];e.item=function(o){return this[o]||null};e.contains=function(o){o+="";return g(this,o)!==-1};e.add=function(o){o+="";if(g(this,o)===-1){this.push(o);this._updateClassName()}};e.remove=function(p){p+="";var o=g(this,p);if(o!==-1){this.splice(o,1);this._updateClassName()}};e.toggle=function(o){o+="";if(g(this,o)===-1){this.add(o)}else{this.remove(o)}};e.toString=function(){return this.join(" ")};if(b.defineProperty){var l={get:i,enumerable:true,configurable:true};try{b.defineProperty(m,a,l)}catch(h){if(h.number===-2146823252){l.enumerable=false;b.defineProperty(m,a,l)}}}else{if(b[f].__defineGetter__){m.__defineGetter__(a,i)}}}(self))};
|
||||
@@ -1,8 +0,0 @@
|
||||
/**
|
||||
Head JS The only script in your <HEAD>
|
||||
Copyright Tero Piirainen (tipiirai)
|
||||
License MIT / http://bit.ly/mit-license
|
||||
Version 0.96
|
||||
|
||||
http://headjs.com
|
||||
*/(function(a){function z(){d||(d=!0,s(e,function(a){p(a)}))}function y(c,d){var e=a.createElement("script");e.type="text/"+(c.type||"javascript"),e.src=c.src||c,e.async=!1,e.onreadystatechange=e.onload=function(){var a=e.readyState;!d.done&&(!a||/loaded|complete/.test(a))&&(d.done=!0,d())},(a.body||b).appendChild(e)}function x(a,b){if(a.state==o)return b&&b();if(a.state==n)return k.ready(a.name,b);if(a.state==m)return a.onpreload.push(function(){x(a,b)});a.state=n,y(a.url,function(){a.state=o,b&&b(),s(g[a.name],function(a){p(a)}),u()&&d&&s(g.ALL,function(a){p(a)})})}function w(a,b){a.state===undefined&&(a.state=m,a.onpreload=[],y({src:a.url,type:"cache"},function(){v(a)}))}function v(a){a.state=l,s(a.onpreload,function(a){a.call()})}function u(a){a=a||h;var b;for(var c in a){if(a.hasOwnProperty(c)&&a[c].state!=o)return!1;b=!0}return b}function t(a){return Object.prototype.toString.call(a)=="[object Function]"}function s(a,b){if(!!a){typeof a=="object"&&(a=[].slice.call(a));for(var c=0;c<a.length;c++)b.call(a,a[c],c)}}function r(a){var b;if(typeof a=="object")for(var c in a)a[c]&&(b={name:c,url:a[c]});else b={name:q(a),url:a};var d=h[b.name];if(d&&d.url===b.url)return d;h[b.name]=b;return b}function q(a){var b=a.split("/"),c=b[b.length-1],d=c.indexOf("?");return d!=-1?c.substring(0,d):c}function p(a){a._done||(a(),a._done=1)}var b=a.documentElement,c,d,e=[],f=[],g={},h={},i=a.createElement("script").async===!0||"MozAppearance"in a.documentElement.style||window.opera,j=window.head_conf&&head_conf.head||"head",k=window[j]=window[j]||function(){k.ready.apply(null,arguments)},l=1,m=2,n=3,o=4;i?k.js=function(){var a=arguments,b=a[a.length-1],c={};t(b)||(b=null),s(a,function(d,e){d!=b&&(d=r(d),c[d.name]=d,x(d,b&&e==a.length-2?function(){u(c)&&p(b)}:null))});return k}:k.js=function(){var a=arguments,b=[].slice.call(a,1),d=b[0];if(!c){f.push(function(){k.js.apply(null,a)});return k}d?(s(b,function(a){t(a)||w(r(a))}),x(r(a[0]),t(d)?d:function(){k.js.apply(null,b)})):x(r(a[0]));return k},k.ready=function(b,c){if(b==a){d?p(c):e.push(c);return k}t(b)&&(c=b,b="ALL");if(typeof b!="string"||!t(c))return k;var f=h[b];if(f&&f.state==o||b=="ALL"&&u()&&d){p(c);return k}var i=g[b];i?i.push(c):i=g[b]=[c];return k},k.ready(a,function(){u()&&s(g.ALL,function(a){p(a)}),k.feature&&k.feature("domloaded",!0)});if(window.addEventListener)a.addEventListener("DOMContentLoaded",z,!1),window.addEventListener("load",z,!1);else if(window.attachEvent){a.attachEvent("onreadystatechange",function(){a.readyState==="complete"&&z()});var A=1;try{A=window.frameElement}catch(B){}!A&&b.doScroll&&function(){try{b.doScroll("left"),z()}catch(a){setTimeout(arguments.callee,1);return}}(),window.attachEvent("onload",z)}!a.readyState&&a.addEventListener&&(a.readyState="loading",a.addEventListener("DOMContentLoaded",handler=function(){a.removeEventListener("DOMContentLoaded",handler,!1),a.readyState="complete"},!1)),setTimeout(function(){c=!0,s(f,function(a){a()})},300)})(document)
|
||||
@@ -1,7 +0,0 @@
|
||||
document.createElement('header');
|
||||
document.createElement('nav');
|
||||
document.createElement('section');
|
||||
document.createElement('article');
|
||||
document.createElement('aside');
|
||||
document.createElement('footer');
|
||||
document.createElement('hgroup');
|
||||
@@ -1,45 +0,0 @@
|
||||
{
|
||||
"name": "reveal.js",
|
||||
"version": "3.1.0",
|
||||
"description": "The HTML Presentation Framework",
|
||||
"homepage": "http://lab.hakim.se/reveal-js",
|
||||
"subdomain": "revealjs",
|
||||
"main": "js/reveal.js",
|
||||
"scripts": {
|
||||
"test": "grunt test",
|
||||
"start": "grunt serve"
|
||||
},
|
||||
"author": {
|
||||
"name": "Hakim El Hattab",
|
||||
"email": "hakim.elhattab@gmail.com",
|
||||
"web": "http://hakim.se"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/hakimel/reveal.js.git"
|
||||
},
|
||||
"engines": {
|
||||
"node": "~0.10.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"underscore": "~1.5.1",
|
||||
"express": "~2.5.9",
|
||||
"mustache": "~0.7.2",
|
||||
"socket.io": "~0.9.16"
|
||||
},
|
||||
"devDependencies": {
|
||||
"grunt-contrib-qunit": "~0.5.2",
|
||||
"grunt-contrib-jshint": "~0.6.4",
|
||||
"grunt-contrib-cssmin": "~0.12.2",
|
||||
"grunt-contrib-uglify": "~0.2.4",
|
||||
"grunt-contrib-watch": "~0.5.3",
|
||||
"grunt-sass": "~0.14.0",
|
||||
"grunt-contrib-connect": "~0.8.0",
|
||||
"grunt-autoprefixer": "~1.0.1",
|
||||
"grunt-zip": "~0.7.0",
|
||||
"grunt": "~0.4.0",
|
||||
"node-sass": "~0.9.3"
|
||||
},
|
||||
|
||||
"license": "MIT"
|
||||
}
|
||||
@@ -1,129 +0,0 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
||||
<title>reveal.js - Markdown Demo</title>
|
||||
|
||||
<link rel="stylesheet" href="../../css/reveal.css">
|
||||
<link rel="stylesheet" href="../../css/theme/white.css" id="theme">
|
||||
|
||||
<link rel="stylesheet" href="../../lib/css/zenburn.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="reveal">
|
||||
|
||||
<div class="slides">
|
||||
|
||||
<!-- Use external markdown resource, separate slides by three newlines; vertical slides by two newlines -->
|
||||
<section data-markdown="example.md" data-separator="^\n\n\n" data-separator-vertical="^\n\n"></section>
|
||||
|
||||
<!-- Slides are separated by three dashes (quick 'n dirty regular expression) -->
|
||||
<section data-markdown data-separator="---">
|
||||
<script type="text/template">
|
||||
## Demo 1
|
||||
Slide 1
|
||||
---
|
||||
## Demo 1
|
||||
Slide 2
|
||||
---
|
||||
## Demo 1
|
||||
Slide 3
|
||||
</script>
|
||||
</section>
|
||||
|
||||
<!-- Slides are separated by newline + three dashes + newline, vertical slides identical but two dashes -->
|
||||
<section data-markdown data-separator="^\n---\n$" data-separator-vertical="^\n--\n$">
|
||||
<script type="text/template">
|
||||
## Demo 2
|
||||
Slide 1.1
|
||||
|
||||
--
|
||||
|
||||
## Demo 2
|
||||
Slide 1.2
|
||||
|
||||
---
|
||||
|
||||
## Demo 2
|
||||
Slide 2
|
||||
</script>
|
||||
</section>
|
||||
|
||||
<!-- No "extra" slides, since there are no separators defined (so they'll become horizontal rulers) -->
|
||||
<section data-markdown>
|
||||
<script type="text/template">
|
||||
A
|
||||
|
||||
---
|
||||
|
||||
B
|
||||
|
||||
---
|
||||
|
||||
C
|
||||
</script>
|
||||
</section>
|
||||
|
||||
<!-- Slide attributes -->
|
||||
<section data-markdown>
|
||||
<script type="text/template">
|
||||
<!-- .slide: data-background="#000000" -->
|
||||
## Slide attributes
|
||||
</script>
|
||||
</section>
|
||||
|
||||
<!-- Element attributes -->
|
||||
<section data-markdown>
|
||||
<script type="text/template">
|
||||
## Element attributes
|
||||
- Item 1 <!-- .element: class="fragment" data-fragment-index="2" -->
|
||||
- Item 2 <!-- .element: class="fragment" data-fragment-index="1" -->
|
||||
</script>
|
||||
</section>
|
||||
|
||||
<!-- Code -->
|
||||
<section data-markdown>
|
||||
<script type="text/template">
|
||||
```php
|
||||
public function foo()
|
||||
{
|
||||
$foo = array(
|
||||
'bar' => 'bar'
|
||||
)
|
||||
}
|
||||
```
|
||||
</script>
|
||||
</section>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="../../lib/js/head.min.js"></script>
|
||||
<script src="../../js/reveal.js"></script>
|
||||
|
||||
<script>
|
||||
|
||||
Reveal.initialize({
|
||||
controls: true,
|
||||
progress: true,
|
||||
history: true,
|
||||
center: true,
|
||||
|
||||
// Optional libraries used to extend on reveal.js
|
||||
dependencies: [
|
||||
{ src: '../../lib/js/classList.js', condition: function() { return !document.body.classList; } },
|
||||
{ src: 'marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
|
||||
{ src: 'markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
|
||||
{ src: '../highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
|
||||
{ src: '../notes/notes.js' }
|
||||
]
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,31 +0,0 @@
|
||||
# Markdown Demo
|
||||
|
||||
|
||||
|
||||
## External 1.1
|
||||
|
||||
Content 1.1
|
||||
|
||||
Note: This will only appear in the speaker notes window.
|
||||
|
||||
|
||||
## External 1.2
|
||||
|
||||
Content 1.2
|
||||
|
||||
|
||||
|
||||
## External 2
|
||||
|
||||
Content 2.1
|
||||
|
||||
|
||||
|
||||
## External 3.1
|
||||
|
||||
Content 3.1
|
||||
|
||||
|
||||
## External 3.2
|
||||
|
||||
Content 3.2
|
||||
@@ -1,393 +0,0 @@
|
||||
/**
|
||||
* The reveal.js markdown plugin. Handles parsing of
|
||||
* markdown inside of presentations as well as loading
|
||||
* of external markdown documents.
|
||||
*/
|
||||
(function( root, factory ) {
|
||||
if( typeof exports === 'object' ) {
|
||||
module.exports = factory( require( './marked' ) );
|
||||
}
|
||||
else {
|
||||
// Browser globals (root is window)
|
||||
root.RevealMarkdown = factory( root.marked );
|
||||
root.RevealMarkdown.initialize();
|
||||
}
|
||||
}( this, function( marked ) {
|
||||
|
||||
if( typeof marked === 'undefined' ) {
|
||||
throw 'The reveal.js Markdown plugin requires marked to be loaded';
|
||||
}
|
||||
|
||||
if( typeof hljs !== 'undefined' ) {
|
||||
marked.setOptions({
|
||||
highlight: function( lang, code ) {
|
||||
return hljs.highlightAuto( lang, code ).value;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var DEFAULT_SLIDE_SEPARATOR = '^\r?\n---\r?\n$',
|
||||
DEFAULT_NOTES_SEPARATOR = 'note:',
|
||||
DEFAULT_ELEMENT_ATTRIBUTES_SEPARATOR = '\\\.element\\\s*?(.+?)$',
|
||||
DEFAULT_SLIDE_ATTRIBUTES_SEPARATOR = '\\\.slide:\\\s*?(\\\S.+?)$';
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves the markdown contents of a slide section
|
||||
* element. Normalizes leading tabs/whitespace.
|
||||
*/
|
||||
function getMarkdownFromSlide( section ) {
|
||||
|
||||
var template = section.querySelector( 'script' );
|
||||
|
||||
// strip leading whitespace so it isn't evaluated as code
|
||||
var text = ( template || section ).textContent;
|
||||
|
||||
var leadingWs = text.match( /^\n?(\s*)/ )[1].length,
|
||||
leadingTabs = text.match( /^\n?(\t*)/ )[1].length;
|
||||
|
||||
if( leadingTabs > 0 ) {
|
||||
text = text.replace( new RegExp('\\n?\\t{' + leadingTabs + '}','g'), '\n' );
|
||||
}
|
||||
else if( leadingWs > 1 ) {
|
||||
text = text.replace( new RegExp('\\n? {' + leadingWs + '}', 'g'), '\n' );
|
||||
}
|
||||
|
||||
return text;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a markdown slide section element, this will
|
||||
* return all arguments that aren't related to markdown
|
||||
* parsing. Used to forward any other user-defined arguments
|
||||
* to the output markdown slide.
|
||||
*/
|
||||
function getForwardedAttributes( section ) {
|
||||
|
||||
var attributes = section.attributes;
|
||||
var result = [];
|
||||
|
||||
for( var i = 0, len = attributes.length; i < len; i++ ) {
|
||||
var name = attributes[i].name,
|
||||
value = attributes[i].value;
|
||||
|
||||
// disregard attributes that are used for markdown loading/parsing
|
||||
if( /data\-(markdown|separator|vertical|notes)/gi.test( name ) ) continue;
|
||||
|
||||
if( value ) {
|
||||
result.push( name + '="' + value + '"' );
|
||||
}
|
||||
else {
|
||||
result.push( name );
|
||||
}
|
||||
}
|
||||
|
||||
return result.join( ' ' );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Inspects the given options and fills out default
|
||||
* values for what's not defined.
|
||||
*/
|
||||
function getSlidifyOptions( options ) {
|
||||
|
||||
options = options || {};
|
||||
options.separator = options.separator || DEFAULT_SLIDE_SEPARATOR;
|
||||
options.notesSeparator = options.notesSeparator || DEFAULT_NOTES_SEPARATOR;
|
||||
options.attributes = options.attributes || '';
|
||||
|
||||
return options;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for constructing a markdown slide.
|
||||
*/
|
||||
function createMarkdownSlide( content, options ) {
|
||||
|
||||
options = getSlidifyOptions( options );
|
||||
|
||||
var notesMatch = content.split( new RegExp( options.notesSeparator, 'mgi' ) );
|
||||
|
||||
if( notesMatch.length === 2 ) {
|
||||
content = notesMatch[0] + '<aside class="notes" data-markdown>' + notesMatch[1].trim() + '</aside>';
|
||||
}
|
||||
|
||||
return '<script type="text/template">' + content + '</script>';
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a data string into multiple slides based
|
||||
* on the passed in separator arguments.
|
||||
*/
|
||||
function slidify( markdown, options ) {
|
||||
|
||||
options = getSlidifyOptions( options );
|
||||
|
||||
var separatorRegex = new RegExp( options.separator + ( options.verticalSeparator ? '|' + options.verticalSeparator : '' ), 'mg' ),
|
||||
horizontalSeparatorRegex = new RegExp( options.separator );
|
||||
|
||||
var matches,
|
||||
lastIndex = 0,
|
||||
isHorizontal,
|
||||
wasHorizontal = true,
|
||||
content,
|
||||
sectionStack = [];
|
||||
|
||||
// iterate until all blocks between separators are stacked up
|
||||
while( matches = separatorRegex.exec( markdown ) ) {
|
||||
notes = null;
|
||||
|
||||
// determine direction (horizontal by default)
|
||||
isHorizontal = horizontalSeparatorRegex.test( matches[0] );
|
||||
|
||||
if( !isHorizontal && wasHorizontal ) {
|
||||
// create vertical stack
|
||||
sectionStack.push( [] );
|
||||
}
|
||||
|
||||
// pluck slide content from markdown input
|
||||
content = markdown.substring( lastIndex, matches.index );
|
||||
|
||||
if( isHorizontal && wasHorizontal ) {
|
||||
// add to horizontal stack
|
||||
sectionStack.push( content );
|
||||
}
|
||||
else {
|
||||
// add to vertical stack
|
||||
sectionStack[sectionStack.length-1].push( content );
|
||||
}
|
||||
|
||||
lastIndex = separatorRegex.lastIndex;
|
||||
wasHorizontal = isHorizontal;
|
||||
}
|
||||
|
||||
// add the remaining slide
|
||||
( wasHorizontal ? sectionStack : sectionStack[sectionStack.length-1] ).push( markdown.substring( lastIndex ) );
|
||||
|
||||
var markdownSections = '';
|
||||
|
||||
// flatten the hierarchical stack, and insert <section data-markdown> tags
|
||||
for( var i = 0, len = sectionStack.length; i < len; i++ ) {
|
||||
// vertical
|
||||
if( sectionStack[i] instanceof Array ) {
|
||||
markdownSections += '<section '+ options.attributes +'>';
|
||||
|
||||
sectionStack[i].forEach( function( child ) {
|
||||
markdownSections += '<section data-markdown>' + createMarkdownSlide( child, options ) + '</section>';
|
||||
} );
|
||||
|
||||
markdownSections += '</section>';
|
||||
}
|
||||
else {
|
||||
markdownSections += '<section '+ options.attributes +' data-markdown>' + createMarkdownSlide( sectionStack[i], options ) + '</section>';
|
||||
}
|
||||
}
|
||||
|
||||
return markdownSections;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses any current data-markdown slides, splits
|
||||
* multi-slide markdown into separate sections and
|
||||
* handles loading of external markdown.
|
||||
*/
|
||||
function processSlides() {
|
||||
|
||||
var sections = document.querySelectorAll( '[data-markdown]'),
|
||||
section;
|
||||
|
||||
for( var i = 0, len = sections.length; i < len; i++ ) {
|
||||
|
||||
section = sections[i];
|
||||
|
||||
if( section.getAttribute( 'data-markdown' ).length ) {
|
||||
|
||||
var xhr = new XMLHttpRequest(),
|
||||
url = section.getAttribute( 'data-markdown' );
|
||||
|
||||
datacharset = section.getAttribute( 'data-charset' );
|
||||
|
||||
// see https://developer.mozilla.org/en-US/docs/Web/API/element.getAttribute#Notes
|
||||
if( datacharset != null && datacharset != '' ) {
|
||||
xhr.overrideMimeType( 'text/html; charset=' + datacharset );
|
||||
}
|
||||
|
||||
xhr.onreadystatechange = function() {
|
||||
if( xhr.readyState === 4 ) {
|
||||
// file protocol yields status code 0 (useful for local debug, mobile applications etc.)
|
||||
if ( ( xhr.status >= 200 && xhr.status < 300 ) || xhr.status === 0 ) {
|
||||
|
||||
section.outerHTML = slidify( xhr.responseText, {
|
||||
separator: section.getAttribute( 'data-separator' ),
|
||||
verticalSeparator: section.getAttribute( 'data-separator-vertical' ),
|
||||
notesSeparator: section.getAttribute( 'data-separator-notes' ),
|
||||
attributes: getForwardedAttributes( section )
|
||||
});
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
section.outerHTML = '<section data-state="alert">' +
|
||||
'ERROR: The attempt to fetch ' + url + ' failed with HTTP status ' + xhr.status + '.' +
|
||||
'Check your browser\'s JavaScript console for more details.' +
|
||||
'<p>Remember that you need to serve the presentation HTML from a HTTP server.</p>' +
|
||||
'</section>';
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
xhr.open( 'GET', url, false );
|
||||
|
||||
try {
|
||||
xhr.send();
|
||||
}
|
||||
catch ( e ) {
|
||||
alert( 'Failed to get the Markdown file ' + url + '. Make sure that the presentation and the file are served by a HTTP server and the file can be found there. ' + e );
|
||||
}
|
||||
|
||||
}
|
||||
else if( section.getAttribute( 'data-separator' ) || section.getAttribute( 'data-separator-vertical' ) || section.getAttribute( 'data-separator-notes' ) ) {
|
||||
|
||||
section.outerHTML = slidify( getMarkdownFromSlide( section ), {
|
||||
separator: section.getAttribute( 'data-separator' ),
|
||||
verticalSeparator: section.getAttribute( 'data-separator-vertical' ),
|
||||
notesSeparator: section.getAttribute( 'data-separator-notes' ),
|
||||
attributes: getForwardedAttributes( section )
|
||||
});
|
||||
|
||||
}
|
||||
else {
|
||||
section.innerHTML = createMarkdownSlide( getMarkdownFromSlide( section ) );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a node value has the attributes pattern.
|
||||
* If yes, extract it and add that value as one or several attributes
|
||||
* the the terget element.
|
||||
*
|
||||
* You need Cache Killer on Chrome to see the effect on any FOM transformation
|
||||
* directly on refresh (F5)
|
||||
* http://stackoverflow.com/questions/5690269/disabling-chrome-cache-for-website-development/7000899#answer-11786277
|
||||
*/
|
||||
function addAttributeInElement( node, elementTarget, separator ) {
|
||||
|
||||
var mardownClassesInElementsRegex = new RegExp( separator, 'mg' );
|
||||
var mardownClassRegex = new RegExp( "([^\"= ]+?)=\"([^\"=]+?)\"", 'mg' );
|
||||
var nodeValue = node.nodeValue;
|
||||
if( matches = mardownClassesInElementsRegex.exec( nodeValue ) ) {
|
||||
|
||||
var classes = matches[1];
|
||||
nodeValue = nodeValue.substring( 0, matches.index ) + nodeValue.substring( mardownClassesInElementsRegex.lastIndex );
|
||||
node.nodeValue = nodeValue;
|
||||
while( matchesClass = mardownClassRegex.exec( classes ) ) {
|
||||
elementTarget.setAttribute( matchesClass[1], matchesClass[2] );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add attributes to the parent element of a text node,
|
||||
* or the element of an attribute node.
|
||||
*/
|
||||
function addAttributes( section, element, previousElement, separatorElementAttributes, separatorSectionAttributes ) {
|
||||
|
||||
if ( element != null && element.childNodes != undefined && element.childNodes.length > 0 ) {
|
||||
previousParentElement = element;
|
||||
for( var i = 0; i < element.childNodes.length; i++ ) {
|
||||
childElement = element.childNodes[i];
|
||||
if ( i > 0 ) {
|
||||
j = i - 1;
|
||||
while ( j >= 0 ) {
|
||||
aPreviousChildElement = element.childNodes[j];
|
||||
if ( typeof aPreviousChildElement.setAttribute == 'function' && aPreviousChildElement.tagName != "BR" ) {
|
||||
previousParentElement = aPreviousChildElement;
|
||||
break;
|
||||
}
|
||||
j = j - 1;
|
||||
}
|
||||
}
|
||||
parentSection = section;
|
||||
if( childElement.nodeName == "section" ) {
|
||||
parentSection = childElement ;
|
||||
previousParentElement = childElement ;
|
||||
}
|
||||
if ( typeof childElement.setAttribute == 'function' || childElement.nodeType == Node.COMMENT_NODE ) {
|
||||
addAttributes( parentSection, childElement, previousParentElement, separatorElementAttributes, separatorSectionAttributes );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( element.nodeType == Node.COMMENT_NODE ) {
|
||||
if ( addAttributeInElement( element, previousElement, separatorElementAttributes ) == false ) {
|
||||
addAttributeInElement( element, section, separatorSectionAttributes );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts any current data-markdown slides in the
|
||||
* DOM to HTML.
|
||||
*/
|
||||
function convertSlides() {
|
||||
|
||||
var sections = document.querySelectorAll( '[data-markdown]');
|
||||
|
||||
for( var i = 0, len = sections.length; i < len; i++ ) {
|
||||
|
||||
var section = sections[i];
|
||||
|
||||
// Only parse the same slide once
|
||||
if( !section.getAttribute( 'data-markdown-parsed' ) ) {
|
||||
|
||||
section.setAttribute( 'data-markdown-parsed', true )
|
||||
|
||||
var notes = section.querySelector( 'aside.notes' );
|
||||
var markdown = getMarkdownFromSlide( section );
|
||||
|
||||
section.innerHTML = marked( markdown );
|
||||
addAttributes( section, section, null, section.getAttribute( 'data-element-attributes' ) ||
|
||||
section.parentNode.getAttribute( 'data-element-attributes' ) ||
|
||||
DEFAULT_ELEMENT_ATTRIBUTES_SEPARATOR,
|
||||
section.getAttribute( 'data-attributes' ) ||
|
||||
section.parentNode.getAttribute( 'data-attributes' ) ||
|
||||
DEFAULT_SLIDE_ATTRIBUTES_SEPARATOR);
|
||||
|
||||
// If there were notes, we need to re-add them after
|
||||
// having overwritten the section's HTML
|
||||
if( notes ) {
|
||||
section.appendChild( notes );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// API
|
||||
return {
|
||||
|
||||
initialize: function() {
|
||||
processSlides();
|
||||
convertSlides();
|
||||
},
|
||||
|
||||
// TODO: Do these belong in the API?
|
||||
processSlides: processSlides,
|
||||
convertSlides: convertSlides,
|
||||
slidify: slidify
|
||||
|
||||
};
|
||||
|
||||
}));
|
||||
@@ -1,64 +0,0 @@
|
||||
/**
|
||||
* A plugin which enables rendering of math equations inside
|
||||
* of reveal.js slides. Essentially a thin wrapper for MathJax.
|
||||
*
|
||||
* @author Hakim El Hattab
|
||||
*/
|
||||
var RevealMath = window.RevealMath || (function(){
|
||||
|
||||
var options = Reveal.getConfig().math || {};
|
||||
options.mathjax = options.mathjax || 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js';
|
||||
options.config = options.config || 'TeX-AMS_HTML-full';
|
||||
|
||||
loadScript( options.mathjax + '?config=' + options.config, function() {
|
||||
|
||||
MathJax.Hub.Config({
|
||||
messageStyle: 'none',
|
||||
tex2jax: { inlineMath: [['$','$'],['\\(','\\)']] },
|
||||
skipStartupTypeset: true
|
||||
});
|
||||
|
||||
// Typeset followed by an immediate reveal.js layout since
|
||||
// the typesetting process could affect slide height
|
||||
MathJax.Hub.Queue( [ 'Typeset', MathJax.Hub ] );
|
||||
MathJax.Hub.Queue( Reveal.layout );
|
||||
|
||||
// Reprocess equations in slides when they turn visible
|
||||
Reveal.addEventListener( 'slidechanged', function( event ) {
|
||||
|
||||
MathJax.Hub.Queue( [ 'Typeset', MathJax.Hub, event.currentSlide ] );
|
||||
|
||||
} );
|
||||
|
||||
} );
|
||||
|
||||
function loadScript( url, callback ) {
|
||||
|
||||
var head = document.querySelector( 'head' );
|
||||
var script = document.createElement( 'script' );
|
||||
script.type = 'text/javascript';
|
||||
script.src = url;
|
||||
|
||||
// Wrapper for callback to make sure it only fires once
|
||||
var finish = function() {
|
||||
if( typeof callback === 'function' ) {
|
||||
callback.call();
|
||||
callback = null;
|
||||
}
|
||||
}
|
||||
|
||||
script.onload = finish;
|
||||
|
||||
// IE
|
||||
script.onreadystatechange = function() {
|
||||
if ( this.readyState === 'loaded' ) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
// Normal browsers
|
||||
head.appendChild( script );
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
@@ -1,13 +0,0 @@
|
||||
(function() {
|
||||
var multiplex = Reveal.getConfig().multiplex;
|
||||
var socketId = multiplex.id;
|
||||
var socket = io.connect(multiplex.url);
|
||||
|
||||
socket.on(multiplex.id, function(data) {
|
||||
// ignore data from sockets that aren't ours
|
||||
if (data.socketId !== socketId) { return; }
|
||||
if( window.location.host === 'localhost:1947' ) return;
|
||||
|
||||
Reveal.slide(data.indexh, data.indexv, data.indexf, 'remote');
|
||||
});
|
||||
}());
|
||||
@@ -1,56 +0,0 @@
|
||||
var express = require('express');
|
||||
var fs = require('fs');
|
||||
var io = require('socket.io');
|
||||
var crypto = require('crypto');
|
||||
|
||||
var app = express.createServer();
|
||||
var staticDir = express.static;
|
||||
|
||||
io = io.listen(app);
|
||||
|
||||
var opts = {
|
||||
port: process.env.PORT || 1948,
|
||||
baseDir : __dirname + '/../../'
|
||||
};
|
||||
|
||||
io.sockets.on('connection', function(socket) {
|
||||
socket.on('slidechanged', function(slideData) {
|
||||
if (typeof slideData.secret == 'undefined' || slideData.secret == null || slideData.secret === '') return;
|
||||
if (createHash(slideData.secret) === slideData.socketId) {
|
||||
slideData.secret = null;
|
||||
socket.broadcast.emit(slideData.socketId, slideData);
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
app.configure(function() {
|
||||
[ 'css', 'js', 'plugin', 'lib' ].forEach(function(dir) {
|
||||
app.use('/' + dir, staticDir(opts.baseDir + dir));
|
||||
});
|
||||
});
|
||||
|
||||
app.get("/", function(req, res) {
|
||||
res.writeHead(200, {'Content-Type': 'text/html'});
|
||||
fs.createReadStream(opts.baseDir + '/index.html').pipe(res);
|
||||
});
|
||||
|
||||
app.get("/token", function(req,res) {
|
||||
var ts = new Date().getTime();
|
||||
var rand = Math.floor(Math.random()*9999999);
|
||||
var secret = ts.toString() + rand.toString();
|
||||
res.send({secret: secret, socketId: createHash(secret)});
|
||||
});
|
||||
|
||||
var createHash = function(secret) {
|
||||
var cipher = crypto.createCipher('blowfish', secret);
|
||||
return(cipher.final('hex'));
|
||||
};
|
||||
|
||||
// Actually listen
|
||||
app.listen(opts.port || null);
|
||||
|
||||
var brown = '\033[33m',
|
||||
green = '\033[32m',
|
||||
reset = '\033[0m';
|
||||
|
||||
console.log( brown + "reveal.js:" + reset + " Multiplex running on port " + green + opts.port + reset );
|
||||
@@ -1,51 +0,0 @@
|
||||
(function() {
|
||||
// Don't emit events from inside of notes windows
|
||||
if ( window.location.search.match( /receiver/gi ) ) { return; }
|
||||
|
||||
var multiplex = Reveal.getConfig().multiplex;
|
||||
|
||||
var socket = io.connect(multiplex.url);
|
||||
|
||||
var notify = function( slideElement, indexh, indexv, origin ) {
|
||||
if( typeof origin === 'undefined' && origin !== 'remote' ) {
|
||||
var nextindexh;
|
||||
var nextindexv;
|
||||
|
||||
var fragmentindex = Reveal.getIndices().f;
|
||||
if (typeof fragmentindex == 'undefined') {
|
||||
fragmentindex = 0;
|
||||
}
|
||||
|
||||
if (slideElement.nextElementSibling && slideElement.parentNode.nodeName == 'SECTION') {
|
||||
nextindexh = indexh;
|
||||
nextindexv = indexv + 1;
|
||||
} else {
|
||||
nextindexh = indexh + 1;
|
||||
nextindexv = 0;
|
||||
}
|
||||
|
||||
var slideData = {
|
||||
indexh : indexh,
|
||||
indexv : indexv,
|
||||
indexf : fragmentindex,
|
||||
nextindexh : nextindexh,
|
||||
nextindexv : nextindexv,
|
||||
secret: multiplex.secret,
|
||||
socketId : multiplex.id
|
||||
};
|
||||
|
||||
socket.emit('slidechanged', slideData);
|
||||
}
|
||||
}
|
||||
|
||||
Reveal.addEventListener( 'slidechanged', function( event ) {
|
||||
notify( event.currentSlide, event.indexh, event.indexv, event.origin );
|
||||
} );
|
||||
|
||||
var fragmentNotify = function( event ) {
|
||||
notify( Reveal.getCurrentSlide(), Reveal.getIndices().h, Reveal.getIndices().v, event.origin );
|
||||
};
|
||||
|
||||
Reveal.addEventListener( 'fragmentshown', fragmentNotify );
|
||||
Reveal.addEventListener( 'fragmenthidden', fragmentNotify );
|
||||
}());
|
||||
@@ -1,60 +0,0 @@
|
||||
(function() {
|
||||
|
||||
// don't emit events from inside the previews themselves
|
||||
if( window.location.search.match( /receiver/gi ) ) { return; }
|
||||
|
||||
var socket = io.connect( window.location.origin ),
|
||||
socketId = Math.random().toString().slice( 2 );
|
||||
|
||||
console.log( 'View slide notes at ' + window.location.origin + '/notes/' + socketId );
|
||||
|
||||
window.open( window.location.origin + '/notes/' + socketId, 'notes-' + socketId );
|
||||
|
||||
/**
|
||||
* Posts the current slide data to the notes window
|
||||
*/
|
||||
function post() {
|
||||
|
||||
var slideElement = Reveal.getCurrentSlide(),
|
||||
notesElement = slideElement.querySelector( 'aside.notes' );
|
||||
|
||||
var messageData = {
|
||||
notes: '',
|
||||
markdown: false,
|
||||
socketId: socketId,
|
||||
state: Reveal.getState()
|
||||
};
|
||||
|
||||
// Look for notes defined in a slide attribute
|
||||
if( slideElement.hasAttribute( 'data-notes' ) ) {
|
||||
messageData.notes = slideElement.getAttribute( 'data-notes' );
|
||||
}
|
||||
|
||||
// Look for notes defined in an aside element
|
||||
if( notesElement ) {
|
||||
messageData.notes = notesElement.innerHTML;
|
||||
messageData.markdown = typeof notesElement.getAttribute( 'data-markdown' ) === 'string';
|
||||
}
|
||||
|
||||
socket.emit( 'statechanged', messageData );
|
||||
|
||||
}
|
||||
|
||||
// When a new notes window connects, post our current state
|
||||
socket.on( 'connect', function( data ) {
|
||||
post();
|
||||
} );
|
||||
|
||||
// Monitor events that trigger a change in state
|
||||
Reveal.addEventListener( 'slidechanged', post );
|
||||
Reveal.addEventListener( 'fragmentshown', post );
|
||||
Reveal.addEventListener( 'fragmenthidden', post );
|
||||
Reveal.addEventListener( 'overviewhidden', post );
|
||||
Reveal.addEventListener( 'overviewshown', post );
|
||||
Reveal.addEventListener( 'paused', post );
|
||||
Reveal.addEventListener( 'resumed', post );
|
||||
|
||||
// Post the initial state
|
||||
post();
|
||||
|
||||
}());
|
||||
@@ -1,66 +0,0 @@
|
||||
var express = require('express');
|
||||
var fs = require('fs');
|
||||
var io = require('socket.io');
|
||||
var _ = require('underscore');
|
||||
var Mustache = require('mustache');
|
||||
|
||||
var app = express.createServer();
|
||||
var staticDir = express.static;
|
||||
|
||||
io = io.listen(app);
|
||||
|
||||
var opts = {
|
||||
port : 1947,
|
||||
baseDir : __dirname + '/../../'
|
||||
};
|
||||
|
||||
io.sockets.on( 'connection', function( socket ) {
|
||||
|
||||
socket.on( 'connect', function( data ) {
|
||||
socket.broadcast.emit( 'connect', data );
|
||||
});
|
||||
|
||||
socket.on( 'statechanged', function( data ) {
|
||||
socket.broadcast.emit( 'statechanged', data );
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
app.configure( function() {
|
||||
|
||||
[ 'css', 'js', 'images', 'plugin', 'lib' ].forEach( function( dir ) {
|
||||
app.use( '/' + dir, staticDir( opts.baseDir + dir ) );
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
app.get('/', function( req, res ) {
|
||||
|
||||
res.writeHead( 200, { 'Content-Type': 'text/html' } );
|
||||
fs.createReadStream( opts.baseDir + '/index.html' ).pipe( res );
|
||||
|
||||
});
|
||||
|
||||
app.get( '/notes/:socketId', function( req, res ) {
|
||||
|
||||
fs.readFile( opts.baseDir + 'plugin/notes-server/notes.html', function( err, data ) {
|
||||
res.send( Mustache.to_html( data.toString(), {
|
||||
socketId : req.params.socketId
|
||||
}));
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// Actually listen
|
||||
app.listen( opts.port || null );
|
||||
|
||||
var brown = '\033[33m',
|
||||
green = '\033[32m',
|
||||
reset = '\033[0m';
|
||||
|
||||
var slidesLocation = 'http://localhost' + ( opts.port ? ( ':' + opts.port ) : '' );
|
||||
|
||||
console.log( brown + 'reveal.js - Speaker Notes' + reset );
|
||||
console.log( '1. Open the slides at ' + green + slidesLocation + reset );
|
||||
console.log( '2. Click on the link your JS console to go to the notes page' );
|
||||
console.log( '3. Advance through your slides and your notes will advance automatically' );
|
||||