aitech-eks-pub/wyk/pytorch_regression/my_linear_regressor.py

13 lines
346 B
Python
Raw Permalink Normal View History

2021-05-05 13:35:25 +02:00
import torch.nn as nn
import torch
class MyLinearRegressor(nn.Module):
def __init__(self, vlen):
super(MyLinearRegressor, self).__init__()
self.register_parameter(name='w', param=torch.nn.Parameter(
torch.zeros(vlen, dtype=torch.double, requires_grad=True)))
def forward(self, x):
return x @ self.w