Convolutional Neural Networks in R Mengli Xiao Division of - - PowerPoint PPT Presentation

convolutional neural networks in r
SMART_READER_LITE
LIVE PREVIEW

Convolutional Neural Networks in R Mengli Xiao Division of - - PowerPoint PPT Presentation

Convolutional Neural Networks in R Mengli Xiao Division of Biostatistics University of Minnesota February 21, 2018 1/9 Outline Preparation Create Python environment Install R packages: keras, tensorflow(optional) Application Convolutional


slide-1
SLIDE 1

1/9

Convolutional Neural Networks in R

Mengli Xiao

Division of Biostatistics University of Minnesota

February 21, 2018

slide-2
SLIDE 2

2/9

Outline

Preparation Create Python environment Install R packages: keras, tensorflow(optional) Application Convolutional Neural Network in MNIST

slide-3
SLIDE 3

3/9

Why we need Python?

◮ Most deep learning algorithms are written in Python ◮ Based on some intermediate packages, R can call Python to

implement the deep neural networks written in Python

slide-4
SLIDE 4

4/9

Create Python virtual environment

◮ Download Python 2.7 at https://www.python.org/downloads/ ◮ Download Anaconda Python 2.7 version

https://www.anaconda.com/download/?lang=en-us

◮ The python 3.6 can also be used

slide-5
SLIDE 5

5/9

Packages in R

◮ Package ”keras”: Keras is a high-level neural network API

written in Python (https://keras.rstudio.com/) install.packages("keras") library(keras) install_keras ()

◮ The commands automatically install tensorflow with keras

◮ Optional: Package ”tensorflow” – Tensorflow is a low-level

API and Keras is a wrapper to it (https://tensorflow.rstudio.com/) install.packages("tensorflow")

◮ Faster than Keras ◮ Harder to use at the expense of having more control

◮ It’s necessary to create Python virtual environment to ensure

you to load the R packages successfully

slide-6
SLIDE 6

6/9

Figure: Popularity of deep learning framework by year

slide-7
SLIDE 7

6/9

Convolutional neural network

A very simple CNN structure

Input image, 28 × 28 × 1 Conv layer with 32 3 × 3 filters, padding=0, stride=1

Output dimension: 26 × 26 × 32

Conv layer with 32 3 × 3 filters, padding=0, stride=1

Output dimension: 24 × 24 × 32

2 × 2 Maxpooling

Output dimension: 12 × 12 × 32

Fully connected with 128 neurons

Output dimension: 128 × 1

Dropout (0.5)

Output dimension: 128 × 1

Fully connected with 10 neurons

Output dimension: 10 × 1

slide-8
SLIDE 8

7/9

Data: MNIST

slide-9
SLIDE 9

8/9

Steps in the implementation

  • 1. Load the data from the Keras pacakage
  • 2. Construct the model structure
  • 3. Compile the model
  • 4. Evaluate the model
slide-10
SLIDE 10

9/9

Reference I

https://keras.rstudio.com/ https://tensorflow.rstudio.com/