aitech-eks-pub/wyk/pytorch-regression/linear3-infer.py

21 lines
373 B
Python
Executable File

#!/usr/bin/env python3
import sys
from analyzer import midpoint, vectorize_text
import torch
model = torch.load('model.bin')
for line in sys.stdin:
line = line.strip('\n')
content = line
x = vectorize_text(content)
y_hat = model(x)
# na wyjściu musimy mieć z powrotem rok
print(max(1814.0, min(2013.999, y_hat.item() * 100.0 + midpoint)))