aitech-eks-pub/wyk/pytorch_regression/linear1-infer.py

24 lines
387 B
Python
Raw Normal View History

2021-05-05 13:35:25 +02:00
#!/usr/bin/env python3
import sys
from analyzer import vectorizer
import torch
w = torch.load('model.bin')
def fun(w, x):
return x @ w
for line in sys.stdin:
line = line.strip('\n')
content = line
x = (torch.from_numpy(vectorizer.fit_transform([content]).toarray()))[0]
y_hat = fun(w, x)
print(max(1814.0, min(2013.999, y_hat.item() * 100.0 + 1913.0)))