Book Image

R Deep Learning Cookbook

By : PKS Prakash, Achyutuni Sri Krishna Rao
Book Image

R Deep Learning Cookbook

By: PKS Prakash, Achyutuni Sri Krishna Rao

Overview of this book

Deep Learning is the next big thing. It is a part of machine learning. It's favorable results in applications with huge and complex data is remarkable. Simultaneously, R programming language is very popular amongst the data miners and statisticians. This book will help you to get through the problems that you face during the execution of different tasks and Understand hacks in deep learning, neural networks, and advanced machine learning techniques. It will also take you through complex deep learning algorithms and various deep learning packages and libraries in R. It will be starting with different packages in Deep Learning to neural networks and structures. You will also encounter the applications in text mining and processing along with a comparison between CPU and GPU performance. By the end of the book, you will have a logical understanding of Deep learning and different deep learning packages to have the most appropriate solutions for your problems.
Table of Contents (17 chapters)
Title Page
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Executing the graph in a TensorFlow session


Until now, we have only created tensor objects and added them to a TensorFlow graph for later execution. In this recipe, we will learn how to create a TensorFlow session that can be used to execute (or run) the TensorFlow graph.

Getting ready

Before we run the graph, we should have TensorFlow installed and loaded in R. The installation details can be found in Chapter 1, Getting Started.

How to do it...

  1. Load the tensorflow library and import the numpy package:
library(tensorflow)
np <- import("numpy")
  1. Reset or remove any existing default_graph:
tf$reset_default_graph()
  1. Start an InteractiveSession:
sess <- tf$InteractiveSession()
  1. Initialize the global_variables:
sess$run(tf$global_variables_initializer())
  1. Run iterations to perform optimization (training):
# Train the model
train_batch_size = 128L
for (i in 1:100) {
spls <- sample(1:dim(train_data$images)[1],train_batch_size)
if (i %% 10 == 0) {
train_accuracy <- accuracy$eval(feed_dict = dict(
x ...