Prepare with the top Deep Learning interview questions listed here. These have been answered by experts and will be your best guide to surviving the trickiest Deep Learning interviews. Convert your next Deep Learning interview into a sure job offer as a Senior Data Scientist, Software Developer, etc. These Deep Learning interview questions and answers are based on real-time projects and will help you competently answer questions on neural networks, advanced pattern recognition and more.
Deep Learning is a branch of machine learning based on a set of algorithms that attempt to model high level and hierarchical representation in data using deep graph with multiple processing layers, multiple linear and non-linear transformations.
In Machine Learning (ML), basic process flow is from “Input” to “hand designed features” to “mapping from features” to “output”. In Representation Learning (RL), basic process flow is from “Input” to “features” to “mapping from features” to “output”. In Deep Learning (DL), basic process flow is from “Input” to “ simple features” to “more layers of abstract features” to “mapping from features” to “output”. Below table provides a quick reference of this understanding.
|Topic / Area||Basic Process Flow|
A neural network’s primary function is to receive a set of inputs, perform progressively complex computations, and then use the output to solve the problem. Neural networks are used for lot of different applications, one example would be classification. There are lots of classifiers available today such as logistic regression, support vector machine, decision trees, random forest and so on and of course neural networks.
For example, say we needed to predict if a person is healthy or sick. All you have are some input information such as height, weight, body temperature of each person, there is a need to classify / predict if a person is sick or healthy is a classification problem and it can be solved using approaches such as neural networks. The classifier would receive the data about the patient, process it and give a confidence score. A high score would indicate high confidence that patient is sick and a low score would suggest they are healthy. Score could be probability value of 0 to 1.
Neural network is highly structured and comes in layers. First layer is the input layer, last layer is the output layer and all layers in between are referred to as hidden layers. Hence a neural network can be viewed as the result of spinning classifiers together in a layered web.
What enables a deep neural net to recognize complex pattern? Explain with an example. Connect Side A to Side B in below table. (Multiple techniques in Side B can be used for a Side A problem, please tag all those)
|Side A||Side B|
Recurrent Net (RNTN)
Restricted Boltzmann Machine (RBM)
Deep Belief Nets (DBN)
Convolutional Neural Nets (CNN)
*RNTN – Recursive Neural Tensor Network, *MLP – Multi Layer Perceptron, *RELU – Rectifier Linear Unit
The key is that deep neural nets are able to break complex patterns down into a series of simpler patterns. For example: let’s say a task is to determine whether or not an image contained a human face. A deep neural net would first use edges to detect different parts of the face – the nose, lips, ears, eyes etc. and would then combine the results together to form the whole face. This important feature using simpler patterns as building blocks to detect “complex patterns” is what gives deep neural nets their strength.
There is one key downside to all this – deep neural nets take much longer to train. However with the advancement in technology, now there are high performance GPUs available that can finish training a complex net in a relatively quicker time compared to those using CPUs.
There are different categories to be able to handle both scenarios where labelled data exist and where there is no labelled data. Different techniques / approaches can be used to hand such problems.
Below is correct mapping for the tabular data of Side A to Side B:
|Side A||Side B|
|Unlabelled Data||Restricted Boltzmann Machine (RBM)Autoencoders|
|Text Processing||Recurrent Net (RNTN)|
|Unsupervised Learning||Restricted Boltzmann Machine (RBM) Autoencoders|
|Image Recognition||Deep Belief Nets (DBN) Convolutional Neural Nets (CNN)|
|Object Recognition||Recurrent Net (RNTN) Convolutional Neural Nets (CNN)|
|Speech Recognition||Recurrent Net (RNTN)|
|Classification||MLP/RELU, Deep Belief Nets (DBN)|
*RNTN – Recursive Neural Tensor Network, *MLP – Multi Layer Perceptron, *RELU – Rectifier Linear Unit
Please select that apply from below reason(s). Explain in brief why is vanishing gradient a problem?
a) Training is quick if the gradient is large and slow if it is small
b) With backpropagation, the gradient becomes smaller as it works back through the net
c) The gradient is calculated multiplying two numbers between 0 and 1
d) All of the above.
All of the above / Option d is correct option.
Now coming to second part of question for the explanation, below is described:
With a method called backpropagation, we run into a problem called vanishing gradient or sometimes the exploding gradient. When that happens, training takes too long and accuracy really suffers.
For example, when we are training a neural net, we are constantly calculating a cost value. The cost is typically difference between net’s predicted output and the actual output from a set of labelled training data. The cost is then lowered by making slight adjustments to the weights and biases over and over throughout the training process, until the lowest possible value is obtained. The training process utilizes a “gradient”, which measures the rate at which the cost will change w.r.t. a change in a weight or a bias.
Early layers of a network are slowest to train, early layers are also responsible for early detection of features and building blocks. If we consider the face detection, early layers are important to figure out edges to correctly identify the face and then pass on the details to later layers where it’s features are captured and consolidated to be able to provide final output.
A convolutional neural network (CNN) is a type of artificial neural network used in image recognition and processing that is specifically designed to process pixel data. In deep learning, a CNN is a class of deep neural nets, most commonly applied to analysing visual imagery. CNNs use a variation of multilayer perceptrons designed to require minimal pre-processing. Convolution is the process of filtering through the image for a specific pattern.
CNNs typical has the following layers other than Input and Output layers –
There is also a fully connected layer (FC) at the end prior to output layer, in order to equip net with the ability to classify data samples.
A fundamental architecture comprising of all layers for a CNN can be described in the image below. This is an illustrative structure and layers can be used differently to solve a specific problem based on a context or situation.
Yes, CNN does perform dimensionality reduction. Pooling layer is used for this.
Image classification and tagging, Face detection and Video recognition are use cases of machine vision. So option “i”,”iii”,”iv” are correct answers.
Image search systems use deep learning for image classification and automatic tagging, which allows images to be accessible through a standard search query. For example: companies such as Facebook use deep nets to scan pictures for faces at many different angles, and then label the face with the proper name.
Face detection is a computer technology being used in a variety of applications that identifies human faces in digital images. Deep nets are also used to recognize objects within images which allow for images to be searchable based on the objects within them.
Video recognition systems are important tools for driverless cars, remote robots, theft detection etc. Typically video is an ordered set of frames of same resolution. It has got two parts – video stream and video sequence. Video stream is an ongoing video for online real-time procession. Video sequence is a video of fixed length.
A deep learning platform provides a set of tools and an interface for building custom deep nets. Typically they provide a user with a selection of deep nets to choose from, along with the ability to integrate data from different sources, manipulate data, and manage models through user interface. Some platforms also help with performance if a net needs to be trained with a large dataset. The platform is typically an out of the box application that lets us configure a deep net’s hyper-parameters through an intuitive UI. With a platform, we don’t need to know anything about coding aspects in order to use tools. The downside is that we are constrained by the platform’s selection of deep nets as well as the configuration options. However, for somebody to quickly deploy a deep net, a platform could be the best way to go. Deep learning platforms come in two different forms – software platform and full platform. Examples are H2O.ai, Data Graph etc
Library is a set of functions and modules that we can call through our own programs in order to perform certain tasks. Deep net libraries gives us lot of flexibility with net selection and hyper-parameter configuration. For example: there are not many platforms that let us build a Recursive Neural Tensor Net (RNTN), however we can code our own with the appropriate deep net library. The obvious downside here is the coding experience required to use them. However if we need flexibility, these are great options. Examples are TensorFlow, Theano, Caffe, deeplearning4j, torch etc.
Artificial Neural Network (ANN) can be of two main categories: Feed-forward neural networks and recursive neural networks. They are flexible to many possible variations based on – the learning rule, the inference rule and the architecture.
Feed forward neural network can be described as per below diagram:
Perceptron algorithm is a fundamental computational unit at heart of the Deep learning model. It’s a supervised learning algorithm for binary classification.
There are many packages available for ANNs. In R, some of the packages are nnet, neuralnet, RSNNS, deepnet, darch, caret, RNN, Autoencoder, RcppDL, MXNetR and others for more specific tasks.
The answer will be .
The program creates a graph by using source operations. These source operations will pass their information to other operations which will execute computations.
Here in order to create two source operations which will output numbers, two constants are defined in a and b. After that, function tf.add() adds two elements and stores the calculation in c.
The with block then prints the result by opening the session.
After running the with block, session will close automatically.
Answer: 0, 1, 2
The result will print 0 to 2.
The variable is first defined using tf.Variable() and it is initialized with 0. Then in order to counter from the initial value, tf.assign() function is used. It takes two arguments – the reference_variable as 1st argument and value_to_update as a 2nd argument.
Variables must be initialized by running an initialization operation after having launched the graph. We first have to add the initialization operation to the graph.
We then start a session to run the graph, first initialize the variables, then print the initial value of the state variable, and then run the operation of updating the state variable and printing the result after each update.
The tf.float32 will define a 32 bit floating point. The first line creates a placeholder and then it is multiplied by 2 and kept in second variable as b.
Now we need to define and run the session, but since we created a "hole" in the model to pass the data, when we initialize the session we are obligated to pass an argument with the data, otherwise we would get an error.
To pass the data into the model we call the session with an extra argument feed_dict in which we should pass a dictionary with each placeholder name followed by its respective data, like the way it was shown in above code snippet.
Operations are nodes that represent the mathematical operations over the tensors on a graph. These operations can be any kind of functions, like add and subtract tensor or maybe an activation function.
ALL of these four - tf.constant, tf.matmul, tf.add, tf.nn.sigmoid are operations in TensorFlow. These are like functions in python but operate directly over tensors and each one does a specific thing.
While others are straight forward and simple, tf.nn.sigmoid is an activation function, it's a little more complicated, but this function helps learning models to evaluate what kind of information is good or not.
The output will be as follows:
c =: 8 d =: 4
Operations are nodes that represent the mathematical operations over the tensors on a graph. These operations can be any kind of functions, like add and subtract tensor used here. tf.constant function defines the values to variables a and b.
Then c and d performs add and subtract operations respectively based on the given value in the session. Hence it outputs desired result and prints it.
Option c would be the correct answer.
The size of the convoluted matrix is given by C = ((I-F+2P)/S)+1, where
Here I = 12, F = 3, P = 0, S = 1
Therefore the answer is 10 X 10 matrix.
Option c is the correct answer.
Softmax function is of the form in which the sum of probabilities over all i sum to 1.
If we take an input of [1, 2, 3, 4, 1, 2, 3], the softmax of that is [0.024, 0.064, 0.175, 0.475, 0.024, 0.064, 0.175]. The output has most of its weight where the '4' was in the original input. This is what the function is normally used for: to highlight the largest values and suppress values which are significantly below the maximum value. However please note that, softmax is not scale invariant, so if the input were [0.1, 0.2, 0.3, 0.4, 0.1, 0.2, 0.3] (which sums to 1.6) the softmax would be [0.125, 0.138, 0.153, 0.169, 0.125, 0.138, 0.153]. This shows that for values between 0 and 1 softmax, in fact, de-emphasizes the maximum value (note that 0.169 is not only less than 0.475, it is also less than the initial proportion of 0.4/1.6=0.25)
If we execute below code snippet in Python 3.x, then we can get the desired output for the example of [1,2,3,4,1,2,3] that we mentioned above.
Gradient descent is a first-order iterative optimization algorithm for finding the minimum of a function. To find a local minimum of a function using gradient descent, one takes steps proportional to the negative of the gradient (or approximate gradient) of the function at the current point. If, instead, one takes steps proportional to the positive of the gradient, one approaches a local maximum of that function; the procedure is then known as gradient ascent.
Below is an illustrative diagram of gradient descent on a series of level sets.
Dropout is a regularization technique patented by Google for reducing overfitting in neural networks by preventing complex co-adaptations on training data. It is a very efficient way of performing model averaging with neural networks. The term "dropout" refers to dropping out units (both hidden and visible) in a neural network.
Dropout can be seen as an extreme form of bagging in which each model is trained on a single case and each parameter of the model is very strongly regularized by sharing it with the corresponding parameter in all the other models.
Key points are as follows: Large weights in a neural network are a sign of a more complex network that has overfit the training data. Probabilistically dropping out nodes in the network is a simple and effective regularization method. A large network with more training and the use of a weight constraint are suggested when using dropout.
Goodness of fit is to strike a balance between bias and variance.
Yes, overfitting can occur in a neural network. There are various ways to handle overfitting in a neural network which are as follows:
Dropout is a regularization method that approximates training a large number of neural networks with different architectures in parallel. Dropout has the effect of making the training process noisy, forcing nodes within a layer to probabilistically take on more or less responsibility for the inputs.
Some of the key aspects for using dropout regularization are:
Batch normalisation is a technique for improving the performance and stability of neural networks. The idea is to normalise the inputs of each layer in such a way that they have a mean output activation of 0 and standard deviation of 1. This is analogous to how the inputs to networks are standardised.
In Keras, it is implemented using the following code snippet. Note how the BatchNormalization call occurs after each fully-connected layer, but before the activation function and dropout.
Yes, CNN has the pooling layer.
Invariance means that we can recognize an object as an object, even when its appearance varies in some way. It preserves object’s identity, category etc across the changes in the specifics of visual input, like relative positions of the viewer and object.
The translation has a specific meaning in vision, generally borrowed from geometry. It does not refer to any type of conversion, unlike say, a translation from French language to English language or between file formats. Instead, it means that each point/pixel in the image has been moved the same amount in the same direction. Alternately, you can think of the origin as having been shifted an equal amount in the opposite direction.
So typically, CNN + max-pooling ~ Translation invariance
We are trying to solve a problem which has small amount of data. We have a pre-trained neural network model that was trained on a similar problem. What methodologies from below would you choose for make use of the given pre-trained model in hand?
Correct answer option is D.
The best method would be to train only the last layer as previous all layers work as feature extractors. They would have extracted key features as part of initial layers in a similar scenario.
Since the data similarity is very high, we do not need to retrain the model. All we need to do is to customize and modify the output layers according to our problem statement. We use the pretrained model as a feature extractor. For example: let’s say we decide to use models trained on Imagenet to identify if the new set of images have cats or dogs. Here the images we need to identify would be similar to imagenet, however we just need two categories as our output – cats or dogs. In this case all we do is just modify the dense layers and the final softmax layer to output 2 categories instead of a 1000. Additionally training time takes longer in these type of neural nets. Hence it would save significant amount of time. Re-training last layer will take care of the new dataset at hand with a similar feature being created already and executed leveraging that.
There are potentially four scenarios and they can be explained in below diagrammatical fashion.
The primary reason overfitting happens is because the model learns even the tiniest details present in the data. So after learning all the possible patterns it can find, the model tends to perform extremely well on the training set but fails to produce good results on the test sets. It falls apart when faced with previously unseen data. And this is critical from an accuracy standpoint.
One way to prevent overfitting is to reduce the complexity of the model. This is exactly what regularization does. If we set the regularization parameter to a large value, the decay in the weights during gradient descent update will be more. Hence, the weights of most of the hidden units will be close to zero.
Since the weights are negligible, the model will not learn much from these units. This will end up making the network simpler and thus reduce overfitting.
Let us take another example. Assume we are using a tanh activation function.
Now if we set regularization parameter to a large value, the weight of the units will be less. To calculate the z[l], we can use the following:
Z[l] = w[l] m[l-1] + n[l]
Hence the z-value will be less. If we use the tanh activation function then these low values of z[l] will lie near the origin.
The key aspect with this change is that we are only using the linear region of the tanh function. This will make every layer in the network mostly linear. i.e. we will get linear boundaries that separate the data which prevents overfitting.
Correct answer option is B.
ReLU or Rectifier Linear Unit gives continuous output in range 0 to infinity. However in output layer, we would require a finite range of values.
A unit employing the rectifier is called Rectifier Linear Unit or ReLU.
Range is 0 to infinity.
In case of Leaky ReLU, f(y) is ay and not zero. The leak helps to increase the range of the ReLU function. Usually the value of a is 0.01 or equivalent to that.
Correct answer is B.
The output can be calculated as 3 (2*4 + 3*5 + 4*6) = 3 (8 + 15 + 24) = 3 * 47 = 141.
MLP or Multi Layer Perceptron is a class of feed forward artificial neural net. It comprises of at least 3 layers of nodes – input layer, hidden layer and output layer. Except the input node, each node is a neuron that uses a nonlinear activation function.
In the theory of artificial neural networks, the universal approximation theorem states that a feed-forward network with a single hidden layer containing a finite number of neurons can approximate continuous functions on compact subsets of Rⁿ, under mild assumptions on the activation function. It does state that simple neural networks can represent a wide variety of interesting functions when given appropriate parameters; however, it does not touch upon the algorithmic learnability of those parameters.
Examples of universal approximators are –
All of these methods can approximate any function.
Given below is an input matrix shape of 7 X 7. What will be the output on applying a max pooling of size 3 X 3 with a stride of 2?
Max pooling takes a 3 X 3 matrix and takes the maximum of the matrix as the output. Slide it over the entire input matrix with a stride of 2 and we can get below matrix as the result.
Yes dropout can be applied. Please refer below. We have added a new dropout layer between the input and first hidden layer. The dropout rate is also set to 20%. This means one in five inputs will be randomly excluded from each update cycle.
We can not provide an answer to above as sufficient information is not available. We need to know weights and biases of a neural net, to be able to predict output like above scenario.
The above code will throw error.
Dimensions must be equal. But these are 3 and 2 for “matmul” function which is mismatching. Hence this has to be defined for a 2 X 2 matrix.
Please change the “Matrix_one” and “Matrix_two” dimensions to reflect a 2 X 2 matrix and then it should work fine.
Weight sharing occurs in Convolutional Neural Network (CNN) and Recurrent Neural Network (RNN). It does not occur in case of Fully Connected neural nets.
For example: “Shared weights” is simple: use the same weight vector to do the “convolution” (which is essentially inner product of two vectors). Let’s take below scenario.
Input layer is x = [x1 x2 x3 x4 x5 x6 x7]
Hidden layer is h = [h1 h2 h3]
Weight vector is w = [w1 w2 w3] = [1 0 -1] which is used by all
H1 = w * x[1:3]
H2 = w * x[3:5]
H3 = w * x[5:7]
Reference from : http://cs231n.github.io/assets/conv-demo/index.html - cs231n guide from Stanford University- amazing animation on convolution describing the shared weights.
The idea behind this is : a filter, e.g. which detects horizontal edge, matches the left corner of an image but may also match the right bottom corner of the image. Using(sharing) multiple filters avoid the feed forward neural network structure which is more complicated.
The Rectified Linear Unit or ReLU is represented below with a diagram. It computes the function f(x)=max(0,x). In other words, the activation is simply thresholded at zero.
The Pros and Cons of ReLU are as follows:
An issue with dealing with them is where they die, i.e. dead Relus. Because if activation of any relu neurons become zero then its gradients will be clipped to zero in back-propagation. This can be avoided if we are very careful with weights initialization and tuning learning rate.
For example, a large gradient flowing through a ReLU neuron can cause the weights to update in such a way that the neuron will never activate on any data point again. If this happens, then the gradient flowing through the unit will forever be zero from that point on. That is, the ReLU units can irreversibly die during training since they can get knocked off the data manifold. For example, we may find that as much as 40% of our network can be “dead” (i.e. neurons that never activate across the entire training dataset) if the learning rate is set too high. With a proper setting of the learning rate this is less frequently an issue.
We have a hidden layer neural network as represented below. The hidden layer in this network works as a dimensionality reductor. Instead of using the hidden layer, we replace it with a dimensionality reduction technique such as PCA (Principal Component Analysis).
How will the network behave that uses a dimensionality reduction technique?
No, CNNs cannot.
Data pre-processing steps such as scaling, rotations is necessary before we model data and provide them as an input to neural network such as CNN because CNNs cannot do it by themselves.
Bias = -1.5, w1 = 1, w2 = 1
We can do hit and trial to ensure below functions can be computed based on the above AND gate functions mentioned. Below is the example of the same:
F(-1.5*1 + 1*0 + 1*0) = f(-1.5) = 0
F(-1.5*1 + 1*0 + 1*1) = f(-0.5) = 0
F(-1.5*1 + 1*1 + 1*0) = f(-0.5) = 0
F(-1.5*1 + 1*1 + 1*1) = f(0.5) = 1
Above all of these also comply with the AND gate.
Various factors could be affecting this scenario. Some of them are as follows:
Some of the key aspects that we should monitor during training of a neural network are –
The first quantity that is useful to track during training is the loss, as it is evaluated on the individual batches during the forward pass. Below is a diagram showing the loss over time, and especially what the shape might tell us about the learning rate.
The second important quantity to track while training a classifier is the validation/training accuracy. This plot can give us valuable insights into the amount of overfitting in our model:
The last quantity we might want to track is the ratio of the update magnitudes to the value magnitudes. Note: updates, not the raw gradients (e.g. in vanilla sgd this would be the gradient multiplied by the learning rate). We might want to evaluate and track this ratio for every set of parameters independently. A rough heuristic is that this ratio should be somewhere around 1e-3. If it is lower than this then the learning rate might be too low. If it is higher then the learning rate is likely too high. Here is a specific example:
Nesterov Momentum is a different version of the momentum update. It enjoys stronger theoretical converge guarantees for convex functions and in practice it also consistently works slightly better than standard momentum.
The core idea behind Nesterov momentum is that when the current parameter vector is at some position x, then looking at the momentum update above, we know that the momentum term alone (i.e. ignoring the second term with the gradient) is about to nudge the parameter vector by mu * v. Therefore, if we are about to compute the gradient, we can treat the future approximate position x + mu * v as a “lookahead” - this is a point in the vicinity of where we are soon going to end up. Hence, it makes sense to compute the gradient at x + mu * v instead of at the “old/stale” position x.
Nesterov momentum: Instead of evaluating gradient at the current position (red circle), we know that our momentum is about to carry us to the tip of the green arrow. With Nesterov momentum we therefore instead evaluate the gradient at this "looked-ahead" position.
In training deep networks, it is usually helpful to anneal the learning rate over time. Good intuition to have in mind is that with a high learning rate, the system contains too much kinetic energy and the parameter vector bounces around chaotically, unable to settle down into deeper, but narrower parts of the loss function.
Knowing when to decay the learning rate can be tricky: Decay it slowly and you’ll be wasting computation bouncing around chaotically with little improvement for a long time. But decay it too aggressively and the system will cool too quickly, unable to reach the best position it can. There are three common types of implementing the learning rate decay.
Deep Learning is a subfield of machine learning methods and is based on learning data representation. the learning process can be supervised, semi-supervised or unsupervised. Professionals can opt for positions like Machine Learning Engineer, Senior Machine Learning Engineer, Data Scientist, etc.
According to payscale.com, the average salary for a Machine Learning Engineers ranges from $76,000 to $153,000 per year, with a base salary of approximately $111,453.
Companies from around the world use Machine Learning in different yet amazing ways. A few of the companies that use Machine Learning are Yelp, Pinterest, Facebook, Twitter, etc.
There has been an increase in demand for Data Scientists and Machine Learning Engineers in the past few years. Yes, interviews for Deep Learning can be scary, but preparing with these Deep Learning interview questions will help you in pursuing your dream career. It’s important to be prepared to respond effectively to the questions that employers typically ask in an interview. Since these deep learning engineer interview questions are very common, your prospective recruiters will expect you to be able to answer. These current deep learning interview questions will increase your confidence that you need to ace the interview and motivation as well.
Going through these interview questions for deep learning will help you land your dream job and will definitely prepare you to answer the toughest of questions in the best way possible. These deep learning interview questions and answers are suggested by experts and have proven to have great value.
Not only the job aspirants but also the recruiters can refer to these deep learning technical interview questions to know the right set of questions to assess a candidate.