Layers that have two bottoms, two tops in prototxt file [New to caffe]

204 views
Skip to first unread message

GATETE Elie MAGAMBO

unread,
May 10, 2017, 3:33:26 AM5/10/17
to Caffe Users

i keep seeing some layers in caffe that has two bottoms(source) or tops(destination) in Neural networks architecture,for example this is Segnet data layer that has two tops ,data and label given from the same source file on the same line img1.png lagel1.png

    layer {
  name: "data"
  type: "Data"
  top: "data"
  top: "label"
  dense_image_data_param {
    source: "train.txt" # train file format img1.png img1.png (data and label)
    batch_size: 1               
    shuffle: true
  }

and these from Pascal-object-detection-fc

layer {
  name: "loss"
  type: "SoftmaxWithLoss"
  bottom: "fc8_pascal"
  bottom: "label"
}
layer {
  name: "accuracy"
  type: "Accuracy"
  bottom: "fc8_pascal"
  bottom: "label"
  top: "accuracy"
  include {
    phase: TEST
  }
}

that have two bottoms.

I would appreciate if someone could explain the implication of having those into one layer and why not have different layer for each. Another thing,if a layer reference its self as top/bottom, does it mean it does not do forward/backward calculations?

Przemek D

unread,
May 10, 2017, 4:33:13 AM5/10/17
to Caffe Users
Data layer produces two blobs to separate "data" flow from "labels" flow. If you switch the network to deploy mode, you will no longer have any labels to work with, so these flows must be separate. You can of course also use two separate layers to read data - one to load data itself, another to load labels. You only do that when really necessary though, because usually for training you will use a data source that contains (datum,label) pairs. It is more convenient this way, besides you might encounter problems if you tried to open one database from two layers (due to locking).

Layer never "references itself". Top and bottom are blobs, a layer is a layer - those two entities should not be confused. A layer called "data" does not have to produce a blob called "data" - it might be convenient to make it so (eg. if you draw a network graph or otherwise analyse/debug the net), but it is not a requirement. The only thing you need to pay attention to is, make sure a blob you want to use as input exists.

GATETE Elie MAGAMBO

unread,
May 10, 2017, 5:04:38 AM5/10/17
to Caffe Users
Thank you very much,that is where i was getting confused..layer having same names with blobs....now i understand...
Reply all
Reply to author
Forward
0 new messages