1

here is the function using to backward in a caffe cnn, the top are the output of this layer and bottom are the input from previous layer

def backward(self,top,propagate_down,bottom):
         if propagate_down[0] and self.count!=0:
             bottom[0].diff[...]=0
             bottom[0].diff[self.valid_index]=top[0].diff[...]
         if propagate_down[1] and self.count!=0:
             bottom[1].diff[...]=0
             bottom[1].diff[self.valid_index]=top[1].diff[...]

eh... what does the .diff[...]=0 means?

Shai
  • 111,146
  • 38
  • 238
  • 371
jeck yung
  • 128
  • 1
  • 10
  • 3
    `...` is just the `Ellipsis` constant, `__getitem__()` implemented by `diff` is free to do whatever it wants with it, e.g. you can use it as a key in a `dict`: `d = {}; d[...] = 0 #{Ellipsis: 0}` – AChampion Sep 13 '17 at 03:28
  • 2
    See also: https://stackoverflow.com/questions/772124/what-does-the-python-ellipsis-object-do – Robᵩ Sep 13 '17 at 03:31
  • Thanks, it helps me! – jeck yung Sep 13 '17 at 06:05

1 Answers1

3

setting

diff[...]=0

simply sets all gradients of var to zero.

As suggested by Rob, you can read more about ellipsis ([...]) here.

Shai
  • 111,146
  • 38
  • 238
  • 371