aitech-eks-pub/wyk/pytorch-regression/my_linear_regressor.py

13 lines
346 B
Python

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