Caffe:LSTM使用

name: "BasicLstm"

layer {
  name: "data"
  type: "HDF5Data"
  top: "data" //输入数据
  top: "cont" //数据切分(不是1就是0)
  top: "label"//对应的标签
  include {
    phase: TRAIN
  }
  hdf5_data_param {
    source: "./path_to_txt.txt"
    batch_size: 2000
  }
}


layer {
  name: "lstm1"
  type: "LSTM"
  bottom: "data"
  bottom: "cont"
  top: "lstm1"
  recurrent_param {
    num_output: 5 //LSTM1输出的对应维度
    weight_filler {
      type: "uniform"
      min: -0.08
      max: 0.08
    }
    bias_filler {
      type: "constant"
      value: 0
    }
  }
}

layer {
  name: "lstm2"
  type: "LSTM"
  bottom: "lstm1" 
  bottom: "cont"
  top: "lstm2"
  recurrent_param {
    num_output: 4    //LSTM2输出对应的维度
    weight_filler {
      type: "uniform"
      min: -0.08
      max: 0.08
    }
    bias_filler {
      type: "constant"
      value: 0
    }
  }
}


layer {
  name: "predict"
  type: "InnerProduct"
  bottom: "lstm2"
  top: "predict"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  inner_product_param {
    num_output: 39    //对应的输出维度用于分类
    weight_filler {
      type: "gaussian"
      std: 0.01
    }
    bias_filler {
      type: "constant"
      value: 0
    }
    axis: 2
  }
}



layer {
  name: "softmax_loss"
  type: "SoftmaxWithLoss" //softmax分类
  bottom: "predict"
  bottom: "label"
  top: "loss"
  loss_weight: 20
  softmax_param {
    axis: 2
  }
  loss_param {
    ignore_label: -1 //忽略标签为-1的数据
  }
}

                                                            

值得注意的是:这里的数据会被直接分成三个数据流方向



  • 2
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 9
    评论
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值