【caffe】create_mnist.sh在windows下的解决方案
@tags caffe
在windows下使用caffe时,如果先前没有啥经验,会考虑按照官方文档中的例子跑一跑。比如mnist手写数字识别。
然后就会遇到这个问题:windows下怎么执行
当然,你需要先编译了convert_mnist_data子项目,以及下载了mnist数据集。
ok,要执行的脚本create_mnist.sh是shell语法,不妨转写为python
# create_mnist.py
# by ChrisZZ
import os
import shutil
EXAMPLE='examples\\mnist'
DATA='data\\mnist'
BUILD='Build\\x64\\Release'
BACKEND='lmdb'
print "Createing "+BACKEND+"..."
#rm -rf $EXAMPLE/mnist_train_${BACKEND}
#rm -rf $EXAMPLE/mnist_test_${BACKEND}
path1=EXAMPLE+"\\mnist_train_"+BACKEND
path2=EXAMPLE+"\\mnist_test_"+BACKEND
if os.path.exists(path1):
shutil.rmtree(path1)
if os.path.exists(path2):
shutil.rmtree(path2)
s1=BUILD+"\\convert_mnist_data.exe"
s2=DATA+"\\train-images-idx3-ubyte"
s3=DATA+"\\train-labels-idx1-ubyte"
s4=EXAMPLE+"\\mnist_train_"+BACKEND
s5="--backend="+BACKEND
cmd=s1+" "+s2+" "+s3+" "+s4+" "+s5
print cmd
os.system(cmd)
t1=BUILD+"\\convert_mnist_data.exe"
t2=DATA+"\\t10k-images-idx3-ubyte"
t3=DATA+"\\t10k-labels-idx1-ubyte"
t4=EXAMPLE+"\\mnist_test_"+BACKEND
t5="--backend="+BACKEND
cmd=t1+" "+t2+" "+t3+" "+t4+" "+t5
print "cmd2="+cmd
os.system(cmd)
然后,新开一个cmd控制台,cd到caffe根目录,执行:
python examples\mnist\create_mnist.py
Greatness is never a given, it must be earned.