
Tensorflow
mjiansun
Live and Learn.
展开
-
【Tensorflow】反卷积是如何实现的
注意:tensorflow是指定了output_shape的,但是keras的output是计算出来的,所以keras的具体输出形状还是得打印出来看了才能知道,或者自己到相应的计算函数中查看。tensorflow反卷积是如何实现的?卷积的输出尺寸:tensorflow官方是这么写的,其中,VALID时的padding数为:如果p为奇数就是左奇右...转载 2019-08-15 11:12:00 · 1081 阅读 · 1 评论 -
tf.slice()介绍
函数:tf.slice(inputs, begin, size, name)作用:从列表、数组、张量等对象中抽取一部分数据begin和size是两个多维列表,他们共同决定了要抽取的数据的开始和结束位置begin表示从inputs的哪几个维度上的哪个元素开始抽取size表示在inputs的各个维度上抽取的元素个数若begin[]或size[]中出现-1,表示抽取对应维度上的所有元素import tensorflow as tf import numpy as np x=[[1,转载 2022-02-17 15:06:35 · 173 阅读 · 0 评论 -
keras和Tensorflow同时加载多个模型,以及与keras模型混用
Tensorflow同时加载使用多个模型(keras同理,只要是tf的后端)Tensorflow,所有操作对象都包装在相应的session中,所以想要使用不同的模型就要将这些模型加载到不同session中,并且声明使用的时候申请是哪个session,从而避免由于session和想使用的模型不匹配导致错误,而使用多个graph就需要为每个graph使用不同的session,但是每个graph也可以在多个session中使用,这个时候就需要在每个session中使用的时候明确使用的graph。g1 =转载 2020-08-07 11:00:04 · 1680 阅读 · 6 评论 -
Tensorflow同时加载使用多个模型
在Tensorflow中,所有操作对象都包装到相应的Session中的,所以想要使用不同的模型就需要将这些模型加载到不同的Session中并在使用的时候申明是哪个Session,从而避免由于Session和想使用的模型不匹配导致的错误。而使用多个graph,就需要为每个graph使用不同的Session,但是每个graph也可以在多个Session中使用,这个时候就需要在每个Session使用的时候明确申明使用的graph。g1 = tf.Graph() # 加载到Session 1的graphg2转载 2020-05-15 10:47:33 · 1274 阅读 · 0 评论 -
【TensorFlow】安装TensorFlow问题 解决Cannot uninstall 'wrapt'. It is a distutils installed project
cmd安装 pip install tensorflow1.遇到了ERROR: Cannot uninstall 'wrapt'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a ...转载 2019-12-31 17:40:50 · 539 阅读 · 0 评论 -
【Tensorflow】tf.import_graph_def
tf.import_graph_deftf.import_graph_def( graph_def, input_map=None, return_elements=None, name=None, op_dict=None, producer_op_list=None)定义:tensorflow/python/framework/imp...转载 2019-11-25 17:29:03 · 751 阅读 · 0 评论 -
从源码求证tensorflow中os.environ["TF_CPP_MIN_LOG_LEVEL"]的值的含义
看代码时遇到了os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'这样一句话,于是开始百度,是设置log输出信息的,也就是程序运行时系统打印的信息。但是发现有两种答案:一种是这样说的还有一种是这样说的… …一脸懵逼?所以去找了源码看(找了半天?,还是C++写的),如下:应该很明了了。稍微解释下:1、log信息共有四个等级,按重要性...转载 2019-11-25 10:38:36 · 178 阅读 · 0 评论 -
ImportError: cannot import name '_validate_lengths'
找到:Anaconda3/lib/python3.6/site-packages/numpy/lib/arraypad.py 954行,添加下面两个函数保存,重新加载即可消除错误def _normalize_shape(ndarray, shape, cast_to_int=True): """ Private function which does some chec...转载 2019-11-08 14:07:16 · 197 阅读 · 0 评论 -
pycharm加载tensorflow时出错 - 找不到“cudart64_100.dll”
之前nvidia 已经装好了,后来系统出了点故障,就在环境变量里 鼓捣了半天不小心把%PATH%变量中:C:\ Program Files \ NVIDIA GPU计算工具包\ CUDA \ v10.0 \ bin下的bin 目录漏掉了,之后添加上之后还是报错。解决办法:1. 不太推荐:重新启动计算机来传播所有更改2. 简单:如果使用的是intellij或pycharm,重新启...转载 2019-11-08 13:46:49 · 457 阅读 · 0 评论 -
tensorflow升级至1.14.0出现问题及解决方法
目录解决ModuleNotFoundError: No module named numpy.core._multiarray_umath' 错误一、错误原因分析二、解决方式解决python调用TensorFlow时出现FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecate第一种...转载 2019-11-08 11:16:07 · 5820 阅读 · 0 评论 -
【TensorFlow】tf.gather_nd
函数:tf.gather_ndgather_nd( params, indices, name=None)参见指南:张量变换>分割和连接将参数中的切片收集到由索引指定的形状的张量中.索引(indices)是一个 k 维整数张量,最好作为一个 (k-1) 维的索引(indices)张量的参数,其中每个元素定义了一个参数切片:output[i_...转载 2019-10-23 13:23:45 · 890 阅读 · 0 评论 -
【Tensorflow】tile
import tensorflow as tfboxes1 = tf.constant([[1,2,3,4],[4,5,6,7],[1,2,3,4],[4,5,6,7],[1,2,3,4],[4,5,6,7]])b1 = tf.tile(tf.expand_dims(boxes1, 1), [1, 1, 5])sess = tf.S...原创 2019-10-22 16:04:15 · 195 阅读 · 0 评论 -
【Tensorflow】tf.boolean_mask()
tf.boolean_mask()函数的使用,顺便学习>和<逻辑表达式在做目标检测(YOLO)时涉及到一个函数boolean_mask(a,b)将使a (m维)矩阵仅保留与b中“True”元素同下标的部分。使用tf.boolean_mask用来过滤概率值比较低的锚盒,这个函数的一个参数b为滤波器掩模,生成掩模要用到逻辑表达式(>或者<)生成布尔值,假设阈值thresho...转载 2019-10-21 16:47:00 · 384 阅读 · 0 评论 -
【Tensorflow】tf.image.non_max_suppression()
在吴恩达老师深度学习yolo算法实现自动驾驶的编程题中出现了这个函数,这个函数的功能是在检测算法中我们的一个目标被检测了多次,如何排除掉多余的边界框。比如下面的图,来自于编程题中的图片,下面的这个车被多次检测到,存在多个边界框,保留概率最大的那个,去除掉与这个概率最大的边界框的IoU大于一个阙值的其余边界框。这个过程就成为非最大值抑制=NMS函数原型:tf.image.non_max...转载 2019-10-21 14:56:00 · 1713 阅读 · 0 评论 -
【CBAM】注意力模型CBAM
论文:CBAM: Convolutional Block Attention Module官方代码:https://github.com/Jongchan/attention-moduleConvolutional Block Attention Module (CBAM) 表示卷积模块的注意力机制模块。是一种结合了空间(spatial)和通道(channel)的注意力机制模块。相...转载 2019-10-14 15:55:11 · 2430 阅读 · 0 评论 -
【Tensorflow】tf.sets.set_intersection
import tensorflow as tfimport collections# Represent the following array of sets as a sparse tensor:# a = np.array([[{1, 2}, {3}], [{4}, {5, 6}]])a = collections.OrderedDict([ ((0, 0, 0), 1)...原创 2019-09-12 09:19:07 · 2098 阅读 · 0 评论 -
【TensorFlow】tf.where
官方APITensorFlow中文社区tf.wheretf.where(input, name=None)`Returns locations of true values in a boolean tensor.This operation returns the coordinates of true elements in input. The coordinates are...转载 2019-09-11 13:36:28 · 356 阅读 · 0 评论 -
tensorflow AttributeError: 'module' object has no attribute 'cpu_count'
参考:Tensorboard AttributeError: ‘module’ object has no attribute ‘cpu_count’解决方案:sudo pip install --upgrade psutil原创 2017-06-12 21:07:48 · 2796 阅读 · 0 评论 -
tensorflow读取数据
http://www.cnblogs.com/Charles-Wan/p/6197019.html转载 2017-08-16 20:30:24 · 414 阅读 · 0 评论 -
超智能体,tensorflow
https://yjango.gitbooks.io/superorganism/content/转载 2017-07-27 20:40:51 · 1889 阅读 · 1 评论 -
tensorflow学习之常用函数总结:tensorflow官方例子中的诸如tf.reduce_mean()这类函数
前言tensorflow官网给的例子用到了很多函数,然后并没有具体说明,还要自己去翻文档,有些函数是很常用的,下面来一一总结。正文一,tensorflow中有一类在tensor的某一维度上求值的函数。如:求最大值tf.reduce_max(input_tensor, reduction_indices=None, keep_dims=False, name=No转载 2017-08-07 14:29:43 · 404 阅读 · 0 评论 -
tensorflow点滴(1)
tf.nn.max_pool中padding的2种形式'SAME','VALID'的差别import tensorflow as tfimport numpy as npa= np.random.randint(9,size=(1,9,9,1))print(np.squeeze(a))cons = tf.constant(value=a,dtype=tf.float32,shap原创 2017-08-15 20:34:39 · 310 阅读 · 0 评论 -
Tensorflow不同版本要求与CUDA及CUDNN版本对应关系
cuda、cudnn与tensorflow版本下载https://github.com/fo40225/tensorflow-windows-wheelcudnn和cuda的关系:https://blog.youkuaiyun.com/u013066730/article/details/80980940亲自尝试成功的版本号对应:(1)win10,cuda10.0,cudnn-10.0-wind...转载 2019-03-27 15:01:35 · 28156 阅读 · 8 评论 -
查看已安装tensorflow版本
由于tensorflow版本不同,可能一些函数的调用也有变换,这时候可能需要查看tensorflow版本,可以在终端输入查询命令如下:pythonimport tensorflow as tftf.__version__查询tensorflow安装路径为:tf.__path__查询结果如下:...转载 2019-07-25 09:14:34 · 4489 阅读 · 2 评论 -
【Tensorflow】tf.pad解析
tf.pad的作用是填充它的表达式如下:pad( tensor, paddings, mode='CONSTANT', name=None)1、tensor是要填充的张量2、padings也是一个张量,代表每一维填充多少行/列,但是有一个要求它的rank一定要和tensor的rank是一样的3、mode可以取三个值,分别是"CONSTANT"...转载 2019-08-04 17:26:22 · 282 阅读 · 0 评论 -
【Tensorflow】tf.Assert()
tf.Assert() 根据条件打印数据参数:tf.Assert( condition,//条件 data,//数据 summarize=None, name=None)如果 condition 的结果为假,请打印 data 中的张量列表,summarize 用来确定要打印的张量的条目数量.注意:为了确保断言执行,通常会附加依赖关系。使用案例...转载 2019-08-05 09:39:50 · 1449 阅读 · 0 评论 -
【Tensorflow】tf.boolean_mask()
函数原型:tf.boolean_mask(tensor,mask,name='boolean_mask',axis=None)跟numpy里面的tensor[mask]具有相同的功能。参数:tensor是N维度的tensor,mask是K维度的,注意K小于等于N,name可选项也就是这个操作的名字,axis是一个0维度的int型tensor,表示的是从参数tensor的哪个axis开始ma...转载 2019-08-05 09:51:04 · 1014 阅读 · 0 评论 -
【Tensorflow】tf.equal()用法
tensorflow 中tf.equal()用法:equal(x, y, name=None)equal,相等的意思。顾名思义,就是判断,x, y 是不是相等,它的判断方法不是整体判断,而是逐个元素进行判断,如果相等就是True,不相等,就是False。由于是逐个元素判断,所以x,y 的维度要一致。看个例子:import tensorflow as tfa = [[1...转载 2019-08-13 18:52:33 · 2252 阅读 · 0 评论 -
【Tensorflow】tf.split()函数的用法
tf.split( value, num_or_size_splits, axis=0, num=None, name='split')根据官方文档的说法这个函数的用途简单说就是把一个张量划分成几个子张量。value:准备切分的张量num_or_size_splits:准备切成几份axis : 准备在第几个维度上进行切割其中分割方式...转载 2019-08-23 18:27:17 · 2920 阅读 · 0 评论 -
【Tensorflow】tf.image.crop_and_resize的使用
tf.image.crop_and_resize(image,boxes,box_ind,crop_size,method='bilinear',extrapolation_value=0,name=None)上面是函数的相关参数,首先必须说明官网中有输入tensor的要求,但是我直接输入值也是可以的。这里进行相应的解释...转载 2019-09-06 17:22:10 · 2210 阅读 · 0 评论 -
TensorFlow保存和加载训练模型
http://blog.youkuaiyun.com/jasonzhangoo/article/details/60756590对于机器学习,尤其是深度学习DL的算法,模型训练可能很耗时,几个小时或者几天,所以如果是测试模块出了问题,每次都要重新运行就显得很浪费时间,所以如果训练部分没有问题,那么可以直接将训练的模型保存起来,然后下次运行直接加载模型,然后进行测试很方便。在tensorflow中保转载 2017-07-12 12:16:41 · 470 阅读 · 0 评论