
tensorflow
醉小义
学习算法让自己有更大的提升
展开
-
对全局平均池化(GAP)过程的理解
对学习Class Activation Mapping(CAM)原文献的时候提到的全局平均池化GAP方法做个简单的知识补充。所谓的全局就是针对常用的平均池化而言,平均池化会有它的filter size,比如 2 * 2,全局平均池化就没有size,它针对的是整张feature map.全局平均池化(Global average Pooling)由 M. Lin, Q. Chen, and ...转载 2018-12-07 16:02:45 · 2991 阅读 · 3 评论 -
关于卷积的特征映射
对于input=(1,4,4,2) 对应卷积核为3*3 channel从2映射为5个特征 (3,3,2,5), s=1,k=3 pad=valid是如何计算的?输出为 (1,2,2,5)原创 2018-10-24 20:44:32 · 2293 阅读 · 0 评论 -
tf.control_dependencies与tf.identity组合详解
引言我们在实现神经网络的时候经常会看到tf.control_dependencies的使用,但是这个函数究竟是什么作用,我们应该在什么情况下使用呢?今天我们就来一探究竟。理解其实从字面上看,control_dependencies 是控制依赖的意思,我们可以大致推测出来,这个函数应该使用来控制就算图节点之间的依赖的。其实正是如此,tf.control_dependencies()是用来...转载 2018-10-26 20:25:53 · 422 阅读 · 0 评论 -
tensorflow: (data_format) NHWC、NCHW 区别与转换
https://blog.youkuaiyun.com/jningwei/article/details/78156011区别NHWC[batch, in_height, in_width, in_channels]NCHW[batch, in_channels, in_height, in_width]NHWC –> NCHW:import tensorflow as...转载 2018-10-21 12:32:35 · 4288 阅读 · 0 评论 -
tensorflow之tf.nn.l2_normalize与l2_loss的计算
1.tf.nn.l2_normalize tf.nn.l2_normalize(x, dim, epsilon=1e-12, name=None) 上式: x为输入的向量; dim为l2范化的维数,dim取值为0或0或1; epsilon的范化的最小值边界; 按照列计算:import tensorflow as tfinput_data = tf.constant([[...转载 2018-10-28 13:05:45 · 6554 阅读 · 0 评论 -
语义分割,去除边缘线代码
import tensorflow as tfimport scipy.misc as msc''' 对于语义分割的边缘线,白色的为255,进行去除'''def remove_ignore_label(gt ,output=None ,pred=None): ''' 去除label为255的值,进行交叉熵的计算 gt: not one-hot...原创 2018-10-28 12:30:44 · 1287 阅读 · 0 评论 -
反卷积与反卷积核的初始化问题
导论:https://blog.youkuaiyun.com/qq_30638831/article/details/81532892https://cv-tricks.com/image-segmentation/transpose-convolution-in-tensorflow/https://zhuanlan.zhihu.com/p/38964806tf.nn.conv2d_t...原创 2018-10-19 20:12:14 · 3438 阅读 · 5 评论 -
VOC数据集颜色对应关系与代码
VOC颜色和分类的对于关系: code:def voc_colormap(N=256): def bitget(val, idx): return ((val & (1 << idx)) != 0) cmap = np.zeros((N, 3), dtype=np.uint8) for i in range(N): ...原创 2018-10-18 16:05:54 · 4887 阅读 · 1 评论 -
Tensorflow系列:tf.contrib.layers.batch_norm
tf.contrib.layers.batch_norm( inputs, decay=0.999, center=True, scale=False, epsilon=0.001, activation_fn=None, param_initializers=None, param_regularizers=None, u...转载 2018-09-28 10:11:54 · 19934 阅读 · 10 评论 -
关于一张RGB图片,在numpy中的存储。
假设图片为 width:200 heigh:300在numpy中,shape为 (1,300,200,3) 意思就是在矩阵中每一列,存储一张图片,即一个特征。就比如:[ [[0.0, 1.0], [2.0, 3.0], [4.0, 7.0], [6.0, 6.0]], [[8.0, 9.0], [10.0, 11.0], [12.0, 13.0], [14.0, 15...原创 2018-10-02 15:02:03 · 4265 阅读 · 3 评论 -
反卷积(Deconvolution)、上采样(UNSampling)与上池化(UnPooling)
原文:https://blog.youkuaiyun.com/A_a_ron/article/details/79181108前言在看图像语义分割方面的论文时,发现在网络解码器结构中有的时候使用反卷积、而有的时候使用unpooling或或者unsampling,查了下资料,发现三者还是有不同的。这里记录一下。图示理解使用三张图进行说明:图(a)表示UnPooling的过程,特点是在Maxp...转载 2018-09-26 10:46:01 · 3329 阅读 · 0 评论 -
反卷积(Transposed Convolution, Fractionally Strided Convolution or Deconvolution)
反卷积(Deconvolution)的概念第一次出现是Zeiler在2010年发表的论文Deconvolutional networks中,但是并没有指定反卷积这个名字,反卷积这个术语正式的使用是在其之后的工作中(Adaptive deconvolutional networks for mid and high level feature learning)。随着反卷积在神经网络可视化上的...转载 2018-09-26 10:40:07 · 700 阅读 · 0 评论 -
关于tensorflow中Dataset图片的批量读取以及维度的操作
三维的读取图片(w, h, c):import tensorflow as tfimport globimport os def _parse_function(filename): # print(filename) image_string = tf.read_file(filename) image_decoded = tf.image.decod...原创 2018-10-27 21:52:49 · 5612 阅读 · 0 评论 -
关于dilated convolution(空洞卷积)感受野的计算
关于感受野的定义请参考:https://www.jianshu.com/p/2b968e7a1715定义:感受野用来表示网络内部的不同神经元对原图像的感受范围的大小,或者说,convNets(cnn)每一层输出的特征图(feature map)上的像素点在原始图像上映射的区域大小。 计算公式: 从前往后: F后 = (F前 - 1) + k (F代表感受野的大小,...原创 2018-11-01 20:20:00 · 25260 阅读 · 17 评论 -
网络npy权值文件的使用
以imageNet中vgg网络:读取name:import numpy as npa=np.load('../model/largefov.npy',encoding="latin1")data=a.item()for item in data: print( item )conv5_1fc6conv5_3conv5_2fc7c...原创 2018-11-30 16:58:14 · 1704 阅读 · 0 评论 -
tf.split使用
import tensorflow as tfimport matplotlib.pyplot as pltprint(123)''' tensorlfow split的使用 value=img, 传入的图片 num_or_size_splits=3, 分割的数量 axis=2 ,分割的channel ...原创 2018-11-29 16:37:08 · 612 阅读 · 0 评论 -
python中的广播
向量(列): a = (1,2,3) a + 100 --广播 -> (a + (100, 100, 100)) --> (101,102,103)[[1,2,3], + (100,200,300) == (101,102,103)[4,5,6]] ...原创 2018-11-29 14:05:22 · 1219 阅读 · 0 评论 -
学习率,权值,损失函数计算例子
import tensorflow as tffrom tensorflow.examples.tutorials.mnist import input_datainput_node = 784output_node = 10layer1_node = 500batch_size = 100#基础学习率learing_rate_base = 0.8#学习率...原创 2018-11-29 10:38:24 · 2070 阅读 · 0 评论 -
tf.group()用于组合多个操作
tf.group()用于创造一个操作,可以将传入参数的所有操作进行分组。API手册如:tf.group( *inputs, **kwargs)ops = tf.group(tensor1, tensor2,...) 其中*inputs是0个或者多个用于组合tensor,一旦ops完成了,那么传入的tensor1,tensor2,...等等都会完成了,经常用于组合一些训练节...转载 2018-11-25 11:29:50 · 6204 阅读 · 0 评论 -
Tensorflow中tf.train.exponential_decay函数(指数衰减法)
在Tensorflow中,为解决设定学习率(learning rate)问题,提供了指数衰减法来解决。通过tf.train.exponential_decay函数实现指数衰减学习率。步骤:1.首先使用较大学习率(目的:为快速得到一个比较优的解); 2.然后通过迭代逐步减小学习率(目的:为使模型在训练后期更加稳定);代码实现:decayed_lear...转载 2018-11-25 11:08:26 · 435 阅读 · 0 评论 -
tf.add_to_collection,tf.get_collection和tf.add_n的用法
tf.add_to_collection:把变量放入一个集合,把很多变量变成一个列表tf.get_collection:从一个结合中取出全部变量,是一个列表 tf.add_n:把一个列表的东西都依次加起来例如:import tensorflow as tf;import numpy as np;import matplotlib.pyplot as plt;v1 = ...转载 2018-11-25 11:05:22 · 412 阅读 · 0 评论 -
Global average Pooling
最近在看关于cifar10 的分类的识别的文章在看all convolution network 中看到中用到一个global average pooling 下面就介绍一下global average pooling 这个概念出自于 network in network 主要是用来解决全连接的问题,其主要是是将最后一层的特征图进行整张图的一个均值池化,形成一个特征点,将这些...转载 2018-11-12 17:00:52 · 311 阅读 · 0 评论 -
numpy中mgrid与meshgrid的区别
https://blog.youkuaiyun.com/tymatlab/article/details/79027162mgrid[[1:3:3j, 4:5:2j]] 3j:3个点步长为复数表示点数,左闭右闭 步长为实数表示间隔,左闭右开参见:meshgrid mgrid ...转载 2018-11-12 21:51:50 · 462 阅读 · 0 评论 -
先验概率和后验概率理解
对于统计学只是皮毛认识,在学校时根本不重视,如今机器学习几乎以统计学为基础发展起来的,头疼的紧,如今还得琢磨基础概念。1、我自己的理解:1)先验:统计历史上的经验而知当下发生的概率;2)后验:当下由因及果的概率;2、网上有个例子说的透彻:1)先验——根据若干年的统计(经验)或者气候(常识),某地方下雨的概率;2)似然——下雨(果)的时候有乌云(因/证据/观察的数据)的概率,...转载 2018-11-02 19:50:19 · 14400 阅读 · 2 评论 -
iou(交并比)的概念
交并比(Intersection-over-Union,IoU),目标检测中使用的一个概念,是产生的候选框(candidate bound)与原标记框(ground truth bound)的交叠率,即它们的交集与并集的比值。最理想情况是完全重叠,即比值为1。计算公式:def calculateIoU(candidateBound, groundTr...转载 2018-11-02 13:04:52 · 16738 阅读 · 4 评论 -
tf.split()函数的用法
from PIL import Imageimport numpy as npimport tensorflow as tf''' split 对维度进行分割 tf.split( data, 数据图片 ( 300*600*3) num_or_size_splits , 分割的数组 传个数 ...原创 2018-09-19 16:31:31 · 2378 阅读 · 0 评论 -
深度学习中的感受野计算
https://blog.youkuaiyun.com/kuaitoukid/article/details/46829355https://blog.youkuaiyun.com/hungryof/article/details/50241351概念:感受野(receive field)是指当前feature map中的一个原子点P与输入层中多少个原子个数相关的问题,假设输入层相关的点为(RF*RF)个(假...转载 2018-09-13 19:33:29 · 2395 阅读 · 3 评论 -
关于tfrecord写入和取出图片的维度不同
写入:ima = img_array[index][1].tobytes()example = tf.train.Example( features=tf.train.Features( feature={ 'label': _int64_feature( int(img_array[index][0])), # label ...原创 2018-09-13 09:06:54 · 788 阅读 · 12 评论 -
AttributeError: module 'argparse' has no attribute 'ArgumentParser'
原因是我的文件名和包名一样了,修改下python的文件名即可。原创 2018-07-20 19:32:08 · 10549 阅读 · 2 评论 -
TensorFlow图像处理函数
1. 读取图片import matplotlib.pyplot as pltimport tensorflow as tfimport numpy as npimage_raw_data = tf.gfile.FastGFile('./datasets/cat.png','rb').read()with tf.Session() as sess: image_data = tf...原创 2018-07-14 19:24:05 · 1594 阅读 · 5 评论 -
tensorflow中的lrn函数详解
LRN函数类似DROPOUT和数据增强作为relu激励之后防止数据过拟合而提出的一种处理方法,全称是 local response normalization--局部响应标准化。这个函数很少使用,基本上被类似DROPOUT这样的方法取代,具体原理还是值得一看的函数原型def lrn(input, depth_radius=None, bias=None, alpha=None, beta=None...转载 2018-06-10 13:15:21 · 754 阅读 · 0 评论 -
tensorflow bias_add
import tensorflow as tfa=tf.constant([[1,1],[2,2],[3,3]],dtype=tf.float32)b=tf.constant([1,-1],dtype=tf.float32)c=tf.constant([1],dtype=tf.float32)with tf.Session() as sess: print('bias_ad...转载 2018-06-10 12:54:47 · 1833 阅读 · 0 评论 -
TensorFlow - tf.multiply和tf.matmul 区别
a# [[1, 2, 3],# [4, 5, 6]] a = tf.constant([1, 2, 3, 4, 5, 6], shape=[2, 3])# b1# [[ 7, 8],# [ 9, 10],# [11, 12]] b1 = tf.constant([7, 8, 9, 10, 11, 12], shape=[3, 2])#b2#[[ 7 8 9]# ...转载 2018-06-09 17:17:31 · 671 阅读 · 0 评论 -
TensorFlow中的tf.app.flags使用
import tensorflow as tf#参数说明 (变量名,值,说明)tf.app.flags.DEFINE_string( 'master', 'variable', 'The address of the TensorFlow master to use.')tf.app.flags.DEFINE_integer( 'worker_replicas', 1,...原创 2018-06-24 10:44:11 · 964 阅读 · 1 评论 -
深度学习 计算机视觉 python opencv
https://www.bilibili.com/video/av23546891/?p=2原创 2018-06-23 10:02:40 · 727 阅读 · 0 评论 -
Tensorflow中tf.train.exponential_decay函数(指数衰减法)
在Tensorflow中,为解决设定学习率(learning rate)问题,提供了指数衰减法来解决。通过tf.train.exponential_decay函数实现指数衰减学习率。步骤:1.首先使用较大学习率(目的:为快速得到一个比较优的解); 2.然后通过迭代逐步减小学习率(目的:为使模型在训练后期更加稳定);代码实现:decayed_learning_rate=lea...转载 2018-06-12 21:44:13 · 1777 阅读 · 0 评论 -
tf.clip_by_value()
tf.clip_by_value(v,a,b) 功能:可以将一个张量中的数值限制在一个范围之内。(可以避免一些运算错误) 参数:(1)v:input数据(2)a、b是对数据的限制。 当v小于a时,输出a; 当v大于a小于b时,输出原值; 当v大于b时,输出b; 例子:import tensorflow as tfv=tf.constant([[1.0,2.0,3.0],[4.0,5.0,6.0...转载 2018-06-12 20:33:22 · 3195 阅读 · 0 评论 -
tensorflow中的stack与numpy切片
import numpy as npimport tensorflow as tfa = np.array([ [1,2,3], [4,5,6], [7,8,9]])#矩阵 a[:] 于a[:,]区别print(a[:1]) #按照行输出print(a[:,1]) #输出第二列print(a[:2])''' For example:...原创 2018-05-29 14:32:26 · 496 阅读 · 0 评论 -
tf.argmax()以及axis解析
用tensorflow做CNN_TEXT文本分类时,看到这个API,然后去官网查了一下,再看了一下别的资料,算是明白它的处理方式了。 首先,明确一点,tf.argmax可以认为就是np.argmax。tensorflow使用numpy实现的这个API。 简单的说,tf.argmax就是返回最大的那个数值所在的下标。 这个很好理解,只是tf.argmax()的参数让人有些迷惑,...转载 2018-05-28 14:09:23 · 1610 阅读 · 0 评论 -
tensorflow中slim详解
1.变量的定义 from __future__ import absolute_importfrom __future__ import divisionfrom __future__ import print_functionimport tensorflow as tfslim = tf.contrib.slim#模型变量weights = slim.mod...原创 2018-08-03 16:47:13 · 1526 阅读 · 0 评论