Question: provide the detailed training code proforma code below - def train _ classifier ( args , train, dev ) : # raise Exception (
provide the detailed training code
proforma code below
def trainclassifierargs train, dev:
# raise ExceptionNot fully implemented yet"
# The following code DOES NOT WORK but can be a starting point for your implementation
# Some suggested snippets to use:
model Transformer
model.zerograd
model.train
optimizer optim.Adammodelparameters lre
numepochs
for t in range numepochs:
lossthisepoch
random.seedt
# You can use batching if you'd like
exidxs i for i in range lentrain
random.shuffleexidxs
lossfcn nnNLLLoss
for exidx in exidxs:
loss lossfcn # TODO: Run forward and compute loss
# model.zerograd
# loss.backward
# optimizer.step
lossthisepoch loss.item
model.eval
return 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
