网络结构可视化步骤

来源:互联网 发布:淘宝网首页制作 编辑:程序博客网 时间:2024/06/05 20:18
name: "LeNet"
layer {
  name: "mnist"
  type: "Data"
  top: "data"
  top: "label"
  include {
    phase: TRAIN
  }
  transform_param {
    scale: 0.00390625
  }
  data_param {
    source: "examples/mnist/mnist_train_lmdb"
    batch_size: 64
    backend: LMDB
  }
}
layer {
  name: "mnist"
  type: "Data"
  top: "data"
  top: "label"
  include {
    phase: TEST
  }
  transform_param {
    scale: 0.00390625
  }
  data_param {
    source: "examples/mnist/mnist_test_lmdb"
    batch_size: 100
    backend: LMDB
  }
}
layer {
  name: "conv1"
  type: "Convolution"
  bottom: "data"
  top: "conv1"
  param {
    lr_mult: 1
  }
  param {
    lr_mult: 2
  }
  convolution_param {
    num_output: 20
    kernel_size: 5
    stride: 1
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
    }
  }
}
layer {
  name: "pool1"
  type: "Pooling"
  bottom: "conv1"
  top: "pool1"
  pooling_param {
    pool: MAX
    kernel_size: 2
    stride: 2
  }
}
layer {
  name: "conv2"
  type: "Convolution"
  bottom: "pool1"
  top: "conv2"
  param {
    lr_mult: 1
  }
  param {
    lr_mult: 2
  }
  convolution_param {
    num_output: 50
    kernel_size: 5
    stride: 1
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
    }
  }
}
layer {
  name: "pool2"
  type: "Pooling"
  bottom: "conv2"
  top: "pool2"
  pooling_param {
    pool: MAX
    kernel_size: 2
    stride: 2
  }
}
layer {
  name: "ip1"
  type: "InnerProduct"
  bottom: "pool2"
  top: "ip1"
  param {
    lr_mult: 1
  }
  param {
    lr_mult: 2
  }
  inner_product_param {
    num_output: 500
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
    }
  }
}
layer {
  name: "relu1"
  type: "ReLU"
  bottom: "ip1"
  top: "ip1"
}
layer {
  name: "ip2"
  type: "InnerProduct"
  bottom: "ip1"
  top: "ip2"
  param {
    lr_mult: 1
  }
  param {
    lr_mult: 2
  }
  inner_product_param {
    num_output: 10
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
    }
  }
}
layer {
  name: "accuracy"
  type: "Accuracy"
  bottom: "ip2"
  bottom: "label"
  top: "accuracy"
  include {
    phase: TEST
  }
}
layer {
  name: "loss"
  type: "SoftmaxWithLoss"
  bottom: "ip2"
  bottom: "label"
  top: "loss"

}

如何直观地的看这个结构呢?

网络结构可视化:

ImportError: No module named _caffe出现这种问题后怎么解决?
1.>>> exit()--目的:退出到caffe路径下
2.cd ${CAFFE_ROOT}下输入: make pycaffe
3.>>> import caffe--目的:验证错误是否还存在
4.>>> exit()--目的:退出到caffe路径下
5.zhangxiangwei@zxw-OptiPlex-3046:~/Documents/caffe-master/python$ python draw_net.py ../models/bvlc_reference_caffenet/train_val.prototxt vis.png


操作步骤如下PS:>>> import caffe
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/zhangxiangwei/Documents/caffe-master/python/caffe/__init__.py", line 1, in <module>
    from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver, NCCL, Timer
  File "/home/zhangxiangwei/Documents/caffe-master/python/caffe/pycaffe.py", line 13, in <module>
    from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \
ImportError: No module named _caffe
>>> exit()
zhangxiangwei@zxw-OptiPlex-3046:~/Documents/caffe-master$ make pycaffe
CXX/LD -o python/caffe/_caffe.so python/caffe/_caffe.cpp
touch python/caffe/proto/__init__.py
PROTOC (python) src/caffe/proto/caffe.proto
zhangxiangwei@zxw-OptiPlex-3046:~/Documents/caffe-master$ python
Python 2.7.12 (default, Nov 19 2016, 06:48:10)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import caffe
>>> exit()
zhangxiangwei@zxw-OptiPlex-3046:~/Documents/caffe-master$ cd python/
zhangxiangwei@zxw-OptiPlex-3046:~/Documents/caffe-master/python$ python draw_net.py ../models/bvlc_reference_caffenet/train_val.prototxt vis.png
Drawing net to vis.png



命令行命令:

    sudo python ./python/draw_net.py  ./examples/mnist/lenet_train_test.prototxt  ./examples/mnist/lenet_train_test.jpeg 
或者

sudo python ./python/draw_net.py --rankdir BT ./examples/mnist/lenet_train_test.prototxt  ./examples/mnist/lenet_train_test.jpeg


原创粉丝点击