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

21 lines
373 B
Python
Raw Normal View History

2021-05-05 13:35:25 +02:00
#!/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)))