- Depthwise convolution (mobilenet)
- Shufflenet
- Densenet
This file contains hidden or 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
""" | |
Reference: | |
J. Redmon. Darknet: Open source neural networks in c. | |
http://pjreddie.com/darknet/, 2013-2016. 5 | |
""" | |
import mxnet as mx | |
def conv_act_layer(from_layer, name, num_filter, kernel=(3, 3), pad=(1, 1), \ | |
stride=(1,1), act_type="relu", use_batchnorm=True): |
This file contains hidden or 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
"""References: | |
Simonyan, Karen, and Andrew Zisserman. "Very deep convolutional networks for | |
large-scale image recognition." arXiv preprint arXiv:1409.1556 (2014). | |
""" | |
import mxnet as mx | |
def depthwise_conv(data, kernel, pad, num_filter, name, num_group): | |
conv = mx.symbol.Convolution(data=data, kernel=kernel, pad=pad, | |
num_filter=num_group, name=name+'_depthwise', num_group=num_group) |
This file contains hidden or 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
"""References: | |
Andrew G. Howard, Menglong Zhu, Bo Chen, Dmitry Kalenichenko, Weijun Wang, | |
Tobias Weyand, Marco Andreetto, Hartwig Adam. | |
"MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications." | |
arXiv preprint arXiv:1704.04861 | |
""" | |
import mxnet as mx | |
def depthwise_conv(data, kernel, pad, num_filter, num_group, stride, name): | |
conv = mx.symbol.Convolution(data=data, kernel=kernel, pad=pad, stride=stride, |
This file contains hidden or 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
import mxnet as mx | |
def inflated_layer(data, num_in, num_out, name): | |
assert(num_out % num_in == 0) | |
num_group = num_out / num_in | |
outputs = [] | |
for i in range(num_group): | |
bias = mx.sym.Variable(shape=(1, num_in, 1, 1), | |
name="{}_{}_bias".format(name, i)) | |
outputs.append(mx.sym.broadcast_add(lhs=data, rhs=bias)) |
This file contains hidden or 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
import numpy as np | |
OLD_CLASSES = ['aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus', 'car', | |
'cat', 'chair', 'cow', 'diningtable', 'dog', 'horse', 'motorbike', | |
'person', 'pottedplant', 'sheep', 'sofa', 'train', 'tvmonitor'] | |
NEW_CLASSES = ['bicycle', 'bus', 'car', 'cat', 'cow', 'dog', 'horse', 'motorbike', | |
'person', 'train'] | |
OLD_INDICES = [OLD_CLASSES.index(x) for x in NEW_CLASSES] |
This file contains hidden or 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
import argparse, time | |
import logging | |
logging.basicConfig(level=logging.INFO) | |
fh = logging.FileHandler('training.log') | |
logger = logging.getLogger() | |
logger.addHandler(fh) | |
import mxnet as mx | |
from mxnet import gluon | |
from mxnet.gluon import nn |
This file contains hidden or 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
import mxnet as mx | |
print(mx.__version__) | |
import time | |
import os | |
print('worker:', os.environ.get('MXNET_CPU_WORKER_NTHREADS', 1)) | |
num_batch = 100 | |
batch_size = 32 | |
data_shape = (3, 224, 224) |
This file contains hidden or 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
"""Diagnose script for checking OS/hardware/python/pip/mxnet/network. | |
The output of this script can be a very good hint to issue/problem. | |
""" | |
import platform, subprocess, sys, os | |
import socket, time | |
try: | |
from urllib.request import urlopen | |
from urllib.parse import urlparse | |
except ImportError: | |
from urlparse import urlparse |
This file contains hidden or 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
name: "GoogleNet" | |
layer { | |
name: "data" | |
type: "Input" | |
top: "data" | |
input_param { shape: { dim: 10 dim: 3 dim: 224 dim: 224 } } | |
} | |
layer { | |
name: "conv1/7x7_s2" | |
type: "Convolution" |
OlderNewer