File size: 425 Bytes
dbadc63 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | import torch
from model import LinearModel
def predict(x_value):
model = LinearModel()
model.load_state_dict(torch.load("models/model.pt"))
model.eval()
x = torch.tensor([[x_value]], dtype=torch.float32)
y = model(x)
print(f"Input: {x_value} | Prediction: {y.item()}")
def actual(x):
return 2 * x + 3
if __name__ == "__main__":
predict(4.0)
print(f"Actual: {actual(4.0)}") |