Skip to content

Commit

Permalink
[OP] 3d conv + 3d pool (#2585)
Browse files Browse the repository at this point in the history
* cudnn 3d conv & 3d pooling
  • Loading branch information
antinucleon authored Jul 8, 2016
1 parent 70fe575 commit 5532511
Show file tree
Hide file tree
Showing 27 changed files with 692 additions and 314 deletions.
20 changes: 10 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ endif
CFLAGS += -I$(ROOTDIR)/mshadow/ -I$(ROOTDIR)/dmlc-core/include -fPIC -Iinclude $(MSHADOW_CFLAGS)
LDFLAGS = -pthread $(MSHADOW_LDFLAGS) $(DMLC_LDFLAGS)
ifeq ($(DEBUG), 1)
NVCCFLAGS = -Xcompiler -std=c++98 -D_FORCE_INLINES -g -G -O0 -ccbin $(CXX) $(MSHADOW_NVCCFLAGS)
NVCCFLAGS = -std=c++11 -Xcompiler -D_FORCE_INLINES -g -G -O0 -ccbin $(CXX) $(MSHADOW_NVCCFLAGS)
else
NVCCFLAGS = -Xcompiler -std=c++98 -D_FORCE_INLINES -g -O3 -ccbin $(CXX) $(MSHADOW_NVCCFLAGS)
NVCCFLAGS = -std=c++11 -Xcompiler -D_FORCE_INLINES -g -O3 -ccbin $(CXX) $(MSHADOW_NVCCFLAGS)
endif

ifndef LINT_LANG
Expand Down Expand Up @@ -149,8 +149,8 @@ endif

build/src/%.o: src/%.cc
@mkdir -p $(@D)
$(CXX) -std=c++0x $(CFLAGS) -MM -MT build/src/$*.o $< >build/src/$*.d
$(CXX) -std=c++0x -c $(CFLAGS) -c $< -o $@
$(CXX) -std=c++11 $(CFLAGS) -MM -MT build/src/$*.o $< >build/src/$*.d
$(CXX) -std=c++11 -c $(CFLAGS) -c $< -o $@

build/src/%_gpu.o: src/%.cu
@mkdir -p $(@D)
Expand All @@ -159,20 +159,20 @@ build/src/%_gpu.o: src/%.cu

build/plugin/%.o: plugin/%.cc
@mkdir -p $(@D)
$(CXX) -std=c++0x $(CFLAGS) -MM -MT build/plugin/$*.o $< >build/plugin/$*.d
$(CXX) -std=c++0x -c $(CFLAGS) -c $< -o $@
$(CXX) -std=c++11 $(CFLAGS) -MM -MT build/plugin/$*.o $< >build/plugin/$*.d
$(CXX) -std=c++11 -c $(CFLAGS) -c $< -o $@

# A nvcc bug cause it to generate "generic/xxx.h" dependencies from torch headers.
# Use CXX to generate dependency instead.
build/plugin/%_gpu.o: plugin/%.cu
@mkdir -p $(@D)
$(CXX) -std=c++0x $(CFLAGS) -MM -MT build/plugin/$*_gpu.o $< >build/plugin/$*_gpu.d
$(CXX) -std=c++11 $(CFLAGS) -MM -MT build/plugin/$*_gpu.o $< >build/plugin/$*_gpu.d
$(NVCC) -c -o $@ $(NVCCFLAGS) -Xcompiler "$(CFLAGS)" $<

$(EXTRA_OPERATORS)/build/%.o: $(EXTRA_OPERATORS)/%.cc
@mkdir -p $(@D)
$(CXX) -std=c++0x $(CFLAGS) -Isrc/operator -MM -MT $(EXTRA_OPERATORS)/build/$*.o $< >$(EXTRA_OPERATORS)/build/$*.d
$(CXX) -std=c++0x -c $(CFLAGS) -Isrc/operator -c $< -o $@
$(CXX) -std=c++11 $(CFLAGS) -Isrc/operator -MM -MT $(EXTRA_OPERATORS)/build/$*.o $< >$(EXTRA_OPERATORS)/build/$*.d
$(CXX) -std=c++11 -c $(CFLAGS) -Isrc/operator -c $< -o $@

$(EXTRA_OPERATORS)/build/%_gpu.o: $(EXTRA_OPERATORS)/%.cu
@mkdir -p $(@D)
Expand Down Expand Up @@ -200,7 +200,7 @@ bin/im2rec: tools/im2rec.cc $(ALL_DEP)

$(BIN) :
@mkdir -p $(@D)
$(CXX) $(CFLAGS) -std=c++0x -o $@ $(filter %.cpp %.o %.c %.a %.cc, $^) $(LDFLAGS)
$(CXX) $(CFLAGS) -std=c++11 -o $@ $(filter %.cpp %.o %.c %.a %.cc, $^) $(LDFLAGS)

include tests/cpp/unittest.mk

Expand Down
4 changes: 2 additions & 2 deletions R-package/vignettes/classifyRealImageWithPretrainedModel.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ algorithm can do is to classify real world images.
In this example we will show how to use a pretrained Inception-BatchNorm Network to predict the class of
real world image. The network architecture is decribed in [1].

The pre-trained Inception-BatchNorm network is able to be downloaded from [this link](http://webdocs.cs.ualberta.ca/~bx3/data/Inception.zip)
The pre-trained Inception-BatchNorm network is able to be downloaded from [this link](http://data.dmlc.ml/mxnet/data/Inception.zip)
This model gives the recent state-of-art prediction accuracy on image net dataset.

Preface
Expand Down Expand Up @@ -69,7 +69,7 @@ preproc.image <- function(im, mean.image) {
shape <- dim(im)
short.edge <- min(shape[1:2])
xx <- floor((shape[1] - short.edge) / 2)
yy <- floor((shape[2] - short.edge) / 2)
yy <- floor((shape[2] - short.edge) / 2)
croped <- crop.borders(im, xx, yy)
# resize to 224 x 224, needed by input of the model.
resized <- resize(croped, 224, 224)
Expand Down
2 changes: 1 addition & 1 deletion docs/how_to/cloud.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ There are several ways to upload local data to S3. One simple way is using
[s3cmd](http://s3tools.org/s3cmd). For example:

```bash
wget http://webdocs.cs.ualberta.ca/~bx3/data/mnist.zip
wget http://data.dmlc.ml/mxnet/data/mnist.zip
unzip mnist.zip && s3cmd put t*-ubyte s3://dmlc/mnist/
```

Expand Down
4 changes: 2 additions & 2 deletions docs/packages/r/classifyRealImageWithPretrainedModel.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ algorithm can do is to classify real world images.
In this example we will show how to use a pretrained Inception-BatchNorm Network to predict the class of
real world image. The network architecture is decribed in [1].

The pre-trained Inception-BatchNorm network is able to be downloaded from [this link](http://webdocs.cs.ualberta.ca/~bx3/data/Inception.zip)
The pre-trained Inception-BatchNorm network is able to be downloaded from [this link](http://data.dmlc.ml/mxnet/data/Inception.zip)
This model gives the recent state-of-art prediction accuracy on image net dataset.

Preface
Expand Down Expand Up @@ -112,7 +112,7 @@ preproc.image <- function(im, mean.image) {
shape <- dim(im)
short.edge <- min(shape[1:2])
xx <- floor((shape[1] - short.edge) / 2)
yy <- floor((shape[2] - short.edge) / 2)
yy <- floor((shape[2] - short.edge) / 2)
croped <- crop.borders(im, xx, yy)
# resize to 224 x 224, needed by input of the model.
resized <- resize(croped, 224, 224)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def DownsampleFactory(data, ch_3x3, mirror_attr):
# conv 3x3
conv = ConvFactory(data=data, kernel=(3, 3), stride=(2, 2), num_filter=ch_3x3, pad=(1, 1), mirror_attr=mirror_attr)
# pool
pool = mx.symbol.Pooling(data=data, kernel=(3, 3), stride=(2, 2), pool_type='max', attr=mirror_attr)
pool = mx.symbol.Pooling(data=data, kernel=(3, 3), stride=(2, 2), pad=(1, 1), pool_type='max', attr=mirror_attr)
# concat
concat = mx.symbol.Concat(*[conv, pool])
return concat
Expand Down
2 changes: 1 addition & 1 deletion example/image-classification/symbol_inception-bn-full.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def InceptionFactoryB(data, num_3x3red, num_3x3, num_d3x3red, num_d3x3, name):
cd3x3 = ConvFactory(data=cd3x3r, num_filter=num_d3x3, kernel=(3, 3), pad=(1, 1), stride=(1, 1), name=('%s_double_3x3_0' % name))
cd3x3 = ConvFactory(data=cd3x3, num_filter=num_d3x3, kernel=(3, 3), pad=(1, 1), stride=(2, 2), name=('%s_double_3x3_1' % name))
# pool + proj
pooling = mx.symbol.Pooling(data=data, kernel=(3, 3), stride=(2, 2), pool_type="max", name=('max_pool_%s_pool' % name))
pooling = mx.symbol.Pooling(data=data, kernel=(3, 3), stride=(2, 2), pad=(1, 1), pool_type="max", name=('max_pool_%s_pool' % name))
# concat
concat = mx.symbol.Concat(*[c3x3, cd3x3, pooling], name='ch_concat_%s_chconcat' % name)
return concat
Expand Down
2 changes: 1 addition & 1 deletion example/image-classification/symbol_inception-bn.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def InceptionFactoryB(data, num_3x3red, num_3x3, num_d3x3red, num_d3x3, name):
cd3x3 = ConvFactory(data=cd3x3r, num_filter=num_d3x3, kernel=(3, 3), pad=(1, 1), stride=(1, 1), name=('%s_double_3x3_0' % name))
cd3x3 = ConvFactory(data=cd3x3, num_filter=num_d3x3, kernel=(3, 3), pad=(1, 1), stride=(2, 2), name=('%s_double_3x3_1' % name))
# pool + proj
pooling = mx.symbol.Pooling(data=data, kernel=(3, 3), stride=(2, 2), pool_type="max", name=('max_pool_%s_pool' % name))
pooling = mx.symbol.Pooling(data=data, kernel=(3, 3), stride=(2, 2), pad=(1, 1), pool_type="max", name=('max_pool_%s_pool' % name))
# concat
concat = mx.symbol.Concat(*[c3x3, cd3x3, pooling], name='ch_concat_%s_chconcat' % name)
return concat
Expand Down
2 changes: 1 addition & 1 deletion example/image-classification/train_cifar10.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def _download(data_dir):
os.chdir(data_dir)
if (not os.path.exists('train.rec')) or \
(not os.path.exists('test.rec')) :
os.system("wget http://webdocs.cs.ualberta.ca/~bx3/data/cifar10.zip")
os.system("wget http://data.dmlc.ml/mxnet/data/cifar10.zip")
os.system("unzip -u cifar10.zip")
os.system("mv cifar/* .; rm -rf cifar; rm cifar10.zip")
os.chdir("..")
Expand Down
4 changes: 2 additions & 2 deletions example/image-classification/train_cifar10_mirroring.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# documentation could be expected when this feature is mature.
#
# When mirroring is turned on and set properly, we could expect smaller memory
# consumption with slightly slower computation speed (due to extra forward
# consumption with slightly slower computation speed (due to extra forward
# steps). We are not including a sample running log here, as this test case
# is only a functionality test. The using of pycuda GPU memory query is also
# not very good way of measuring the memory usage here.
Expand Down Expand Up @@ -55,7 +55,7 @@ def _download(data_dir):
os.chdir(data_dir)
if (not os.path.exists('train.rec')) or \
(not os.path.exists('test.rec')) :
os.system("wget http://webdocs.cs.ualberta.ca/~bx3/data/cifar10.zip")
os.system("wget http://data.dmlc.ml/mxnet/data/data/cifar10.zip")
os.system("unzip -u cifar10.zip")
os.system("mv cifar/* .; rm -rf cifar; rm cifar10.zip")
os.chdir("..")
Expand Down
2 changes: 1 addition & 1 deletion example/image-classification/train_cifar10_resnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def _download(data_dir):
os.chdir(data_dir)
if (not os.path.exists('train.rec')) or \
(not os.path.exists('test.rec')):
os.system('wget http://webdocs.cs.ualberta.ca/~bx3/data/cifar10.zip')
os.system('wget http://data.dmlc.ml/mxnet/data/cifar10.zip')
os.system('unzip -u cifar10.zip')
os.system('mv cifar/* .; rm -rf cifar; rm cifar10.zip')
os.chdir('..')
Expand Down
6 changes: 3 additions & 3 deletions example/image-classification/train_mnist.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ require(mxnet)
download_ <- function(data_dir) {
dir.create(data_dir, showWarnings = FALSE)
setwd(data_dir)
if ((!file.exists('train-images-idx3-ubyte')) ||
if ((!file.exists('train-images-idx3-ubyte')) ||
(!file.exists('train-labels-idx1-ubyte')) ||
(!file.exists('t10k-images-idx3-ubyte')) ||
(!file.exists('t10k-labels-idx1-ubyte'))) {
download.file(url='http://webdocs.cs.ualberta.ca/~bx3/data/mnist.zip',
download.file(url='http://data.dmlc.ml/mxnet/data/mnist.zip',
destfile='mnist.zip', method='wget')
unzip("mnist.zip")
file.remove("mnist.zip")
Expand Down Expand Up @@ -83,7 +83,7 @@ get_iterator <- function(data_shape) {
}

parse_args <- function() {
parser <- ArgumentParser(description='train an image classifer on mnist')
parser <- ArgumentParser(description='train an image classifer on mnist')
parser$add_argument('--network', type='character', default='mlp',
choices = c('mlp', 'lenet'),
help = 'the cnn to use')
Expand Down
2 changes: 1 addition & 1 deletion example/image-classification/train_mnist.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def _download(data_dir):
(not os.path.exists('train-labels-idx1-ubyte')) or \
(not os.path.exists('t10k-images-idx3-ubyte')) or \
(not os.path.exists('t10k-labels-idx1-ubyte')):
os.system("wget http://webdocs.cs.ualberta.ca/~bx3/data/mnist.zip")
os.system("wget http://data.dmlc.ml/mxnet/data/mnist.zip")
os.system("unzip -u mnist.zip; rm mnist.zip")
os.chdir("..")

Expand Down
2 changes: 1 addition & 1 deletion example/module/train_cifar10.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def _download(data_dir):
os.chdir(data_dir)
if (not os.path.exists('train.rec')) or \
(not os.path.exists('test.rec')) :
os.system("wget http://webdocs.cs.ualberta.ca/~bx3/data/cifar10.zip")
os.system("wget http://data.dmlc.ml/mxnet/data/cifar10.zip")
os.system("unzip -u cifar10.zip")
os.system("mv cifar/* .; rm -rf cifar; rm cifar10.zip")
os.chdir(cwd)
Expand Down
2 changes: 1 addition & 1 deletion example/notebooks/predict-with-pretrained-model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"For network structure, you can visualize it in [Composite Symbol Demo](composite_symbol.ipynb)\n",
"\n",
"The pre-trained Inception-BatchNorm network is able to be downloaded from:\n",
"[http://webdocs.cs.ualberta.ca/~bx3/data/Inception.zip](http://webdocs.cs.ualberta.ca/~bx3/data/Inception.zip)\n",
"[http://data.dmlc.ml/mxnet/data/Inception.zip](http://data.dmlc.ml/mxnet/data/Inception.zip)\n",
"This model achieves Top-1 Accuracy: 70% and Top-5 Accuracy: 89.9%\n",
"\n",
"Note: This network is trained by using very simple augmentation (random flip + random crop). We will release model with a little bit more augmentation (which achieves better validation score)"
Expand Down
6 changes: 3 additions & 3 deletions example/rnn/char-rnn.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"<img src=\"http://webdocs.cs.ualberta.ca/~bx3/char-rnn_1.png\">\n"
"<img src=\"http://data.dmlc.ml/mxnet/data/char-rnn_1.png\">\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<img src=\"http://webdocs.cs.ualberta.ca/~bx3/char-rnn_2.png\">"
"<img src=\"http://data.dmlc.ml/mxnet/data/char-rnn_2.png\">"
]
},
{
Expand Down Expand Up @@ -145,7 +145,7 @@
],
"source": [
"import os\n",
"data_url = \"http://webdocs.cs.ualberta.ca/~bx3/lab_data.zip\"\n",
"data_url = \"http://data.dmlc.ml/mxnet/data/lab_data.zip\"\n",
"os.system(\"wget %s\" % data_url)\n",
"os.system(\"unzip -o lab_data.zip\")"
]
Expand Down
4 changes: 2 additions & 2 deletions scala-package/core/scripts/get_cifar_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ fi

cifar_data_path="./data/cifar10.zip"
if [ ! -f "$cifar_data_path" ]; then
wget http://webdocs.cs.ualberta.ca/~bx3/data/cifar10.zip -P $data_path
wget http://data.dmlc.ml/mxnet/data/cifar10.zip -P $data_path
cd $data_path
unzip -u cifar10.zip
fi
fi
2 changes: 1 addition & 1 deletion scala-package/core/scripts/get_mnist_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ fi

mnist_data_path="./data/mnist.zip"
if [ ! -f "$mnist_data_path" ]; then
wget http://webdocs.cs.ualberta.ca/~bx3/data/mnist.zip -P $data_path
wget http://data.dmlc.ml/mxnet/data/mnist.zip -P $data_path
cd $data_path
unzip -u mnist.zip
fi
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,6 @@ class ConvSuite extends FunSuite with BeforeAndAfterAll {
}
val acc = numCorrect.toFloat / numInst
logger.info(s"Final accuracy = $acc")
assert(acc > 0.96)
assert(acc > 0.95)
}
}
Loading

0 comments on commit 5532511

Please sign in to comment.