How to do it...

There are other popular libraries in R to develop stacked autoencoders. Let's utilize the SAENET package from R to set up a stacked autoencoder. The SAENET is a stacked autoencoder implementation, using a feedforward neural network using the neuralnet package from CRAN:

  1. Get the SAENET package from the CRAN repository, if not installed already:
install.packages("SAENET")
  1. Load all library dependencies:
require(SAENET)
  1. Load the train and test occupancy dataset using load_occupancy_data:
occupancy_train <-load_occupancy_data(train=T)
occupancy_test <- load_occupancy_data(train = F)
  1. Normalize the dataset using the minmax.normalize function:
# Normalize dataset
occupancy_train<-minmax.normalize(occupancy_train, scaler = NULL)
occupancy_test<-minmax.normalize(occupancy_test, scaler = occupancy_train$scaler)
  1. The stacked autoencoder model can be built using the SAENET.train train function from the SAENET package:
# Building Stacked Autoencoder
SAE_obj<-SAENET.train(X.train= subset(occupancy_train$data, select=-c(Occupancy)), n.nodes=c(4, 3, 2), unit.type ="tanh", lambda = 1e-5, beta = 1e-5, rho = 0.01, epsilon = 0.01, max.iterations=1000)

The output of the last node can be extracted using the SAE_obj[[n]]$X.output command.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset