keras.argmax中axis=-1是什么意思? [英] What is the meaning of axis=-1 in keras.argmax?

查看:34
本文介绍了keras.argmax中axis=-1是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Keras 的初学者,需要帮助来理解 keras.argmax(a,axis=-1)keras.max(a,axis=-1).a.shape = (19, 19, 5, 80)axis=-1是什么意思?还有 keras.argmax(a,axis=-1)keras.max(a,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)?

推荐答案

这意味着 argmax 将返回的索引将取自最后一个轴.

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

您的数据具有某种形状(19,19,5,80).这意味着:

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

  • 轴 0 = 19 个元素
  • 轴 1 = 19 个元素
  • 轴 2 = 5 个元素
  • 轴 3 = 80 个元素

现在,负数的工作方式与 Python 列表、numpy 数组等中的完全一样.负数表示相反的顺序:

Now, negative numbers work exactly like in python lists, in numpy arrays, etc. Negative numbers represent the inverse order:

  • 轴 -1 = 80 个元素
  • 轴 -2 = 5 个元素
  • 轴 -3 = 19 个元素
  • 轴 -4 = 19 个元素

当您将 axis 参数传递给 argmax 函数时,返回的索引将基于此轴.您的结果将丢失此特定轴,但保留其他轴.

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.

看看 argmax 将为每个索引返回什么形状:

See what shape argmax will return for each index:

  • K.argmax(a,axis= 0 or -4) 返回 (19,5,80) 的值从 0 到 18>
  • K.argmax(a,axis= 1 or -3) 返回 (19,5,80) 的值从 0 到 18>
  • K.argmax(a,axis= 2 or -2) 返回 (19,19,80) 的值从 0 到 4>
  • K.argmax(a,axis= 3 or -1) 返回 (19,19,5) 的值从 0 到 79>
  • 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

这篇关于keras.argmax中axis=-1是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆