Skip to content

Instantly share code, notes, and snippets.

@vaibhavkumar049
Created June 8, 2019 09:10
Show Gist options
  • Save vaibhavkumar049/6421cb92988262ffbe51f6b0fd101ca9 to your computer and use it in GitHub Desktop.
Save vaibhavkumar049/6421cb92988262ffbe51f6b0fd101ca9 to your computer and use it in GitHub Desktop.
def model(x):
a1 = torch.matmul(x, weights1) + bias1 # (N, 2) x (2, 2) -> (N, 2)
h1 = a1.sigmoid() # (N, 2)
a2 = torch.matmul(h1, weights2) + bias2 # (N, 2) x (2, 4) -> (N, 4)
h2 = a2.exp()/a2.exp().sum(-1).unsqueeze(-1) # (N, 4)
return h2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment