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

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)))