softmax

Cross Entropy Loss for Semantic Segmentation Keras

匿名 (未验证) 提交于 2019-12-03 01:26:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm pretty sure this is a silly question but I can't find it anywhere else so I'm going to ask it here. I'm doing semantic image segmentation using a cnn (unet) in keras with 7 labels. So my label for each image is (7,n_rows,n_cols) using the theano backend. So across the 7 layers for each pixel, it's one-hot encoded. In this case, is the correct error function to use categorical cross-entropy? It seems that way to me but the network seems to learn better with binary cross-entropy loss. Can someone shed some light on why that would be and

How to implement pixel-wise classification for scene labeling in TensorFlow?

匿名 (未验证) 提交于 2019-12-03 01:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I am working on a deep learning model using Google's TensorFlow . The model should be used to segment and label scenes . I am using the SiftFlow dataset which has 33 semantic classes and images with 256x256 pixels . As a result, at my final layer using convolution and deconvolution I arrive at the following tensor(array) [256, 256, 33] . Next I would like to apply Softmax and compare the results to a semantic label of size [256, 256] . Questions: Should I apply mean averaging or argmax to my final layer so its shape becomes [256

tensorflow - softmax ignore negative labels (just like caffe) [duplicate]

匿名 (未验证) 提交于 2019-12-03 01:00:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: This question already has an answer here: TensorFlow: How to handle void labeled data in image segmentation? 2 answers In Caffe, there is an option with its SoftmaxWithLoss function to ignore all negative labels (-1) in computing probabilities, so that only 0 or positive label probabilities add up to 1. Is there a similar feature with Tensorflow softmax loss? 回答1: Just came up with a work-around --- I created a one-hot tensor on the label indices using tf.one_hot (with the depth set at the # of labels). tf.one_hot automatically zeros out all

Caffe: Softmax with temperature

匿名 (未验证) 提交于 2019-12-03 00:52:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I am working on implementing Hinton's Knowledge distillation paper . The first step is to store the soft targets of a "cumbersome model" with a higher temperature (i.e. I don't need to train the network, just need to do forward pass per image and store the soft targets with a temperature T ). Is there a way I can get the output of Alexnet or googlenet soft targets but with a different temperature? I need to modify the soft-max with pi= exp(zi/T)/sum(exp(zi/T) . Need to divide the outputs of the final fully connected layer with a

CS224n笔记二:word2vec

匿名 (未验证) 提交于 2019-12-03 00:41:02
语言学中meaning近似于“指代,代指,符号”。 过去一直采用 分类词典 ,计算语言学中常见的方式时WordNet那样的词库,比如NLTK中可以通过WordNet查询熊猫的上位词(hypernums),得到“食肉动物”,“动物”之类的上位词。也可以查询“good”的同义词,如“just”。 这种离散表示并不准确,丢失了些许韵味。如以下同义词的意思还是有微妙不同的:adept, expert, good, practiced, proficient, skillful 缺少新词 耗费人力 无法准确计算词语相似度 大多数NLP学者将词语作为最小的单位,事实上,词语只是词表长度的one-hot向量,这是一种局部表示(localist representation)。在不同的语料中,词表大小不同,如Google的1TB词料词汇量是1300w,这个向量实在过长了。 词语在符号表示上体现不出意义的相似性,如“motel”和“hotel”,其one-hot向量是正交的,无法通过计算获得相似度。 Distributional similarity based representations 语言学家J. R. Firth提出,通过一个单词的上下文可以得到它的意思。J. R. Firth甚至建议,日过能将单词放到正确的上下文中,才说明掌握了它的意义。这是现代统计自然语言处理最成功的思想之一:

PyTorch中的Loss Fucntion

匿名 (未验证) 提交于 2019-12-03 00:34:01
转载:http://sshuair.com/2017/10/21/pytorch-loss/ PyTorch中的Loss Fucntion f ( x ) f(x) y y f ( x ) f(x) W W y ^ y^ y y Cross Entropy Cross Entropy(也就是交叉熵)来自香农的信息论,简单来说,交叉熵是用来衡量在给定的真实分布 p k pk 下,使用非真实分布 q k qk f ( x ) f(x) H ( p , q ) = ∑ k = 1 N ( p k l o g q k ) 最大似然估计、Negative Log Liklihood(NLL)、KL散度与Cross Entropy其实是等价的 ,都可以进行互相推导,当然MSE也可以用Cross Entropy进行对到出(详见Deep Learning Book P132)。 Cross Entropy可以用于分类问题,也可以用于语义分割,对于分类问题,其输出层通常为Sigmoid或者Softmax,当然也有可能直接输出加权之后的,而pytorch中与Cross Entropy相关的loss Function包括: CrossEntropyLoss: combines LogSoftMax and NLLLoss in one single class

简单谈谈Cross Entropy Loss

匿名 (未验证) 提交于 2019-12-03 00:33:02
写在前面 分类问题和回归问题是监督学习的两大种类。 神经网络模型的效果及优化的目标是通过损失函数来定义的。 回归问题解决的是对具体数值的预测。比如房价预测、销量预测等都是回归问题。这些问题需要预测的不是一个事先定义好的类别,而是一个任意实数。解决回顾问题的神经网络一般只有一个输出节点,这个节点的输出值就是预测值。对于回归问题,常用的损失函数是均方误差( MSE,mean squared error )。 分类问题常用的损失函数为交叉熵( Cross Entropy Loss)。 这篇博客我们简单谈谈交叉熵损失函数。 交叉熵描述了两个概率分布之间的距离,当交叉熵越小说明二者之间越接近。[关于交叉熵的原理,我这有一篇简单明白的 博客 ] 尽管交叉熵刻画的是两个概率分布之间的距离,但是神经网络的输出却不一定是一个概率分布。为此我们常常用Softmax回归将神经网络前向传播得到的结果变成概率分布。 softmax常用于多分类过程中,它将多个神经元的输出,归一化到( 0, 1) 区间内,因此Softmax的输出可以看成概率,从而来进行多分类。 假设我们有一个包含k个元素的数组V, i i 表示V中的第 i i 个元素,那么这 i i 个元素的softmax输出就是: S i = e i ∑ k j = 1 e j S i = e i ∑ j = 1 k e j 为了举一个具体例子

caffe softmax_loss layer 解析

匿名 (未验证) 提交于 2019-12-03 00:32:02
按理说每一层应该都要求一层梯度,其中包括对权值,对输入数据,对偏置分别求取梯度。但是在softmax with loss layer这一层求取梯度的一些过程被省去了,首先这一次只是一个激活函数层,没有权值和偏置参数,然后我们只需要对输入数据求取梯度,softmax with loss layer的输入数据其实表示的是原始输入数据相对于各个标签的打分,而对于代价函数对这个输入的梯度已经有专门的迭代算法来求解。 一.softmax简介 当某个类的预测值很大时该类的分量流趋向于1,其他类的分量值就变得很小。 二.前向传播 在caffe中的softmax layer中它的前向传播过程如下所示 输入的向量经过指数化和归一化后进行输出,这就是softmax layer的前向计算过程,主要代码为 template <typename Dtype> void SoftmaxLayer<Dtype>::Forward_cpu(const vector<Blob<Dtype> >& bottom,const vector<Blob<Dtype> >& top) { const Dtype* bottom_data = bottom[0]->cpu_data(); Dtype* top_data = top[0]->mutable_cpu_data(); Dtype* scale_data =

softmax及在多分类中的应用

匿名 (未验证) 提交于 2019-12-03 00:27:02
一、softmax的定义 现有一组值x1、x2、x3 x1变换为 ,x2、x3依次类推 变换后的新值值域是[0,1],所有新值的和等于1,跟概率特征很像,所以有了以下应用。 二、在多分类中应用 某个网络要做多分类,假设分3类,输出节点就有3个,输出值经过了softmax变换,所以输出值值域为[0,1],所有输出值的和等于1。 用xi表示第i个样本,h1(xi)表示样本xi为输入时,第一个输出值的值,h2(xi)、h3(xi)以此类推。 h1、h2、h3就可以用来表示此样本属于第1、2、3类的概率。 下面构建损失函数: 若此样本属于第1类,则此样本的概率加权和=h1(xi)*1+h2(xi)*0+h3(xi)*0=h1(xi) 现在问题变为求loss的最小值 文章来源: softmax及在多分类中的应用

卷积神经网络系列之softmax,softmax loss和cross entropy

匿名 (未验证) 提交于 2019-12-03 00:22:01
全连接层到损失层 间的计算 先理清下 从全连接层到损失层 之间的计算。 这张图的等号左边部分就是全连接层做的事,W是 全连接层的参数 ,我们也称为权值, X是全连接层的输入,也就是特征 。 从图上可以看出特征X是N*1的向量,这是怎么得到的呢? ,假设全连接层前面连接的是一个卷积层,这个卷积层的输出是100个特征(也就是我们常说的feature map的channel为100),每个特征的大小是4*4, 那么在将这些特征输入给全连接层之前会将这些特征flat成N*1的向量(这个时候N就是100*4*4=1600) 。 解释完X,再来看W,W是全连接层的参数,是个T*N的矩阵,这个N和X的N对应, T表示类别数,比如你是7分类,那么T就是7。我们所说的训练一个网络,对于全连接层而言就是寻找最合适的W矩阵。 向量 (也就是图中的logits[T*1]),这个向量里面的每个数都没有大小限制的, 也就是从负无穷大到正无穷大 。 一般会在全连接层后面接一个softmax层 , 这个softmax的输入是T*1的向量,输出也是T*1的向量(也就是图中的prob[T*1],这个向量的每个值表示这个样本属于每个类的概率),只不过输出的向量的每个值的大小范围为0到1。 softmax的输出向量是就是概率,该样本属于各个类的概率! softmax计算