aitech-eks-pub/wyk/pytorch_regression/linear0-infer.py
2021-05-19 13:21:13 +02:00

25 lines
408 B
Python
Executable File

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