Perceptron
Q1. Neural network in simple Numpy.
- Write in plain NumPy the forward and backward pass for a two-layer feed-forward neural network with a ReLU layer in between.
- Implement vanilla dropout for the forward and backward pass in NumPy.
Deep Learning & Generative AI
Interview questions on Neural Networks.
134 questions
Perceptron
Perceptron
Perceptron
Where weights are denoted by wj and biases are denoted by b. Answer the following questions:
Perceptron
Perceptron
Perceptron
Where:
Perceptron
Perceptron
Perceptron
Perceptron
Perceptron
Perceptron
Perceptron
tion functions in a MLP. Which ones can never be back-propagated and why?
Perceptron
Perceptron
Perceptron
Perceptron
Perceptron
classified samples divided by the total number of incorrectly classified samples.
Perceptron
Perceptron
Perceptron
Perceptron
ImageNet Classification with Deep Convolutional Neural Networks”
Perceptron
Perceptron
Perceptron
Perceptron
Perceptron
import torch
nn001 = nn.Sequential(
nn.Linear(200, 512),
nn.Tanh(),
nn.Linear(512, 512),
nn.Tanh(),
nn.Linear(512, 10),
nn.LogSoftmax(dim=1)
)
Perceptron
Perceptron
Perceptron
Perceptron
Perceptron
Perceptron
Perceptron
Perceptron
Perceptron
import torchvision
import torch
def main():
vgg11 = torchvision.models.vgg11(pretrained=True)
vgg_layers = vgg11.features
for param in vgg_layers.parameters():
param.requires_grad = False
example = [torch.rand(1, 3, 224, 224),
torch.rand(1, 3, 512, 512),
torch.rand(1, 3, 704, 1024)]
vgg11.eval()
for e in example:
out=vgg_layers(e)
print(out.shape)
if __name__ == "__main__":
main()^^I^^I
Perceptron
vgg_layers=vgg11.features[:3] to the respective input.Perceptron
Perceptron
Perceptron
Perceptron
tensor after the application of the convolutional layer?
Perceptron
Perceptron
Perceptron
Perceptron
import torch
from torch import nn
class MaxPool001(nn.Module):
def __init__(self):
super(MaxPool001, self).__init__()
self.math = torch.nn.Sequential(
torch.nn.Conv2d(3, 32, kernel_size=7, padding=2),
torch.nn.BatchNorm2d(32),
torch.nn.MaxPool2d(2, 2),
torch.nn.MaxPool2d(2, 2),
)
def forward(self, x):
print (x.data.shape)
x = self.math(x)
print (x.data.shape)
x = x.view(x.size(0), -1)
print ("Final shape:{}",x.data.shape)
return x
model = MaxPool001()
model.eval()
x = torch.rand(1, 3, 224, 224)
out=model.forward(x)
The architecture is presented in 9.2:
Perceptron
Perceptron
import scipy
scipy.stats.norm.pdf(x, mu, sigma)
1. Without using Scipy, implement the normal distribution from scratch in Python.
2. Assume, you want to back propagate on the normal distribution, and therefore you need the derivative. Using Scipy write a function for the derivative.
Perceptron
Perceptron
Perceptron
Perceptron
Perceptron
Where: A scientist, constructs a Dropout layer using the following algorithm:
Perceptron
Perceptron
Perceptron
Training and Hyperparameters
Initial learning rate 0.1 Weight decay 0.0001 Momentum 0.9 Batch size 1024
optimizer = optim.SGD(model.parameters(), lr=0.1, momentum=0.9,weight_decay=0.0001)
...
trainLoader = torch.utils.data.DataLoader(
datasets.LARGE('../data', train=True, download=True, 7 transform=transforms.Compose([
transforms.ToTensor(),
])),
batch_size=1024, shuffle=True)
In your opinion, what could possibly go wrong with this training pipeline?
Training and Hyperparameters
from sklearn.model_selection import train_test_split
dataset = datasets.load_iris()
X_train, X_test, y_train, y_test =
train_test_split(dataset.data, dataset.target, test_size=0.2)
clf = LogisticRegression(data_norm=12)
clf.fit(X_train, y_train)
He then evaluated the performance of the trained model on the Xtest set.
clf = GridSearchCV(method, params, scoring='roc_auc', cv=5) clf.fit(train_X, train_y)
Explain why his new approach may work better?
Training and Hyperparameters
Training and Hyperparameters
Training and Hyperparameters
Training and Hyperparameters
Training and Hyperparameters
Training and Hyperparameters
Training and Hyperparameters
Training and Hyperparameters
elements. During inference, you notice that the performance is not that good. A friend tells you that in computer vision faces are gathered in various poses and perspectives. He there- fore suggests that during inference you would augment the incoming face five times, run inference on each augmented image and then fuse the output probability distributions by averaging.
Training and Hyperparameters
Training and Hyperparameters
Training and Hyperparameters
Training and Hyperparameters
Training and Hyperparameters
Training and Hyperparameters
Training and Hyperparameters
Training and Hyperparameters
Training and Hyperparameters
Training and Hyperparameters
Training and Hyperparameters
Training and Hyperparameters
Training and Hyperparameters
Training and Hyperparameters
known to suffer from the phenomenon of saturated units.
Training and Hyperparameters
Training and Hyperparameters
Training and Hyperparameters
Training and Hyperparameters
function (8.51):
from scipy import spatial
x1=[6,1,4,5]
x2=[2,8,3,-1]
cityblock = spatial.distance.cityblock(x1, x2) 5 print("Manhattan:", cityblock)
In many cases, and for large vectors in particular, it is better to use a GPU for imple- menting numerical computations. PyTorch has full support for GPU’s (and its my favourite DL library ... ), use it to implement the Manhattan distance function on a GPU.
Training and Hyperparameters
Training and Hyperparameters
Training and Hyperparameters
Training and Hyperparameters
Training and Hyperparameters
Training and Hyperparameters
Training and Hyperparameters
Training and Hyperparameters
Training and Hyperparameters
Training and Hyperparameters
Training and Hyperparameters
Training and Hyperparameters
Regularization for deep learning
Regularization for deep learning
Regularization for deep learning
Regularization for deep learning
Regularization for deep learning
Regularization for deep learning
Regularization for deep learning
Regularization for deep learning
Regularization for deep learning
Regularization for deep learning
Regularization for deep learning
Regularization for deep learning
Regularization for deep learning
Regularization for deep learning
Regularization for deep learning
Regularization for deep learning
Regularization for deep learning
Regularization for deep learning
Regularization for deep learning
Regularization for deep learning
Regularization for deep learning
Regularization for deep learning
Regularization for deep learning
Regularization for deep learning
Regularization for deep learning
Regularization for deep learning
Regularization for deep learning
Regularization for deep learning
Regularization for deep learning
Regularization for deep learning
Regularization for deep learning
Regularization for deep learning
Regularization for deep learning
Regularization for deep learning
Regularization for deep learning
Regularization for deep learning
Regularization for deep learning
Regularization for deep learning
Regularization for deep learning