Last active
March 29, 2019 23:07
-
-
Save regonn/86fe60a714082a4639f8bcd5af56d110 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@pydef mutable struct MLP <: Chain | |
function __init__(self, n_mid_units=100, n_out=10) | |
pybuiltin(:super)(MLP, self)[:__init__]() | |
@pywith self.init_scope() begin | |
self.l1 = L.Linear(py"None", n_mid_units) | |
self.l2 = L.Linear(py"None", n_mid_units) | |
self.l3 = L.Linear(py"None", n_out) | |
end | |
end | |
function forward(self, x) | |
h1 = F.relu(self.l1(x)) | |
h2 = F.relu(self.l2(h1)) | |
return self.l3(h2) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MLP(Chain): | |
def __init__(self, n_mid_units=100, n_out=10): | |
super(MLP, self).__init__() | |
with self.init_scope(): | |
self.l1 = L.Linear(None, n_mid_units) | |
self.l2 = L.Linear(None, n_mid_units) | |
self.l3 = L.Linear(None, n_out) | |
def forward(self, x): | |
h1 = F.relu(self.l1(x)) | |
h2 = F.relu(self.l2(h1)) | |
return self.l3(h2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment