Skip to content

Instantly share code, notes, and snippets.

@holmesal
Created January 22, 2019 14:50
Show Gist options
  • Save holmesal/b1e69da3cc3bc6514163312e3778367f to your computer and use it in GitHub Desktop.
Save holmesal/b1e69da3cc3bc6514163312e3778367f to your computer and use it in GitHub Desktop.
class LinearRegressionModel(nn.Module):
def __init__(self):
super(LinearRegressionModel, self).__init__()
# init the layers
self.layers = nn.Sequential(
# input linear layer
nn.Linear(1, 10),
# "rectified linear unit" or "replace negatives with zeroes"
nn.ReLU(inplace=True),
# batch norm
nn.BatchNorm1d(num_features=10),
# output linear layer
nn.Linear(10, 1)
)
# fastai passes both x_cat and x_cont - we can just ignore x_cat
def forward(self, x_cat: Tensor, x_cont: Tensor):
# pass x_cont into the network
return self.layers(x_cont);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment