Question: Problem 1 [ 4 points ] Consider the following code snippet to define a neural network in PyTorch: ` ` ` claan MyNetwork ( nn
Problem points
Consider the following code snippet to define a neural network in PyTorch:
claan MyNetworknnModule:
def initself inputsize, hiddensize, outputsize:
A Bollerplate not shown
self.ll nnLinearinputsize, hiddensize
self.nonlin nnTanh
self nnLinearhiddensize, outputsize
self.logsm nnLogSoftmaxdim
# Initialization, etc. not shown
def forwardself x:
return self.logsmselfnonlinselfselfnonlinselfx
points Let b be a batch size Which of the following tensor shapes can be input to this network without causing a code crash?
I. inp
IIb inp
III. ing b
A
B I and II
C I and III
D II and III
E I, II and III
points What is "wrong" with the above network compared to standard neural network models?
A Tanh is not differentiable so backpropagation will not work
B There is a dimension mismatch which will lead to a crash
C Reusing the self.nonlin layer will cause a crash
D The presence of the nonlinearity before the softmax results in a nonstandard model
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
