examples/sentiment_analysis/skep/predict_opinion.py
def predict(model, data_loader, label_map):
    """
    Given a prediction dataset, it gives the prediction results.

    Args:
        model(obj:`paddle.nn.Layer`): A model to classify texts.
        data_loader(obj:`paddle.io.DataLoader`): The dataset loader which generates batches.
        label_map(obj:`dict`): The label id (key) to label str (value) map.
    """
    model.eval()
    results = []
    for input_ids, token_type_ids, seq_lens in data_loader:
        preds = model(input_ids, token_type_ids, seq_lens=seq_lens)
        tags = parse_predict_result(preds.numpy(), seq_lens.numpy(), label_map)
        results.extend(tags)
    return results

    Given a prediction dataset, it gives the prediction results.

    Args:
        model(obj:`paddle.nn.Layer`): A model to classify texts.
        data_loader(obj:`paddle.io.DataLoader`): The dataset loader which generates batches.
        label_map(obj:`dict`): The label id (key) to label str (value) map.
    
Given a prediction dataset, it gives the prediction results.
Given a prediction dataset it gives the prediction results .
def predict(model, data_loader, label_map):
    model.eval()
    results = []
    for input_ids, token_type_ids, seq_lens in data_loader:
        preds = model(input_ids, token_type_ids, seq_lens=seq_lens)
        tags = parse_predict_result(preds.numpy(), seq_lens.numpy(), label_map)
        results.extend(tags)
    return results
def predict ( model , data_loader , label_map ) : model . eval ( ) results = [ ] for input_ids , token_type_ids , seq_lens in data_loader : preds = model ( input_ids , token_type_ids , seq_lens = seq_lens ) tags = parse_predict_result ( preds . numpy ( ) , seq_lens . numpy ( ) , label_map ) results . extend ( tags ) return results
Given a prediction dataset, it gives the prediction results.
Given a prediction dataset it gives the prediction results .
"""
    Given a prediction dataset, it gives the prediction results.

    Args:
        model(obj:`paddle.nn.Layer`): A model to classify texts.
        data_loader(obj:`paddle.io.DataLoader`): The dataset loader which generates batches.
        label_map(obj:`dict`): The label id (key) to label str (value) map.
    """
model
data_loader
label_map
model(obj
`paddle.nn.Layer`): A model to classify texts.
` paddle . nn . Layer ` ) : A model to classify texts .
data_loader(obj
`paddle.io.DataLoader`): The dataset loader which generates batches.
` paddle . io . DataLoader ` ) : The dataset loader which generates batches .
label_map(obj
`dict`): The label id (key) to label str (value) map.
` dict ` ) : The label id ( key ) to label str ( value ) map .