Question: Evaluating the SGD optimization and training / evaluating the DAN model SGD _ optimization ( 2 5 / 2 5 ) = = All calculated
Evaluating the SGD optimization and trainingevaluating the DAN model
SGDoptimization
All calculated gradients are correct
SGD converged to the optimum
DANdev
Accuracy: ;
Precision fraction of predicted positives that are correct: ;
Recall fraction of true positives predicted correctly: ;
Fharmonic mean of precision and recall: ;
Time for training and evaluation: seconds
DANdevtypo
Accuracy: ;
Precision fraction of predicted positives that are correct: ;
Recall fraction of true positives predicted correctly: ;
Fharmonic mean of precision and recall: ;
Time for training and evaluation: seconds for the typo accuracy im getting but i want to increase this to here is my code class PrefixEmbeddings:
def initself wordindexer, embeddings, embeddingdim, prefixlength :
self.wordindexer wordindexer
self.embeddingdim embeddingdim
self.prefixlength prefixlength
self.prefixindexer
self.embeddings torch.tensorembeddings dtype torch.float
for word in self.wordindexer.objstoints.keys: # Iterate over words
idx self.wordindexer.indexofword
if idx : # Check if the word exists
prefix word:prefixlength
if prefix not in self.prefixindexer:
self.prefixindexerprefix
self.prefixindexerprefixappendselfembeddingsidx # Append the embedding
self.prefixindexerprefixappendembeddingsidx
self.prefixembeddings
for prefix, wordembeddings in self.prefixindexer.items:
avgembedding torch.meantorchstackwordembeddings dim
self.prefixembeddingsprefix avgembedding
def getembeddingself word:
for prefixlen in rangeselfprefixlength, :
prefix word:prefixlen
if prefix in self.prefixembeddings:
return self.prefixembeddingsprefix
return torch.randnselfembeddingdim
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
