zoukankan      html  css  js  c++  java
  • caffe Python API 之 数据输入层(Data,ImageData,HDF5Data)

    1 import sys
    2 sys.path.append('/projects/caffe-ssd/python')
    3 import caffe
    4 net = caffe.NetSpec()

    一、ImageData Layer

    net.data ,net.label = caffe.layers.ImageData(
    name="InputData" source
    ="train.txt", batch_size=32, new_width=48, new_height=48, ntop=2, is_color=True, shuffle=True, root_folder='/', transform_param=dict(crop_size=40,mirror=True)) print str(net.to_proto()) 输出: layer { name: "InputData" type: "ImageData" top: "data" top: "label" transform_param { mirror: true crop_size: 40 } image_data_param { source: "train.txt" batch_size: 32 shuffle: true new_height: 48 new_ 48 is_color: true root_folder: "/" } }

    二、Data Layer (lmdb/leveldb)

    net.data, net.label = caffe.layers.Data(
        name="InputData",
        source="train_lmdb",
        backend = caffe.params.Data.LMDB,
        batch_size=32,
        ntop=2,
    include=dict(phase=caffe.TRAIN) transform_param
    =dict( crop_size=227, mean_value=[104, 117, 123], mirror=True ) ) 输出: layer { name: "InputData" type: "Data" top: "data" top: "label" transform_param { mirror: true crop_size: 227 mean_value: 104 mean_value: 117 mean_value: 123 } data_param { source: "train_lmdb" batch_size: 32 backend: LMDB } }

    三、HDF5Data Layer

    net.data, net.label = caffe.layers.HDF5Data(
                name="InputData",
                source='./training_data_paths.txt',
                batch_size=64,
                include=dict(phase=caffe.TRAIN),
                ntop=2
                )
    
    输出:
    layer {
      name: "InputData"
      type: "HDF5Data"
      top: "data"
      top: "label"
      include {
        phase: TRAIN
      }
      hdf5_data_param {
        source: "./training_data_paths.txt"
        batch_size: 64
      }
    }
    
    另有:
    image = L.HDF5Data( 
        hdf5_data_param={ 'source': './training_data_paths.txt', 'batch_size': 64 },
         include={'phase': caffe.TRAIN } 
    )
  • 相关阅读:
    mysql增加字段,修改字段,增加索引等语句
    php获取post参数的几种方式
    微信小程序开发注意事项
    jQuery的deferred对象详解
    jquery.pagination.js的使用
    js实现一键复制
    PHP读取文件内容的五种方式
    3.3 模块的搜索路径
    3.2 py文件的两种功能
    3.1 模块的定义与分类,import,from...import
  • 原文地址:https://www.cnblogs.com/houjun/p/9909764.html
Copyright © 2011-2022 走看看