Skip to content

Issue with decode in test_review when deploying the model using PyTorch? #1

Closed
@hpkhanh1610

Description

@hpkhanh1610

Hi,

In the project, at Step 6 (again) - Deploy the model for the web app, at the function def test_reviews(data_dir='../data/aclImdb', stop=250):,
# Read in the review and convert to 'utf-8' for transmission via HTTP review_input = review.read().encode('utf-8') # Send the review to the predictor and store the results results.append(int(predictor.predict(review_input)))

I think the last line should be:
results.append(round(float(predictor.predict(review_input))))

The output from predictor.predict is in byte type, that is b' ', so we need to use float() to convert to real number and use round to round it to the nearest integer (int() is not correct in this case because it rounds all numbers from 0-1 down to 0 only).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions