深度學習2 Caffe問題彙總(不定期更細)

2021-07-06 06:21:54 字數 3891 閱讀 2121

#cnn錯誤彙總(遇到就更新)

1.到caffe根目錄下 sudo make pycaffe

2.然後新增caffe路徑

import sys

sudo pip install lmdb
sudo pip install lmdb -i
利用sys新增對應模組的父目錄即可
fatal error: caffe/proto/caffe.pb.h: no such file or directory

解決方法: 用protoc從caffe/src/caffe/proto/caffe.proto生成caffe.pb.h和caffe.pb.cc

li@li:~/caffe/src/caffe/proto$ protoc --cpp_out=/home/li/caffe/include/caffe/ caffe.proto

/usr/bin/ld: caffe_cnn_handler.o: undefined reference to symbol 『_znss4_rep10_m_destroyerksaice@@glibcxx_3.4』

//usr/lib/x86_64-linux-gnu/libstdc++.so.6: error adding symbols: dso missing from command line

解決方法: 是找不到libstdc++.so.6,解決方法是在makefile中加入:

libs += -l/usr/lib/x86_64-linux-gnu -lstdc++

在使用網路**影象時,

prediction = net.predict( [input_image] )

出現: net.image_dims[0] 不是整數情況,

(1).甚至以為np.zeros()出現錯誤!最後發現

原因:net.image_dims

out[25]: '/home/wishchin/caffe-master/python/caffe/imagenet/ilsvrc_2012_mean.npy'

(2).出錯原因:mean_file= caffe_root+"python/caffe/imagenet/ilsvrc_2012_mean.npy"

引用了錯誤的檔案

因此在初始化net的時候不引用meanfile就可以:

net = caffe.classifier(model_file,pretrained,mean_file,channel_swap=(2,1,0 ) , input_scale=255);

修改為:

net = caffe.classifier(model_file,pretrained);

可以執行!

caffe出現了indexerror: tuple index out of range問題;

prediction = net.predict( input_image )#prediction = net.predict( imagefile )

file 「/home/wishchin/caffe-master/python/caffe/classifier.py」, line 69, in predict

inputs[0].shape[2] ),

indexerror: tuple index out of range

原因找出來了:prediction = net.predict( input_image )

忘記 了填入列表,應該修改為:

prediction = net.predict( [input_image ] )

caffe中deploy檔案中的input_shape的dim:10dim:3dim:32dim:32 引數含義

deploy 檔案中的資料層更為

layer }

}hape: 代表含義:

shape

layers

layers

layers 資料及其導數以blobs的形式在層間流動。

#caffe的各層定義

caffe層的定義由2部分組成:層屬性與層引數,例如

name:"conv1"

type:convolution

bottom:"data"

top:"conv1"

convolution_param

}

這段配置檔案的前4行是層屬性,定義了層名稱、層型別以及層連線結構(輸入blob和輸出blob);而後半部分是各種層引數

#blob

blob是用以儲存資料的4維陣列,例如

對於資料:number*channel*height*width

對於卷積權重:output*input*height*width

對於卷積偏置:output*1*1*1

#訓練網路

網路引數的定義也非常方便,可以隨意設定相應引數。

甚至呼叫gpu運算只需要寫一句話:

solver_mode:gpu
不論使用何種框架進行cnns訓練,共有3種資料集

training set:用於訓練網路

validation set:用於訓練時測試網路準確率

test set:用於測試網路訓練完成後的最終正確率

caffe生成的資料分為2種格式:lmdb 和 leveldb

它們都是鍵/值對(key/value pair)嵌入式資料庫管理系統程式設計庫。

雖然 lmdb 的記憶體消耗是 leveldb 的1.1倍,但是 lmdb 的速度比 leveldb快10%至15%,更重要的是lmdb允許多種訓練模型同時讀取同一組資料集。

因此lmdb取代了leveldb成為caffe預設的資料集生成格式。

#預處理影象的leveldb構建

輸入:一批影象和label (2和3)

輸出:leveldb (4)

指令裡包含如下資訊:

conver_imageset (構建leveldb的可執行程式)

train/ (此目錄放處理的jpg或者其他格式的影象)

label.txt (影象檔名及其label資訊)

輸出的leveldb資料夾的名字

cpu/gpu (指定是在cpu上還是在gpu上執行code)

#cnn網路配置檔案

imagenet_solver.prototxt (包含全域性引數的配置的檔案)

imagenet.prototxt (包含訓練網路的配置的檔案)

imagenet_val.prototxt (包含測試網路的配置檔案)

#cnn資料問題

1.編寫程式將image和label轉換成datum格式,並寫入lmdb

2.data layer從lmdb中讀取datum格式的資料,然後轉化成乙個batch

3.從batch裡面把image和label的資料複製到top的記憶體或視訊記憶體

上述的2,3步可以檢視data_layer.cpp,base_data_layer.cpp和base_data_layer.cu這三個檔案,裡面和float_data半點關係都沒有,所以就算你把regression values儲存在datum的float_data裡面,data layer也不會把它讀出來的。

DL學習筆記 2 caffe使用步驟詳解

1 準備路徑 所有在以下兩個資料夾中分別放好 e f study vc2012 dl caffe vs2012 data verifycode train e f study vc2012 dl caffe vs2012 data verifycode test 命令列執行如下命令 下邊的 inpu...

深度學習相關問題彙總

記錄一下學習過程中的問題,防止遺忘 1.訓練集,驗證集和測試集的區別 train,dev,test。訓練集用以訓練模型獲得引數,驗證集用以防止模型對訓練集過擬合,二者是在訓練過程中可以看到的資料集,而測試集理論上我們是不能看到的,用以檢驗模型效果。2.卷積神經網路中,卷積層為了提取特徵值,可以縮小長...

機器學習崗位面試問題彙總 之 深度學習

自己結合網路內容總結,歡迎指正歡迎補充。最新更新 20170624 版本2 增加22 28 1.模式識別 機器學習 深度學習的區別與聯絡 模式識別 過去 程式 機器做智慧型的事 決策樹等 機器學習 熱點領域 給資料 學習資料 深度學習 前言領域 強調模型 2.早年神經網路被淘汰的原因 耗時 區域性最...