Skip to content

Instantly share code, notes, and snippets.

@MLWhiz
Created September 7, 2020 14:50
Show Gist options
  • Save MLWhiz/d20a2cd7a0eab07039c51ce2dc3e6ca6 to your computer and use it in GitHub Desktop.
Save MLWhiz/d20a2cd7a0eab07039c51ce2dc3e6ca6 to your computer and use it in GitHub Desktop.
class myCustomLinearLayer(nn.Module):
def __init__(self,in_size,out_size):
super().__init__()
self.weights = nn.Parameter(torch.randn(in_size, out_size))
self.bias = nn.Parameter(torch.zeros(out_size))
def forward(self, x):
return x.mm(self.weights) + self.bias
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment