Skip to content

Instantly share code, notes, and snippets.

@jkotra
Created April 23, 2019 18:46
Show Gist options
  • Save jkotra/eb1a9cbd316d2cea9f6cf8669b580dd1 to your computer and use it in GitHub Desktop.
Save jkotra/eb1a9cbd316d2cea9f6cf8669b580dd1 to your computer and use it in GitHub Desktop.
import mxnet as mx
from mxnet import nd, gluon, autograd
from mxnet.gluon import nn
import mxnet.ndarray as F
class Net(gluon.Block):
def __init__(self, **kwargs):
super(Net, self).__init__(**kwargs)
with self.name_scope():
self.cnn1 = nn.Conv2D(20,kernel_size=(4,4))
self.mxp1 = nn.MaxPool2D((2,2))
self.cnn2 = nn.Conv2D(25,kernel_size=(2,2))
self.mxp2 = nn.MaxPool2D((2,2))
self.cnn3 = nn.Conv2D(30,kernel_size=(2,2))
self.mxp3 = nn.MaxPool2D((2,2))
self.flat = nn.Flatten()
self.fc = nn.Dense(128)
self.out = nn.Dense(10)
def forward(self,x):
x = F.relu(self.mxp1(self.cnn1(x)))
x = F.relu(self.mxp2(self.cnn2(x)))
x = F.relu(self.mxp3(self.cnn3(x)))
x = self.flat(x)
x = F.relu(self.fc(x))
x = self.out(x)
return x
cnn = Net()
print(cnn)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment