问题标签 [argmax]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
python - 如何在ndarray中找到所有argmax
我有一个二维 NumPy ndarray。
如何获得最大元素的所有索引?所以我想作为输出数组([0,1],[2,2])。
python - 在数据框的给定列中查找最大值的行索引
我想通过增加 column 的值来订购 DataFrame number
,并获得该最大值的索引。(这里是第二行,所以结果应该是'BCD':
(有没有比我的以下黑客更奇怪的解决方案?我通过添加另一个具有相同名称的列来解决这个问题,只是为了让我了解它通常是如何工作的)所以这是我的代码想出了:
这似乎非常尴尬,应该有一个简单的选择来做到这一点,但是我在 pandas 的文档和 www.pandas 的文档中找不到它。我有更改索引的想法(类似于 df = df.reset_index()),然后将旧索引转换为新列,但这仍然不是最终解决方案,因为我认为应该有一个选项来“提取” “我的df的热门指数?
python - numpy中矩阵的one-hot表示
从值矩阵到 3d 张量中同一事物的一个热表示的最简单/最智能的方法是什么?例如,如果矩阵是张量中 argmax 之后的索引,例如:
其中张量是 3D [x,y,z],索引自然是 [x,y]。现在你想去一个 3D [x,y,z] 张量,它在axis = 2中的最大值位置为1s,在任何其他位置为0。
PS 我知道向量到 1-hot 矩阵的答案,但这是矩阵到 1-hot 张量。
matlab - 如何在 MATLAB 中计算 argmax?
最大参数: https ://en.wikipedia.org/wiki/Arg_max
由于存在一些混淆,我将描述 argmax 的作用:
argmax 查找函数的参数,以使该函数最大化。
所以在这个例子中,argmax 将给出 x = 5。argmax 应该对一个函数中的多个变量执行此操作。
我正在尝试从论文Provably Manipulation-Resistant Reputation Systems中解决这个公式:
X
是一个包含变量的矩阵,我想为其找到使公式最大化的值。
我已经用 Wolfram|Cloud 尝试过,但是免费计划的内存限制太小:Wolfram|Cloud memory limit exceeded
我有一个本地 MATLAB R2016b 版本,想在 MATLAB 中编写这个公式。
MATLAB 有 argmax 函数吗?
numpy - 减少的最大值的 Numpy 索引 - numpy.argmax.reduceat
我有一个平面阵列b
:
c
以及标记每个“块”开始的索引数组:
我知道我可以使用减少找到每个“块”中的最大值:
但是......有没有办法通过矢量化操作(无列表,循环)找到<edit>
块内的最大值索引</edit>
(如numpy.argmax
)?
tensorflow - Tensorflow Argmax:“轴”和“维度”参数有什么区别?
当前版本的 Tensorflow Argmax 没有指定“轴”和“维度”参数之间的区别。以下是官方手册中给出的唯一信息:
有人可以澄清吗?究竟是哪一个维度被缩减了?
scala - Scala/Spark 数据帧:找到对应于最大值的列名
在 Scala/Spark 中,有一个数据框:
我想计算一个新列,其中包含与最大值对应的列maxCol
的名称(对于每一行)。在这个例子中,输出应该是:
实际上数据框有60多列。因此需要一个通用的解决方案。
Python Pandas 中的等价物(是的,我知道,我应该与 pyspark 进行比较......)可能是:
python - Set value of first item in slice in python pandas
So I would like make a slice of a dataframe and then set the value of the first item in that slice without copying the dataframe. For example:
The slice here is irrelevant and just for the example and will return the whole data frame again. Point being, by doing it like it is in the example you get a setting with copy warning (understandably). I have also tried slicing first and then using ILOC/IX/LOC and using ILOC twice, i.e. something like:
And neither of these work. Again- I don't want to make a copy of the dataframe even if it id just the sliced version.
EDIT: It seems there are two ways, using a mask or IdxMax. The IdxMax method seems to work if your index is unique, and the mask method if not. In my case, the index is not unique which I forgot to mention in the initial post.
python - python numpy argmax到多维数组中的最大值
我有以下代码:
即我沿axis = 2取argmax,它给了我一个(10,10)矩阵。现在,我想将这些索引值分配为 0。为此,我想索引示例数组。我试过了:
但它不起作用。我想要类似的东西
我只是通过检查max_values - np.max(sample, axis=2)
应该给出一个形状为零的矩阵(10,10)来验证。任何帮助将不胜感激。
label - 为什么我们需要 tf.arg_max(Y,1) 和 tensorflow 中的 softmax?
当我写 tensorflow 演示时,我arg_max()
在定义中找到了这个函数correct_predition
返回张量轴上具有最大值的索引。(这是来自 TF 的 API)
因为我们使用' softmax_cross_entropy_with_logits
',
预测 ( hypothesis
) 表示为概率
arg_max()
我们将通过函数获得最大预测概率的索引hypothesis
但是Y
是标签,这不是我们需要使用的概率tf.arg_max(Y,1)
吗?