添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams Adding to the excellent answer by Daniel Möller, if your data has a shape (19,19,5,80) then keras.max(a, axis=-1) would return a matrix of shape (19,19,5) where each value of the output matrix would be the maximum of the 80 elements (the maximum of the values specified within the last index) user9702892 Apr 26, 2018 at 9:05

This means that the index that will be returned by argmax will be taken from the last axis.

Your data has some shape (19,19,5,80) . This means:

  • Axis 0 = 19 elements
  • Axis 1 = 19 elements
  • Axis 2 = 5 elements
  • Axis 3 = 80 elements
  • Now, negative numbers work exactly like in python lists, in numpy arrays, etc. Negative numbers represent the inverse order:

  • Axis -1 = 80 elements
  • Axis -2 = 5 elements
  • Axis -3 = 19 elements
  • Axis -4 = 19 elements
  • When you pass the axis parameter to the argmax function, the indices returned will be based on this axis. Your results will lose this specific axes, but keep the others.

    See what shape argmax will return for each index:

  • K.argmax(a,axis= 0 or -4) returns (19,5,80) with values from 0 to 18
  • K.argmax(a,axis= 1 or -3) returns (19,5,80) with values from 0 to 18
  • K.argmax(a,axis= 2 or -2) returns (19,19,80) with values from 0 to 4
  • K.argmax(a,axis= 3 or -1) returns (19,19,5) with values from 0 to 79
  • Thank you! I was working with a different data structure, and it turns out for me it was important to use the Keras axis indexing as something like K.sum(three_dimensional_array, axis=[0,1]). legel Sep 3, 2019 at 8:32