pythonargmaxaxis1_keras.argmax中axis = -1的含义是什么?

I am a beginner in Keras and need help to understand keras.argmax(a, axis=-1) and keras.max(a, axis=-1). What is the meaning of axis=-1 when a.shape = (19, 19, 5, 80)? And also what will be the output of keras.argmax(a, axis=-1) and keras.max(a, axis=-1)?

解决方案

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值