softmax

tensorflow识别MNIST数据集

只谈情不闲聊 提交于 2019-11-27 21:51:48
目录 数据准备 1、引入MNIST数据集 2、保存前30条数据的原始图片 一、softmax实现单神经元模型 1、初始化变量 2、向前传播以及损失函数 3、向后传播以及优化参数 4、开始训练 5、评估模型 补充 二、两层卷积网络分类 1、初始化变量 2、预定义函数 3、卷积层 4、全连接层 5、定义交叉熵损失以及测试的准确率 6、开始训练 总结 数据准备 简单的说,MNIST就是一组最基础的数据集,M代表Modified,NIST代表国家标准和技术研究所,包括从0~9的训练数字的图片,这个分类问题是机器学习最简单和最广泛使用的测试之一。 1、引入MNIST数据集 from tensorflow.examples.tutorials.mnist import input_data # 从MNIST_data/中读取MNIST数据。这条语句在数据不存在时,会自动执行下载 mnist = input_data.read_data_sets("MNIST_data/", one_hot=True) # 查看训练数据的大小 print(mnist.train.images.shape) # (55000, 784) print(mnist.train.labels.shape) # (55000, 10) # 查看验证数据的大小 print(mnist.validation.images

Why use softmax as opposed to standard normalization?

狂风中的少年 提交于 2019-11-27 16:38:16
In the output layer of a neural network, it is typical to use the softmax function to approximate a probability distribution: This is expensive to compute because of the exponents. Why not simply perform a Z transform so that all outputs are positive, and then normalise just by dividing all outputs by the sum of all outputs? There is one nice attribute of Softmax as compared with standard normalisation. It react to low stimulation (think blurry image) of your neural net with rather uniform distribution and to high stimulation (ie. large numbers, think crisp image) with probabilities close to 0

Numercially stable softmax

我怕爱的太早我们不能终老 提交于 2019-11-27 04:37:40
问题 Is there a numerically stable way to compute softmax function below? I am getting values that becomes Nans in Neural network code. np.exp(x)/np.sum(np.exp(y)) 回答1: The softmax exp( x )/sum(exp( x )) is actually numerically well-behaved. It has only positive terms, so we needn't worry about loss of significance, and the denominator is at least as large as the numerator, so the result is guaranteed to fall between 0 and 1. The only accident that might happen is over- or under-flow in the

numpy : calculate the derivative of the softmax function

拜拜、爱过 提交于 2019-11-27 01:29:40
问题 I am trying to understand backpropagation in a simple 3 layered neural network with MNIST . There is the input layer with weights and a bias . The labels are MNIST so it's a 10 class vector. The second layer is a linear tranform . The third layer is the softmax activation to get the output as probabilities. Backpropagation calculates the derivative at each step and call this the gradient. Previous layers appends the global or previous gradient to the local gradient . I am having trouble

TensorFlow实现Softmax

Deadly 提交于 2019-11-26 19:27:15
我们先来理解理解Softmax:任 意事 件发生的概率都在 0 和 1 之间,且总有某 一 个 事 件发生 ( 概率的和为 1 )。如果将分类问题中“ 一 个样例属于某 一 个类别”看成 一 个概率 事 件, 那么训练数据的正确答案就符合 一 个概率分布 。因为事 件“ 一 个样例属于不正确的类别”的概率为0, 而“ 一 个样例属于正确的类别”的概率为 1。如何将神经网络前向传播得到的结果也变成 概率分布呢? Softmax 回归就是 一 个非常常用的方法 。 Softmax 回归本身可以作为 一 个学习算法来优化分类结果,但在TensorFlow 中, softmax 回归的参数被去掉了,它只是 一 层额外的处理层,将神经网络的输出变成 一 个概率分布 。 总结:softmax就是把输出结果变成概率分布。 TensorFlow实现Softmax:result = tf.nn.softmax( tf.matmul(x,w)+b ),其中 tf.matmul(x,w)+b为神经网络的输出结果。 来源: https://www.cnblogs.com/Mydream6/p/11330909.html

论文阅读:Face Recognition: From Traditional to Deep Learning Methods 《人脸识别综述:从传统方法到深度学习》

让人想犯罪 __ 提交于 2019-11-26 19:17:50
论文阅读: Face Recognition: From Traditional to Deep Learning Methods 《人脸识别综述:从传统方法到深度学习》 一、引言 1.探索人脸关于姿势、年龄、遮挡、光照、表情的不变性,通过特征工程人工构造feature,结合PCA、LDA、支持向量机等机器学习算法。 2.流程 人脸检测,返回人脸的bounding box 人脸对齐,用2d或3d的参考点,去对标人脸 人脸表达,embed 人脸匹配,匹配分数 二、人脸识别发展综述 1.几何特征 最早:边缘提取算子和连通域算子提取特征器官 发展:梯度图像 普氏距离分析 基于几何理论的方法在3d识别中有一定应用 [20][21] 2.整体方法 PCA [22-24] PCA的概率版变体,利用贝叶斯分析 [25]。使用两组特征脸来描述相同人和不同人之间variation PAC其他变体 kernel PCA 独立成分分析 ICA 其他见文章 PCA方法总的来说是基于整体脸,而不是局部部件,来判断输入图像是否是人脸。 PCA方法的问题在于,其投影将训练集中所有图片的variance最大化了,也就是说,最大的特征向量并不利于人脸识别,这是因为,提取到的eigenvector很有可能同一个体的variation(光照,姿势,表情带来的) LDA,即Fisher discriminant

What's the difference between sparse_softmax_cross_entropy_with_logits and softmax_cross_entropy_with_logits?

╄→гoц情女王★ 提交于 2019-11-26 15:41:23
I recently came across tf.nn.sparse_softmax_cross_entropy_with_logits and I can not figure out what the difference is compared to tf.nn.softmax_cross_entropy_with_logits . Is the only difference that training vectors y have to be one-hot encoded when using sparse_softmax_cross_entropy_with_logits ? Reading the API, I was unable to find any other difference compared to softmax_cross_entropy_with_logits . But why do we need the extra function then? Shouldn't softmax_cross_entropy_with_logits produce the same results as sparse_softmax_cross_entropy_with_logits , if it is supplied with one-hot

3、深度学习基础

天涯浪子 提交于 2019-11-26 10:50:35
3.1 基本概念 3.1.1 神经网络组成 神经网络类型众多,其中最为重要的是多层感知机。为了详细地描述神经网络,我们先从最简单的神经网络说起。 感知机 多层感知机中的特征神经元模型称为感知机,由Frank Rosenblatt于1957年发明。 简单的感知机如下图所示: 其中$x_1$,$x_2$,$x_3$为感知机的输入,其输出为: $ output = \left{ \begin{aligned} 0, \quad if \ \ \sumi wi xi \leqslant threshold \ 1, \quad if \ \ \sumi wi xi > threshold \end{aligned} \right. $ 假如把感知机想象成一个加权投票机制,比如 3 位评委给一个歌手打分,打分分别为$ 4 $分、$1$ 分、$-3 $分,这$ 3$ 位评分的权重分别是 $1、3、2$,则该歌手最终得分为 $4 \times 1 + 1 \times 3 + (-3) \times 2 = 1$ 。按照比赛规则,选取的 $threshold$ 为 $3$,说明只有歌手的综合评分大于$ 3$ 时,才可顺利晋级。对照感知机,该选手被淘汰,因为: $$ \sumi wi x_i < threshold=3, output = 0 $$ 用 $-b$ 代替 $threshold$

How to implement the Softmax function in Python

泪湿孤枕 提交于 2019-11-26 06:54:15
问题 From the Udacity\'s deep learning class, the softmax of y_i is simply the exponential divided by the sum of exponential of the whole Y vector: Where S(y_i) is the softmax function of y_i and e is the exponential and j is the no. of columns in the input vector Y. I\'ve tried the following: import numpy as np def softmax(x): \"\"\"Compute softmax values for each sets of scores in x.\"\"\" e_x = np.exp(x - np.max(x)) return e_x / e_x.sum() scores = [3.0, 1.0, 0.2] print(softmax(scores)) which

What&#39;s the difference between sparse_softmax_cross_entropy_with_logits and softmax_cross_entropy_with_logits?

﹥>﹥吖頭↗ 提交于 2019-11-26 04:32:34
问题 I recently came across tf.nn.sparse_softmax_cross_entropy_with_logits and I can not figure out what the difference is compared to tf.nn.softmax_cross_entropy_with_logits. Is the only difference that training vectors y have to be one-hot encoded when using sparse_softmax_cross_entropy_with_logits ? Reading the API, I was unable to find any other difference compared to softmax_cross_entropy_with_logits . But why do we need the extra function then? Shouldn\'t softmax_cross_entropy_with_logits