subtract output of two layers

1,164 views
Skip to first unread message

Peter Neher

unread,
Jan 7, 2016, 7:08:12 AM1/7/16
to Caffe Users
Hi everyone,

I was wondering if this is the right way to get the difference-vector of the output vectors of two fully connected layers:

layer
{
  name: "eltwise_layer"
  type: "Eltwise"
  bottom: "ip1"
  bottom: "ip2"
  top: "diff"
  eltwise_param {
    operation: SUM
    coeff: -1
  }
}

Cheers,
Peter

Evan Shelhamer

unread,
Jan 9, 2016, 11:26:18 PM1/9/16
to Peter Neher, Caffe Users
​That's almost it, but you need to set a coefficient for each bottom. Try

layer 
{
  name: "eltwise_layer"
  type: "Eltwise"
  bottom: "ip1"
  bottom: "ip2"
  top: "diff"
  eltwise_param {
    operation: SUM
    coeff: 1
    coeff: -1
  }
}

to compute ip1 - ip2.

Evan Shelhamer




Peter Neher

unread,
Jan 11, 2016, 1:56:43 AM1/11/16
to Caffe Users, pne...@gmail.com
Seems to work, thank you!
Reply all
Reply to author
Forward
0 new messages