argmax

数据统计

匿名 (未验证) 提交于 2019-12-02 22:11:45
Ŀ¼ Outline Vector norm Eukl. Norm L1 Norm reduce_min/max/mean argmax/argmin tf.equal Accuracy tf.unique Outline tf.norm tf.reduce_min/max/mean tf.argmax/argmin tf.equal tf.unique Vector norm Eukl. Norm \[ ||x||_2=|\sum_{k}x_k^2|^{\frac{1}{2}} \] Max.norm \[ ||x||_{\infty}=max_k|x_k| \] L1-Norm \[ ||x||_1=\sum_{k}|x_k| \] Here talks about Vector Norm Eukl. Norm import tensorflow as tf a = tf . ones ([ 2 , 2 ]) a <tf.Tensor : id = 11, shape = (2, 2), dtype = float32, numpy = array([[1., 1.], [1., 1.]], dtype = float32) > tf . norm ( a ) <tf.Tensor : id = 7, shape = (), dtype = float32, numpy = 2

What is the meaning of axis=-1 in keras.argmax?

自闭症网瘾萝莉.ら 提交于 2019-12-02 14:14:15
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

deep_learning_LSTM长短期记忆神经网络处理Mnist数据集

假装没事ソ 提交于 2019-11-30 18:29:06
1、RNN(Recurrent Neural Network)循环神经网络模型 详见RNN循环神经网络: https://www.cnblogs.com/pinard/p/6509630.html 2、LSTM(Long Short Term Memory)长短期记忆神经网络模型 详见LSTM长短期记忆神经网络: http://www.cnblogs.com/pinard/p/6519110.html 3、LSTM长短期记忆神经网络处理Mnist数据集 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data from tensorflow.contrib import rnn # 载入数据集 mnist = input_data.read_data_sets( "MNIST_data/" , one_hot = True ) # 输入图片是28

tf.argmax()解析

我的梦境 提交于 2019-11-30 11:26:25
tf.argmax()解析 2018年07月27日 17:00:53 爱抓猫的狗 阅读数 17059 更多 分类专栏: TensorFlow 版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。 本文链接: https://blog.csdn.net/u012300744/article/details/81240580 tf.argmax(input,axis)根据axis取值的不同返回每行或者每列最大值的索引。 这个很好理解,只是tf.argmax()的参数让人有些迷惑,比如,tf.argmax(array, 1)和tf.argmax(array, 0)有啥区别呢? 这里面就涉及到一个概念:axis。上面例子中的1和0就是axis。我先笼统的解释这个问题,设置axis的主要原因是方便我们进行多个维度的计算。   比如: test = np.array([[1, 2, 3], [2, 3, 4], [5, 4, 3], [8, 7, 2]]) np.argmax(test, 0)   #输出:array([3, 3, 1] np.argmax(test, 1)   #输出:array([2, 2, 0, 0]123 1 2 3 axis = 0:   axis=0时比较每一列的元素,将每一列最大元素所在的索引记录下来

python查找数组中出现次数最多的元素

喜夏-厌秋 提交于 2019-11-29 13:32:49
方法1-np.argmax(np.bincount()) 看一个例子 array = [0,1,2,2,3,4,4,4,5,6] print(np.bincount(array)) print(np.argmax(np.bincount(array))) #[1 1 2 1 3 1 1] #4 这里用到了两个函数,np.argmax和np.bincount,第一个很常见,就是返回数组中最大值对应的下标,np.bincount可以通过上面的例子理解:首先找到数组最大值max,然后返回0~max的各个数字出现的次数,在上例中,0出现了1次,1出现了1次,2出现了2次...以此类推。 为什么这两个函数合起来可以找到出现次数最多的元素呢?因为np.bincount返回的数组中的下标对应的就是原数组的元素值,如上例中np.argmax找到np.bincount返回的数组中的最大值3(原数组中4出现了3次),其对应的下标4正是原数组中的元素4,如此就可以找到数组中出现次数最多的元素。 但是这种方法有一个缺陷,即bincount只能统计0~max出现的次数, 所以这种方法仅适用于非负数组 方法2-Counter().most_common(1)[0][0] 看一个例子 from collections import Counter array = [0,1,2,2,3,4,4,4,5,6]

Numpy arrays: row/column wise argmax with random ties

梦想与她 提交于 2019-11-29 12:27:11
Here is what I am trying to do with Numpy in Python 2.7. Suppose I have an array a defined by the following: a = np.array([[1,3,3],[4,5,6],[7,8,1]]) I can do a.argmax(0) or a.argmax(1) to get the row/column wise argmax: a.argmax(0) Out[329]: array([2, 2, 1], dtype=int64) a.argmax(1) Out[330]: array([1, 2, 1], dtype=int64) However, when there is a tie like in a 's first row, I would like to get the argmax decided randomly between the ties (by default, Numpy returns the first element whenever a tie occurs in argmax or argmin). Last year, someone put a question on solving Numpy argmax/argmin ties

Numpy arrays: row/column wise argmax with random ties

偶尔善良 提交于 2019-11-28 01:57:21
问题 Here is what I am trying to do with Numpy in Python 2.7. Suppose I have an array a defined by the following: a = np.array([[1,3,3],[4,5,6],[7,8,1]]) I can do a.argmax(0) or a.argmax(1) to get the row/column wise argmax: a.argmax(0) Out[329]: array([2, 2, 1], dtype=int64) a.argmax(1) Out[330]: array([1, 2, 1], dtype=int64) However, when there is a tie like in a 's first row, I would like to get the argmax decided randomly between the ties (by default, Numpy returns the first element whenever a

numpy: how to get a max from an argmax result

萝らか妹 提交于 2019-11-27 08:00:49
问题 I have a numpy array of arbitrary shape, e.g.: a = array([[[ 1, 2], [ 3, 4], [ 8, 6]], [[ 7, 8], [ 9, 8], [ 3, 12]]]) a.shape = (2, 3, 2) and a result of argmax over the last axis: np.argmax(a, axis=-1) = array([[1, 1, 0], [1, 0, 1]]) I'd like to get max: np.max(a, axis=-1) = array([[ 2, 4, 8], [ 8, 9, 12]]) But without recalculating everything. I've tried: a[np.arange(len(a)), np.argmax(a, axis=-1)] But got: IndexError: shape mismatch: indexing arrays could not be broadcast together with

Find row where values for column is maximal in a pandas DataFrame

笑着哭i 提交于 2019-11-26 11:04:33
How can I find the row for which the value of a specific column is maximal ? df.max() will give me the maximal value for each column, I don't know how to get the corresponding row. ely You just need the argmax() ( now called idxmax ) function. It's straightforward: >>> import pandas >>> import numpy as np >>> df = pandas.DataFrame(np.random.randn(5,3),columns=['A','B','C']) >>> df A B C 0 1.232853 -1.979459 -0.573626 1 0.140767 0.394940 1.068890 2 0.742023 1.343977 -0.579745 3 2.125299 -0.649328 -0.211692 4 -0.187253 1.908618 -1.862934 >>> df['A'].argmax() 3 >>> df['B'].argmax() 4 >>> df['C']

Find row where values for column is maximal in a pandas DataFrame

自闭症网瘾萝莉.ら 提交于 2019-11-26 03:27:38
问题 How can I find the row for which the value of a specific column is maximal ? df.max() will give me the maximal value for each column, I don\'t know how to get the corresponding row. 回答1: You just need the argmax() ( now called idxmax ) function. It's straightforward: >>> import pandas >>> import numpy as np >>> df = pandas.DataFrame(np.random.randn(5,3),columns=['A','B','C']) >>> df A B C 0 1.232853 -1.979459 -0.573626 1 0.140767 0.394940 1.068890 2 0.742023 1.343977 -0.579745 3 2.125299 -0