(sess, graph, features)
return total_loss / data_len, total_acc / data_len
:param sess:
    :param graph:
    :param features:
    :return:
def test_model(sess, graph, features):
    """

    :param sess:
    :param graph:
    :param features:
    :return:
    """

    total_loss = 0.0
    total_acc = 0.0

    input_ids = graph.get_operation_by_name('input_ids').outputs[0]
    input_mask = graph.get_operation_by_name('input_mask').outputs[0]
    segment_ids = graph.get_operation_by_name('segment_ids').outputs[0]
    labels = graph.get_operation_by_name('labels').outputs[0]
    is_training = graph.get_operation_by_name('is_training').outputs[0]
    loss = graph.get_operation_by_name('loss/loss').outputs[0]
    acc = graph.get_operation_by_name('accuracy/acc').outputs[0]

    data_len = len(features)
    batch_size = 12
    num_batch = int((len(features) - 1) / batch_size) + 1

    for i in range(num_batch):
        print(i)
        start_index = i * batch_size
        end_index = min((i + 1) * batch_size, data_len)

        batch_len = end_index-start_index

        _input_ids = np.array([data.input_ids for data in features[start_index:end_index]])
        _input_mask = np.array([data.input_mask for data in features[start_index:end_index]])
        _segment_ids = np.array([data.segment_ids for data in features[start_index:end_index]])
        _labels = np.array([data.label_id for data in features[start_index:end_index]])
        feed_dict = {input_ids: _input_ids,
                     input_mask: _input_mask,
                     segment_ids: _segment_ids,
                     labels: _labels,
                     is_training: False}
        test_loss, test_acc = sess.run([loss, acc], feed_dict=feed_dict)
        total_loss += test_loss * batch_len
        total_acc += test_acc * batch_len

    return total_loss / data_len, total_acc / data_len
def test_model ( sess , graph , features ) : total_loss = 0.0 total_acc = 0.0 input_ids = graph . get_operation_by_name ( 'input_ids' ) . outputs [ 0 ] input_mask = graph . get_operation_by_name ( 'input_mask' ) . outputs [ 0 ] segment_ids = graph . get_operation_by_name ( 'segment_ids' ) . outputs [ 0 ] labels = graph . get_operation_by_name ( 'labels' ) . outputs [ 0 ] is_training = graph . get_operation_by_name ( 'is_training' ) . outputs [ 0 ] loss = graph . get_operation_by_name ( 'loss/loss' ) . outputs [ 0 ] acc = graph . get_operation_by_name ( 'accuracy/acc' ) . outputs [ 0 ] data_len = len ( features ) batch_size = 12 num_batch = int ( ( len ( features ) - 1 ) / batch_size ) + 1 for i in range ( num_batch ) : print ( i ) start_index = i * batch_size end_index = min ( ( i + 1 ) * batch_size , data_len ) batch_len = end_index - start_index _input_ids = np . array ( [ data . input_ids for data in features [ start_index : end_index ] ] ) _input_mask = np . array ( [ data . input_mask for data in features [ start_index : end_index ] ] ) _segment_ids = np . array ( [ data . segment_ids for data in features [ start_index : end_index ] ] ) _labels = np . array ( [ data . label_id for data in features [ start_index : end_index ] ] ) feed_dict = { input_ids : _input_ids , input_mask : _input_mask , segment_ids : _segment_ids , labels : _labels , is_training : False } test_loss , test_acc = sess . run ( [ loss , acc ] , feed_dict = feed_dict ) total_loss += test_loss * batch_len total_acc += test_acc * batch_len return total_loss / data_len , total_acc / data_len