MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / evaluate

Function evaluate

tensorflow/contrib/eager/python/examples/rnn_ptb/rnn_ptb.py:178–191  ·  view source on GitHub ↗

evaluate an epoch.

(model, data)

Source from the content-addressed store, hash-verified

176
177
178def evaluate(model, data):
179 """evaluate an epoch."""
180 total_loss = 0.0
181 total_batches = 0
182 start = time.time()
183 for _, i in enumerate(range(0, data.shape[0] - 1, FLAGS.seq_len)):
184 inp, target = _get_batch(data, i, FLAGS.seq_len)
185 loss = loss_fn(model, inp, target, training=False)
186 total_loss += loss.numpy()
187 total_batches += 1
188 time_in_ms = (time.time() - start) * 1000
189 sys.stderr.write("eval loss %.2f (eval took %d ms)\n" %
190 (total_loss / total_batches, time_in_ms))
191 return total_loss
192
193
194def train(model, optimizer, train_data, sequence_length, clip_ratio):

Callers 1

mainFunction · 0.70

Calls 6

_get_batchFunction · 0.85
timeMethod · 0.80
loss_fnFunction · 0.70
rangeFunction · 0.50
numpyMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected