def evaluate(data_source):
log.info('<STR_LIT>')<EOL>tic = time.time()<EOL>for batch in data_source:<EOL><INDENT>inputs, token_types, valid_length = batch<EOL>out = net(inputs.astype('<STR_LIT>').as_in_context(ctx),<EOL>token_types.astype('<STR_LIT>').as_in_context(ctx),<EOL>valid_length.astype('<STR_LIT>').as_in_context(ctx))<EOL><DEDENT>toc = time.time()<EOL>log.info('<STR_LIT>'<EOL>.format(toc - tic,<EOL>len(data_source) / (toc - tic)))<EOL>
Evaluate the model on a mini-batch.