文章出處

@tags caffe

在windows下使用caffe時,如果先前沒有啥經驗,會考慮按照官方文檔中的例子跑一跑。比如mnist手寫數字識別。

然后就會遇到這個問題:windows下怎么執行/examples/mnist/create_mnist.sh呢?

當然,你需要先編譯了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


文章列表


不含病毒。www.avast.com
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 大師兄 的頭像
    大師兄

    IT工程師數位筆記本

    大師兄 發表在 痞客邦 留言(0) 人氣()