MCPcopy Create free account
hub / github.com/OUCMachineLearning/OUCML / evaluate

Function evaluate

AutoML/darts-master/rnn/train.py:140–156  ·  view source on GitHub ↗
(data_source, batch_size=10)

Source from the content-addressed store, hash-verified

138
139
140def evaluate(data_source, batch_size=10):
141 # Turn on evaluation mode which disables dropout.
142 model.eval()
143 total_loss = 0
144 ntokens = len(corpus.dictionary)
145 hidden = model.init_hidden(batch_size)
146 for i in range(0, data_source.size(0) - 1, args.bptt):
147 data, targets = get_batch(data_source, i, args, evaluation=True)
148 targets = targets.view(-1)
149
150 log_prob, hidden = parallel_model(data, hidden)
151 loss = nn.functional.nll_loss(log_prob.view(-1, log_prob.size(2)), targets).data
152
153 total_loss += loss * len(data)
154
155 hidden = repackage_hidden(hidden)
156 return total_loss[0] / len(data_source)
157
158
159def train():

Callers 1

train.pyFile · 0.70

Calls 3

get_batchFunction · 0.90
repackage_hiddenFunction · 0.90
init_hiddenMethod · 0.80

Tested by

no test coverage detected