Deep Learning With R : Convolutional Neural Network

Neural network with many convolutional layers

What Is Convolutional Neural Network?

Do Analyze

install.packages(tensorflow)
install.packages(keras)
install.packages(EBImage)
library(tensorflow)
library(keras)
library(EBImage)
setwd("D://exam/")
save_in <- ("D://result/")
gambar <- list.files()
w <- 100
h <- 100
for (i in 1:length(gambar))
{result <- tryCatch({
imgname<-gambar[i]
img<-readImage(imgname)
img_resized<-resize(img,w=w,h=h)
path<-paste(save_in,imgname,sep=" ")
writeImage(img_resized,path,quality=70)
print(paste("done",i,sep=" "))
},
error=function(e){print(e)}
)}
display(gambar2[[3]]) #menampilkan gambar ke-3
train <- gambar2[c(1:4,7:10)]
test <- gambar2[c(5:6,11:12)]
train[[5]] #menampilkan data training gambar ke-5
par(mfrow=c(2,4))
for (i in 1:8) plot(train[[i]])
for (i in 1:8){train[[i]]<-resize(train[[i]],32,32)}
for (i in 1:4){test[[i]]<-resize(test[[i]],32,32)}
train <- combine(train)
x<-tile(train,8)
display(x,title="gambar")
dim(train)
test <- combine(test)
y <- tile(test,4)
display(y,title="gambar")
dim(test)
Display train data combination
Display set data combination
train<-aperm(train,c(4,1,2,3))
test<-aperm(test,c(4,1,2,3))
dim(train)
dim(test)
#klasifikasi
trainy <- c(rep(0,4), rep(1,4))
testy <- c(rep(0,2), rep(1,2))
trainy
testy
#label dari data target
trainLabels <- to_categorical(trainy)
testLabels <- to_categorical(testy)
trainLabels
testLabels
Classification output
Output labels from target data