
tensorflow
文章平均质量分 89
TinaO-O
这个作者很懒,什么都没留下…
展开
-
分布式运算白花钱警告:使用tensorflow分布式必须注意ps server空耗资源
为武汉祈祷。ps server 不会主动停止,无论在什么情况下。这个问题从2016年提出,到现在,也没有一个简洁干净的解决方式,而这个问题会很严重,如果你使用的是租用资源,会白白花费很多钱钱。我注意到,ps server不论是使用gpu还是cpu资源都不会主动停止,即使worker已经训练完停止了,甚至是遇到错误,ps server仍旧会运行。 这就会导致这个进程对节点资源的持续占有,即使...原创 2020-02-19 02:05:48 · 1033 阅读 · 2 评论 -
几个小时 几行代码 简单 直白 tensorflow 分布式代码实战
北京又下雪了,这个2020年开启的方式太沉重了。我本人对tf并不精通。分布式听起来也很复杂。而且我要做的是将deeplabv3+的代码做成分布式的。也就是多个节点,相当于用两台服务器的gpu。听起来很麻烦,实际上居然很简单。而我自己也是花了几个小时从什么都不懂到代码跑起来。很多教程写了特别长的文字,我认为画图更简单。本教程尽量简短,好懂,并且有代码。只是基础教程,不能做到自创多GPU损失计...原创 2020-02-12 01:36:01 · 1132 阅读 · 9 评论 -
GPU有限,如何提高batch size
那么从:https://github.com/mathildor/DeepLab-v3/blob/master/g3doc/faq.mddeeplabv3+也是谷歌团队,tensorflow就是他们的产品。可以看到提高batch size 的方法。batchsize不仅对于batch normalization至关重要,而且梯度下降也需要一定的batchsize,比如batchsize...原创 2019-10-29 14:29:12 · 2448 阅读 · 1 评论 -
官方代码检测tensorflow gpu版本能不能使用GPU
import tensorflow as tftf.test.is_gpu_available()如下:告诉你gpu情况是可用的。如果T:\src\github\tensorflow\tensorflow\core\platform\cpu_feature_guard.cc:141] Your CPU supports instructions that this Tens...原创 2019-06-21 09:50:28 · 7419 阅读 · 5 评论 -
ValueError: Index out of range using input dim 2; input has only 2 dims for 'crf_1/strided_slice' (o
ValueError: Index out of range using input dim 2; input has only 2 dims for 'crf_1/strided_slice' (op: 'StridedSlice') with input shapes: [?,110], [3], [3], [3] and with computed input tensors: input[...原创 2019-06-25 17:55:46 · 5370 阅读 · 0 评论 -
ubuntu安装tensorflow2.0 beta1 gpu版本(4步)conda anaconda
你需要安装anaconda3.这里就省略了实际上安装就是下载加一句代码。很简单。下面主要说怎么安装tf21.创建conda虚拟环境名叫tf2conda create -n tf2python=3.62激活环境conda activate tf23.安装下面由于清华源安装不成功,所以我临时使用的是豆瓣源,成功的pip install tensorflow-gpu=...原创 2019-06-18 10:22:20 · 2506 阅读 · 1 评论 -
keras tensorflow session
获取keras已经建立的session:from keras import backend as Ksess = K.get_session()给keras设置传递一个建立好的session:K.set_session(sess)参考:https://stackoverflow.com/questions/53653303/where-is-the-tensorflow-...原创 2019-07-02 17:11:05 · 9599 阅读 · 7 评论 -
tensorflow deeplab3+ build_voc2012_data 代码阅读
官方的代码,因为目前市面上有三个版本tf官方,keras,pytorch,但是keras在训练finetune达到原始的识别率有问题,pytorch也有问题,没法复现,因为目前backbone是xception。其他两个我就不给连接了,github一搜就有。主要看官方的:https://github.com/tensorflow/models/tree/master/research/de...原创 2019-07-22 17:09:23 · 1206 阅读 · 8 评论 -
deeplabv3+二:详细代码解读 data generator 数据生成器
3+支持三种数据库,voc2012,cityscapes,ade20k,代码文件夹-deeplab -datasets -data_generator.py在开始之前,始终记住,网络模型的输入是非常简单的image,规格化到[-1,1]或[0,1],或者数据扩增(水平翻转,随机裁剪,明暗变化,模糊),以及一个实施了相同数据扩增的label(毕竟需要pixe...原创 2019-07-23 15:50:45 · 3141 阅读 · 0 评论 -
Tensorflow TFRecord: Can't parse serialized example
原因就是你的数据是串数据,但是你用FixedLenFeature读取,改函数有个参数是需要输入形状的。 'image/width': tf.FixedLenFeature(shape=(), tf.int64, default_value=0),比如这个,由于宽度是个常数,所以shape直接省略了,但是你的是[1,2,3,3]这种就不能省,要不你将shape填写上...原创 2019-09-03 14:25:40 · 1011 阅读 · 0 评论 -
tensorflow:超简单易懂 tensor list的使用 张量数组的使用 扩增 建立 append
构造张量数组:最简单的方式:tensor_list=[tensor1,tensor2]常用的方式(这个方式可以用于for循环)tensor_list=[]tensor_list.append(tensor1)tensor_list.append(tensor2)张量数组的使用批量处理张量数组里面的张量,之后将其存储到一个新的张量数组中new_tensor_l...原创 2019-09-03 21:49:20 · 7285 阅读 · 0 评论 -
deeplabv3+: 输入模块全解析 输入数据 更多维度 多标注
之前已经讲过了generator,这次是要建立一个更详细的框架,数据到底怎么被处理的。可以作为样例学习。写的并不详细,因为你如果要做更深的工作,你需要很高自主能力,大多数人都具备,所以我就不废话了(主要是忙)。源数据:图片/矩阵目标数据:tensorflow 标准的Dataset主要过程:源数据->build_voc_data.py->tfrecord tfrecor...原创 2019-09-04 10:47:04 · 1523 阅读 · 2 评论 -
【Tensorflow】slim.arg_scope()的使用
简单直观的教程:https://zhuanlan.zhihu.com/p/35203106这里单独做个总结笔记,详细的去看上面那个网址。一个好例子胜过千言万语arg_scope是为了偷懒与整洁。打个比方,arg_scope想给自己的小弟寄送一些贺卡了,但是由于他比较懒,祝福语写的都一样,他就想群发,第一个参数就是他小弟的名字,后面的参数就是贺卡内容。直白来讲,arg_scop...原创 2019-09-07 13:30:16 · 568 阅读 · 3 评论 -
tf.cond tensorflow的逻辑控制 if else
tf.cond使用方法z = tf.multiply(a, b)result = tf.cond(x < y, lambda: tf.add(x, z), lambda: tf.square(y))tf.cond(判断语句,执行一,执行二)如果有复合逻辑运算,代码:import tensorflow as tfimport numpy as npa_np =...原创 2019-09-19 09:44:36 · 4266 阅读 · 0 评论 -
tensorflow 常用简单的函数收集 cond expand_dims squeeze map_fn
1.条件函数,替代 if else在tensorflow里面不能使用if else对bool型tensor进行判断。所以需要使用tf.condhttps://blog.youkuaiyun.com/u013249853/article/details/101012523x = tf.constant(2)y = tf.constant(5)def f1(): return tf.multip...原创 2019-09-19 13:50:54 · 254 阅读 · 0 评论 -
tensorflow 图像两种变形方式
还有一种是padding,可以防止图片变形,但是结果并不会比较好,因为pad了过多无关因素,所以我们不用这个。1.适用于标签,利用最近邻的数值填充:tf.image.resize_nearest_neighbor( tf.expand_dims(label, 0), new_dim, align_corners=True)2.适用于图像...原创 2019-09-20 14:01:36 · 708 阅读 · 0 评论 -
keras data generator 调试
在写了代码:https://blog.youkuaiyun.com/u013249853/article/details/90408122之后,我们希望能够看到,每次到底生成了什么因为如果你有数据扩增的代码,你就会想知道我生成的对不对,能不能调试,那么简单直观的调试代码如下[a,b] = training_generator.__getitem__(1)validation_generat...原创 2019-05-27 14:02:34 · 909 阅读 · 0 评论 -
tf.map_fn 处理多输入 tensorflow batch 内张量操作,降低api困难程度 数据降维 不考虑batch 大小
tf.map_fn数据结构,我的数据如下大小:batch_size=2内含两个张量input1.size=[?, 640,480,128]input2.size=[?,640,480]张量函数 希望没有batch_size,即输入不含?这个维度:[640,480,128], [640,480], 我希望tensorflow能够自动的对batch内的张量函数操作.函数f...原创 2019-05-16 20:57:41 · 1324 阅读 · 0 评论 -
ubuntu 安装tfplot windows直接下载安装
官网那么一共有两种方式安装:一种直接用pip:pip install tensorflow-plot还有一种是能获取最新的:pip install git+https://github.com/wookayin/tensorflow-plot.git@master另外作者还说了只兼容tf1.x版本,2.x就是future work了。还有一些速度上的,兼容上的问题,请...原创 2019-03-18 12:21:34 · 1245 阅读 · 0 评论 -
tensorflow 占位符
tensorflow的占位符本质就是先声明数据类型,以便建立模型时申请内存。在这里声明的:https://github.com/tensorflow/tensorflow/blob/r1.13/tensorflow/python/ops/array_ops.pytf.placeholder( dtype, shape=None, name=None)需...原创 2019-03-26 10:41:39 · 5299 阅读 · 0 评论 -
python3 匿名函数 与 生成器
对于keras来讲,这两个概念很重要。匿名函数很简单,有时候我们的函数很简单,我们就会想要偷个懒,不想再单独出去定义新的方法,现在立刻马上就顺手写个函数。这时就需要匿名函数。比如map(func(),list)的作用是将list当中的每个元素都当作参数输入到func()这个函数中。如果我就做个x*x操作,就可以简单的写道:list_a = list(range(10))prin...原创 2019-04-04 08:39:05 · 304 阅读 · 3 评论 -
keras.layer.input()
tenserflow建立网络由于先建立静态的graph,所以没有数据,用placeholder来占位好申请内存。那么keras的layer类其实是一个方便的直接帮你建立深度网络中的layer的类。该类继承了object,是个基础的类,后续的诸如input_layer类都会继承与layer由于model.py中利用这个方法建立网络,所以仔细看一下:他的说明详尽而丰富。input()这...原创 2019-04-02 08:45:32 · 23638 阅读 · 0 评论 -
mask rcnn 之coco.py 解读
代码来自:https://github.com/matterport/Mask_RCNN使用coco.py的命令行代码是这样写的:你可以选择谷歌翻译。# Train a new model starting from pre-trained COCO weightspython3 samples/coco/coco.py train --dataset=/path/to/coco/...原创 2019-03-29 13:27:33 · 3684 阅读 · 9 评论 -
超简单的keras函数模型教程
from keras.models import Modelfrom keras.layers import Input, Dense, Lambdaa = Input(shape=(640, 480, 3))b = Input(shape=(23,))c = Input(shape=(54,))d = Dense(32)(b)multi = Lambda(lambda x: x*...原创 2019-04-09 10:59:15 · 735 阅读 · 0 评论 -
keras optimizers 优化器
优化器就是向模型打包传递参数,什么参数呢,就是我们训练时使用到的诸如,学习率,衰减,momentum,梯度下降得到若干种方式,用不用动量等等。你可以在一开始传入这个值,然后就一直使用这个值训练,也可以在训练时根据epoch调整参数。optimizers的两种使用方式一,在使用compile调用之前就生成自定义的optimizer实例,这种给用户的自由最大,但是同样的你也需要定义很多个参数:...原创 2019-04-09 15:26:59 · 12884 阅读 · 5 评论 -
keras 拼接两个函数api 为修改backbone并且使用其权重做准备
这个代码网络是model2,他用了我之前写的model_mine的网络结构。from keras.models import Modelfrom keras.layers import Input, Dense, Lambda,adda = Input(shape=(640, 480, 3))b = Input(shape=(23,))c = Input(shape=(54,...原创 2019-04-09 16:36:53 · 1034 阅读 · 0 评论 -
tensorflow 生成指定大小的赋值0的张量 np.zeros 在TF中对应的语句 生成全0张量
语句结构:tf.zeros( shape, dtype=tf.float32, name=None)举例:tf.zeros([3, 4], tf.int32)最主要的是,shape可以接收1D张量。所以你可以tfshape = tf.shape(tensor1)tensor2 = tf.zeros(shape=tfshape, ...原创 2019-05-13 21:57:00 · 4776 阅读 · 0 评论 -
AttributeError: module 'tensorflow.math' has no attribute 'bincount' 类似问题
如果是pycharm 还可能出现:“Cannot find reference 'bincount' in '__init__.py' less... (Ctrl+F1)Inspection info: This inspection detects names that should resolve but don't. Due to dynamic dispatch and duck ...原创 2019-05-09 09:59:24 · 4934 阅读 · 0 评论 -
在线免费 简单易用的Colaboratory 浏览器就能解决 深度学习环境难以安装,硬件成本高
Colaboratory 是一个在线编程,使用云端环境的深度学习工具。你不需要有一台好的电脑,好的GPU,也不需要折腾环境两三天(因为你没用anaconda),就可以马上上手开始tensorflow的等深度学习框架的使用,学习。tensorflow :https://colab.research.google.com/github/tensorflow/tensor2tensor/blob...原创 2019-05-15 11:22:49 · 368 阅读 · 0 评论 -
tensorflow output_data[output_id == i] = input_data[input_id == i]代码分析
import tensorflow as tfimport osos.environ['CUDA_VISIBLE_DEVICES'] = '1'with tf.Graph().as_default(), tf.Session() as sess: input_data = tf.constant([0.1, 0.2, 0.3]) input_ids = tf.consta...原创 2019-05-14 17:34:43 · 376 阅读 · 0 评论 -
keras tensorflow 获取张量形状 返回 list 直接得到数值 类型转换
seg是一个tensor high_res = seg.get_shape().as_list()high_res就是list类型了如果是keras,那么同样一句代码:shape = K.int_shape(x)原创 2019-05-07 15:58:22 · 3459 阅读 · 0 评论 -
tensorflow int 与 float 相互转换 代码
#float->intint_data = tf.to_int32(float_data)#int->floatfloat_data = tf.to_float32(int_data)同样的如果要64位的只需要#float->intint_data = tf.toint64(float_data)#int->floatfloat_data = tf....原创 2019-05-15 14:42:58 · 14180 阅读 · 1 评论 -
二:mask RCNN ——jupyter notebook mask rcnn
默认你已经安装好环境了。以下教程完全遵照官网。并且从官网下载好代码包了:https://github.com/matterport/Mask_RCNN,注意不是detrecton那个直接到setup.py路径,也就是根路径python3 setup.py install看下都干啥了:WARNING:root:Fail load requirements file, so...原创 2018-12-04 09:13:08 · 2553 阅读 · 0 评论