国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 開(kāi)發(fā)設(shè)計(jì) > 正文

利用caffe訓(xùn)練網(wǎng)絡(luò)的步驟

2019-11-08 00:35:37
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

0:將圖片設(shè)置好標(biāo)號(hào)(從0開(kāi)始的連續(xù)自然數(shù))

1:首先需要將圖片轉(zhuǎn)換成需要的數(shù)據(jù)格式

#!/usr/bin/env sh# Create the imagenet lmdb inputs# N.B. set the path to the imagenet train + val data dirs# EXAMPLE=examples/imagenet# DATA=data/ilsvrc12TOOLS=build/tools# TRAIN_DATA_ROOT=/path/to/imagenet/train/# VAL_DATA_ROOT=/path/to/imagenet/val/TRAIN_DATA_ROOT=/examples/jb/train/VAL_DATA_ROOT=/examples/jb//val/LABEL_ROOT=/examples/jbSAVE_DATA_ROOT=/examples/jb/data# Set RESIZE=true to resize the images to 256x256. Leave as false if images have# already been resized using another tool.# RESIZE=falseRESIZE=trueif $RESIZE; then  RESIZE_HEIGHT=32  RESIZE_WIDTH=32else  RESIZE_HEIGHT=0  RESIZE_WIDTH=0fiif [ ! -d "$TRAIN_DATA_ROOT" ]; then  echo "Error: TRAIN_DATA_ROOT is not a path to a directory: $TRAIN_DATA_ROOT"  echo "Set the TRAIN_DATA_ROOT variable in create_imagenet.sh to the path" /       "where the ImageNet training data is stored."  exit 1fiif [ ! -d "$VAL_DATA_ROOT" ]; then  echo "Error: VAL_DATA_ROOT is not a path to a directory: $VAL_DATA_ROOT"  echo "Set the VAL_DATA_ROOT variable in create_imagenet.sh to the path" /       "where the ImageNet validation data is stored."  exit 1fiecho "Creating train lmdb..."GLOG_logtostderr=1 $TOOLS/convert_imageset /    --resize_height=$RESIZE_HEIGHT /    --resize_width=$RESIZE_WIDTH /    --shuffle /    $TRAIN_DATA_ROOT /    $LABEL_ROOT/train.txt /    $SAVE_DATA_ROOT/train_lmdbecho "Creating val lmdb..."GLOG_logtostderr=1 $TOOLS/convert_imageset /    --resize_height=$RESIZE_HEIGHT /    --resize_width=$RESIZE_WIDTH /    --shuffle /    $VAL_DATA_ROOT /    $LABEL_ROOT/val.txt /    $SAVE_DATA_ROOT/val_lmdbecho "Done."2:計(jì)算訓(xùn)練樣本的均值(彩色圖時(shí)需要)

#!/usr/bin/env sh# Compute the mean image from the imagenet training leveldb# N.B. this is available in data/ilsvrc12./build/tools/compute_image_mean examples/jb/data/train_lmdb /  examples/jb/data/image_mean.binaryPRotoecho "Done."3:定義好網(wǎng)絡(luò)的結(jié)構(gòu)

name: "AlexNet"layers {  name: "data"  type: DATA  top: "data"  top: "label"  data_param {    source: "examples/jb/data/train_lmdb"    backend: LMDB    batch_size: 256  }  transform_param {    crop_size: 227    mean_file: "examples/jb/data/image_mean.binaryproto"    mirror: true  }  include: { phase: TRAIN }}layers {  name: "data"  type: DATA  top: "data"  top: "label"  data_param {    source: "examples/jb/data/val_lmdb"    backend: LMDB    batch_size: 50  }  transform_param {    crop_size: 227    mean_file: "examples/jb/data/image_mean.binaryproto"    mirror: false  }  include: { phase: TEST }}layers {  name: "conv1"  type: CONVOLUTION  bottom: "data"  top: "conv1"  blobs_lr: 1  blobs_lr: 2  weight_decay: 1  weight_decay: 0  convolution_param {    num_output: 64    kernel_size: 5    stride: 1    weight_filler {      type: "gaussian"      std: 0.01    }    bias_filler {      type: "constant"      value: 0    }  }}layers {  name: "relu1"  type: RELU  bottom: "conv1"  top: "conv1"}layers {  name: "norm1"  type: LRN  bottom: "conv1"  top: "norm1"  lrn_param {    local_size: 9    alpha: 0.0001    beta: 0.75  }}layers {  name: "pool1"  type: POOLING  bottom: "norm1"  top: "pool1"  pooling_param {    pool: MAX    kernel_size: 3    stride: 2  }}layers {  name: "conv2"  type: CONVOLUTION  bottom: "pool1"  top: "conv2"  blobs_lr: 1  blobs_lr: 2  weight_decay: 1  weight_decay: 0  convolution_param {    num_output: 64    pad: 2    kernel_size: 5    group: 2    weight_filler {      type: "gaussian"      std: 0.01    }    bias_filler {      type: "constant"      value: 0.1    }  }}layers {  name: "relu2"  type: RELU  bottom: "conv2"  top: "conv2"}layers {  name: "norm2"  type: LRN  bottom: "conv2"  top: "norm2"  lrn_param {    local_size: 9
#!/usr/bin/env shecho "begin to train the net!"./build/tools/caffe train /    --solver=examples/jb/solver.prototxtecho "the net is finish"alpha: 0.0001 beta: 0.75 }}layers { name: "pool2" type: POOLING bottom: "norm2" top: "pool2" pooling_param { pool: MAX kernel_size: 3 stride: 2 }}layers { name: "conv3" type: CONVOLUTION bottom: "pool2" top: "conv3" blobs_lr: 1 blobs_lr: 2 weight_decay: 1 weight_decay: 0 convolution_param { num_output: 64 pad: 1
#!/usr/bin/env shecho "begin to train the net!"./build/tools/caffe train /    --solver=examples/jb/solver.prototxtecho "the net is finish"kernel_size: 3 weight_filler { type: "gaussian" std: 0.01 } bias_filler { type: "constant" value: 0 } }}layers { name: "relu3" type: RELU bottom: "conv3" top: "conv3"}layers { name: "conv4" type: CONVOLUTION bottom: "conv3" top: "conv4" blobs_lr: 1 blobs_lr: 2 weight_decay: 1 weight_decay: 0 convolution_param { num_output: 32 pad: 1 kernel_size: 3 group: 2 weight_filler { type: "gaussian" std: 0.01 } bias_filler { type: "constant" value: 0.1 } }}layers { name: "relu4" type: RELU bottom: "conv4" top: "conv4"}layers { name: "fc6" type: INNER_PRODUCT bottom: "conv4" top: "fc6" blobs_lr: 1 blobs_lr: 2 weight_decay: 1 weight_decay: 0 inner_product_param { num_output: 43 weight_filler { type: "gaussian" std: 0.005 } bias_filler { type: "constant" value: 0.1 } }}layers { name: "relu6" type: RELU bottom: "fc6" top: "fc6"}layers { name: "accuracy" type: ACCURACY bottom: "fc6" bottom: "label" top: "accuracy" include: { phase: TEST }}layers { name: "loss" type: SOFTMAX_LOSS bottom: "fc6" bottom: "label" top: "loss"}

4:定義好sover文件

net: "examples/jb/train_val.prototxt"test_iter: 1000test_interval: 1000base_lr: 0.01lr_policy: "step"gamma: 0.1stepsize: 100000display: 20max_iter: 450000momentum: 0.9weight_decay: 0.0005snapshot: 10000snapshot_prefix: "examples/jb/models/caffe_alexnet_train"solver_mode: GPU5:訓(xùn)練網(wǎng)絡(luò)

#!/usr/bin/env shecho "begin to train the net!"./build/tools/caffe train /    --solver=examples/jb/solver.prototxtecho "the net is finish"

這樣就完成了網(wǎng)絡(luò)的整個(gè)訓(xùn)練過(guò)程,之后可以利用這個(gè)模型進(jìn)行測(cè)試。

參考博客:http://blog.csdn.net/hebustkyl/article/details/45534219


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 盐边县| 周宁县| 康乐县| 东丰县| 彭阳县| 大田县| 奉化市| 屏山县| 正镶白旗| 萨迦县| 油尖旺区| 巴林左旗| 防城港市| 洮南市| 安新县| 读书| 库尔勒市| 宝坻区| 马关县| 淄博市| 昌平区| 望奎县| 航空| 抚松县| 宜丰县| 玉门市| 建德市| 弥勒县| 衡东县| 赤水市| 青铜峡市| 延安市| 罗平县| 拜城县| 社旗县| 大安市| 淮北市| 隆安县| 都江堰市| 家居| 枣阳市|