ANN Final Exam
ANN Final Exam
48
Answer:
Question No. 1
B. How CNN does automatic feature extraction from data? Why automatic feature
extraction is important than manual feature extraction? What are various ways of
automatic feature extraction? Justify your answers.
Answer:
Feature extraction is one of the most important machine learning issues. Finding suitable
attributes of datasets can enormously reduce the dimensionality of the input space, and from a
computational point of view can help all of the following steps of pattern recognition
problems, such as classification or information retrieval. However, the feature extraction step
is usually performed manually. Moreover, depending on the type of data, we can face a wide
range of methods to extract features. In this sense, the process to select appropriate
techniques normally takes a long time. This work describes the use of recent advances in
deep learning approach in order to find a good feature representation automatically.
Feature extraction involves reducing the number of resources required to describe a large set
of data. When performing analysis of complex data one of the major problem’s stems from
the number of variables involved.
Sparse filtering
Isomap.
Kernel PCA.
Latent semantic analysis.
Partial least squares.
Principal component analysis.
Independent Component Analysis
Question No. 2
A. Suppose you have a non-image data of some experiment. The data may be in the form
of a Table or CSV file with 20 features and 500 samples and feature values are
represented through; F1, F2,……..F20. What type of transformation in this type of
data will be required so that we can apply convolutional neural network (CNN) to it?
Answer:
We must transform our data into image form because the function keras accepts the inputs as
images. Yet we use CSV file that is an array here. And we have to transform these to image
at first which are #-D pixels matrix. And we are now re-shaping the matrix into 3-D matrix.
The X(input) and Y(output) are isolated from data.
We also re-scale the data in the range 0-1 because it will be faster to process. so, we divide all
the values by 255(The max value in the matrix(pixel) is 255)
Question No. 2
B. Compare the architecture of AlexNet and GoogleNet. Which one performs better for
image recognition and Object detection in terms of accuracy and why?
Answer:
GoogleNet
The winner of the ILSVRC 2014 competition was GoogleNet (a.k.a. Inception V1) from
Google. It achieved a top-5 error rate of 6.67%! This was very close to human level
performance which the organizers of the challenge were now forced to evaluate. As it turns
out, this was actually rather hard to do and required some human training in order to beat
GoogleNets accuracy. After a few days of training, the human expert (Andrej Karpathy) was
able to achieve a top-5 error rate of 5.1%(single model) and 3.6%(ensemble). The network
used a CNN inspired by LeNet but implemented a novel element which is dubbed an
inception module. It used batch normalization, image distortions and RMSprop. This module
is based on several very small convolutions in order to drastically reduce the number of
parameters. Their architecture consisted of a 22 layer deep CNN but reduced the number of
parameters from 60 million (AlexNet) to 4 million.
AlexNet
AlexNet is the name of a convolutional neural network. A large impact on the field of
machine learning, specifically in the application of deep learning to machine vision. It
famously won the 2012 ImageNet LSVRC-2012 competition by a large margin The network
had a very similar architecture as LeNet by Yann LeCun et al but was deeper, with more
filters per layer, and with stacked convolutional layers.
Question No. 3
A. What do you know about recurrent neural networks (RNN)? How it can be used to
solve the Sentiment Analysis of Tweets or Social Media contents. Provide the
necessary steps and code for this.
Answer:
Recurrent Neural Network (RNN) are a type of Neural Network where the output from
previous step are fed as input to the current step. In traditional neural networks, all the inputs
and outputs are independent of each other, but in cases like when it is required to predict the
next word of a sentence, the previous words are required and hence there is a need to
remember the previous words.
import os
import json
import tweepy
from tweepy import Stream
from tweepy.streaming import StreamListener
consumer_key = os.getenv(“CONSUMER_KEY_TWITTER”)
consumer_secret = os.getenv(“CONSUMER_SECRET_TWITTER”)
access_token = os.getenv(“ACCESS_KEY_TWITTER”)
access_token_secret = os.getenv(“ACCESS_SECRET_TWITTER”)auth =
tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
except KeyError as e:
print("Keyerror:", e)
return True
B. How filter size, depth, width, Epoch size, learning rate and dataset size effects
Convolutional Neural Networks learning.
Answer:
Size of the filters play an important role in finding the key features. A larger size kernel can
overlook at the features and could skip the essential details in the images whereas a smaller
size kernel could provide more information leading to more confusion. Thus, there is a need
to determine the most suitable size of the kernel/filter.
There is a high correlation between the learning rate and the batch size, when the learning
rates are high, the large batch size performs better than with small learning rates.
Data set size affects the accuracy in transfer learning with deep convolutional neural
networks. The first effect is on the baseline case (to repeat, just training the network with
randomly initialized weights). We can see that the model starts to overfit on the training data
when we artificially reduce the data set size, which leads to a steady decline in accuracy on
both Tiny-ImageNet as well as MiniPlaces2. This can be explained by a sub-optimal
parameter configuration because of overfitting on a small data set size.
Question No. 4
You have to choose a datasets of images/video from a surveillance camera or drone. Then do
the image detection and recognition using Convolutional Neural Networks (CNN) or any
variation of it. Also provide the code and overall steps of the working model.
Answer:
#Step 1:Convolution
classifier.add(Conv2D(32, 3, 3, input_shape = (64, 64, 3), activation = 'relu'))
#Step 2-Pooling
classifier.add(MaxPooling2D(pool_size = (2, 2)))
classifier.add(Dropout(0.3)) classifier.add(Conv2D(32, 3, 3, activation = 'relu'))
classifier.add(MaxPooling2D(pool_size = (2, 2)))
classifier.add(Dropout(0.2))
#step 3- Flattening
classifier.add(Flatten())
test_set = test_datagen.ow_from_directory('test_set',
target_size=(64, 64),
batch_size=32,
class_mode='binary')
classifier.t_generator(training_set,
samples_per_epoch=2732,
epochs=20,
validation_data=test_set,
nb_val_samples=435)