Questions tagged [argmax]

arguments of the maxima: given a function of some arguments, argmax stands for the values of the arguments that maximizes the function.

Case 1

Here we consider a function f that maps from a limited set.

Say,

f(x) := {13, 42, 1981, 9, 11, 0},

so f(x = 1) = 13,and f(x = 2) = 42, so on.

It is easy to see here that the value of x that maximizes the function f is 3; that is f(x = 3) = 1981 is the highest values. Thus, argmax of f(x) is x = 3.

In R

f = c(13, 42, 1981, 9, 11, 0)
which.max(f)
# 3

Case 2

Here we consider a function of a continues variable.

Consider

f(x) = x(4 - x)

for this function the argmax is x = 2. That is the highest value of f(x) is 4 which corresponds to x = 2.

In R, we can use the optimize function for this to find the argmax of f.

f <- function(x) {
     x*(4 - x)
}

optimize(f, interval = c(-100, 100), maximum = TRUE)
# $maximum
# [1] 2
#
#$objective
#[1] 4
170 questions
1
vote
0 answers

Argmax in symengine or equivalent alternative

I am working on a simple simulation of a network of nonlinear systems. In particular I have N nodes, each one composed of m units. The output function of each unit depends both on its activity and the activity of the other units in the same…
giangian
  • 111
  • 4
1
vote
2 answers

How to get a vector. from 2D numpy array using argmax?

I have the following numpy.ndarray: testArr: array([[ 2.55053788e-01, 6.25406146e-01, 1.19271643e-01, 2.68359261e-04], [ 2.59611636e-01, 0.19562805e-01, 1.20518960e-01, 3.06535745e-01], [ 8.52524495e-01, …
ScalaBoy
  • 3,254
  • 13
  • 46
  • 84
1
vote
1 answer

Getting ArgMax of a 2d Array

so my questions is pretty straight forward. I have a 3-d array and would like to get the maximal value alone the first two axes. import numpy as np array = np.zeros((3,3,2)) array[1][1][0] = 1 array[1][1][1] = 2 How do I now check along [1][1]…
Ok iDoki
  • 79
  • 2
  • 10
1
vote
1 answer

Funny behavior with numba - guvectorized functions using argmax()

Consider the following script: from numba import guvectorize, u1, i8 import numpy as np @guvectorize([(u1[:],i8)], '(n)->()') def f(x, res): res = x.argmax() x = np.array([1,2,3],dtype=np.uint8) print(f(x)) print(x.argmax()) print(f(x)) When…
Rodrigo Vargas
  • 145
  • 1
  • 3
1
vote
1 answer

find index of largest difference from median with numpy

I'm trying to find the index number of the outlier number. based on difference from median I'm able to get the correct high number, but whenever the low number is the outlier I only get the high number.. import numpy as np def findoutlier(lis): …
Clueless
  • 79
  • 7
1
vote
0 answers

How can use index in tensorflow?

I have three 2-dim tensor in the training. I made like this below, but I get an error Cannot convert an unknown Dimension to a Tensor: ? mu = params[:, :self.num_mixture] sigma = params[:, self.num_mixture:self.num_mixture * 2] alpha = params[:,…
Ben
  • 45
  • 1
  • 1
  • 6
1
vote
1 answer

Pandas hierarchical pivot get column with max

df.head().info() RangeIndex: 5 entries, 0 to 4 Data columns (total 4 columns): id 5 non-null object date-hr 5 non-null object channel 5 non-null object hr 5 non-null int64 dtypes: int64(1), object(3) Actual…
Nikhil Verma
  • 1,777
  • 1
  • 20
  • 41
1
vote
1 answer

tf.argmax() returning unexpected results

I am recently making a project based on tensorflow CNN, MNIST dataset with a server interface. At the predict part, I use tf.argmax() to get the largest logit, which will be the predicted value. However, the value it returns didn't seems like the…
blahBlahhh
  • 11
  • 2
1
vote
1 answer

argmax(axis=0) : all output values are 0

I want to generate out of 'upsocre' layer of Caffenet(output class=9, there for the size of 'upscore' layer is 9). However, all pixels of upscore layer tuned 0 after using argmax(axis=0). any idea pleas? (upscore is deconvolution layer ) layer { …
1
vote
1 answer

argmax() or idxmax() is not providing right index where the maximum value is located

I have a subset dataframe and am trying to find the index where in the volume column is the max volume. In this case it should be index 1428, but using argmax or idxmcx it is giving 1431 combine1 Out[381]: folder fn …
1
vote
1 answer

Tensorflow : tf.argmax and slicing

I would like to design this loss function: sum((y[argmax(y_)] - y_[argmax(y_)])²) I don't find a way to do y[argmax(y_)]. I tried y[k], y[:,k] and y[None,k] none of these work. This is my code : Na = 3 x = tf.placeholder(tf.float32,…
mehh
  • 59
  • 1
  • 9
1
vote
2 answers

Extracting the max, min or std from a DF for a particular column in pandas

I have a df with columns X1, Y1, Z3. df.describe shows the stats for each column I would like to extract the min, max and std for say column Z3. df[df.z3].idxmax() doesn't seem to work
Padma
  • 37
  • 1
  • 3
1
vote
1 answer

Argmax of a multidimensional array along a subset of dimensions in Matlab

Say, Y is a 7-dimensional array, and I need an efficient way to maximize it along the last 3 dimensions, that will work on GPU. As a result I need a 4-dimensional array with maximal values of Y and three 4-dimensional arrays with the indices of…
1
vote
1 answer

Tensorflow for argmax of top 5?

tf.argmax return the top 1 of a tensor. I did some research and did not find a good way (other than scan) to get top 5 of a tensor. Please let me know if you have a better approach. Thanks!
1
vote
0 answers

java command hitting ARG_MAX limit in RH linux

Our application is generating a huge java command as there are 700+ jar entries in the classpath that we supply. The result is: java": error=7, Argument list too long at…
dganesh2002
  • 1,917
  • 1
  • 26
  • 29