tensorflow
文章平均质量分 82
starxhong
毕业于华中科技大学,具有模式识别与智能系统硕士学位,现从业于广告智能推荐领域。
展开
-
tensorflow笔记之二十九——通过if条件分支理解graph构建
1.从训练到推理过程模型文件形态sess.run模式下,tensorflow在训练过程中,通常使用saver = tf.train.Saver()和saver.save()保存模型,一次 saver.save() 后会生成ckpt文件,这里的ckpt文件并不是1个文件而是4个文件,模型权重数据和模型结构是分开保存。在推理场景下,一般使用tensorflow提供的freeze_graph函数,将权重数据和模型结构合并为pb格式的文件,...原创 2021-10-26 22:30:06 · 796 阅读 · 0 评论 -
tensorflow笔记之二十八——带掩码的损失函数
一个应用场景在多标签问题中,有时候需要一些特殊的处理,比如一些样本只对部分class进行更新,而另一些样本对另外一些class进行更新。举个例子,我们预测一个用户喜欢什么类型的电影,假如我们知道用户对哪些电影有过观看行为,这是正样本,负样本一般来说可以随机采样构造,构造也有两种方式,一个是固定用户随机采样电影,一个是固定电影随机采样用户,两种方式其实是等价的,不过考虑到随机采样用户可以覆盖到完全没有观影记录的用户,我们倾向于用后者(看电影的用户和不看电影的用户可能本身就有很大的不同了,如果train d原创 2021-10-26 13:10:39 · 1148 阅读 · 0 评论 -
tensorflow笔记(二十七)——重要tensor操作函数
1.合并多个tensor的合并主要包括2个函数:tf.concat和tf.stack,他们的输出参数都是list of tensor。区别是:tf.concat是沿某一维度拼接shape相同的张量,拼接生成的新张量维度不会增加。tf.stack是在新的维度上拼接,拼接后维度加1。import tensorflow as tfa = tf.constant([[1,2,3],[4,5,6]]) b = tf.constant([[7,8,9],[10,11,12]])ab1 = tf.con原创 2021-09-08 19:14:01 · 646 阅读 · 0 评论 -
tensorflow笔记(二十六)——tf.estimator模型文件保存和加载
1.模型的4个文件之前一次测试的时候,发现预测概率全部在0.5左右,最后发现是模型加载没有成功,预测结果其实是随机初始化的模型预测结果,所以概率都是0.5。怎么发现是模型没有加载成功呢?我把模型路径下的文件清空了之后预测,没有报错且预测概率就是0.5附近。然后为什么没有加载成功呢,是因为我的模型从平台存储空间上拷贝到测试机上时,只拷贝了model.ckpt-30000.data-00000-of-00001文件,这是不完整的。整个模型其实包含4个文件:model.ckpt-30000.data-000原创 2021-08-29 11:52:52 · 3164 阅读 · 0 评论 -
tensorflow笔记(二十五)——MultiLabelHead.loss代码走读
概述MuiltLabelHead是tf.estimator.Head的子类,用于多标签问题,默认损失函数为sigmoid_cross_entropy。具体的调用原创 2021-08-26 19:55:38 · 419 阅读 · 0 评论 -
tensorflow笔记(二十三)——tf.metrics
1.概述tf.metrics主要是实现了评估相关的各种指标函数,比如mean、precesion、auc、precession、mse、precesion_at_k等等。以tf1.15为例,主要包括:accuracy(...): Calculates how often predictions matches labels.auc(...): Computes the approximate AUC via a Riemann sum.average_precision_at_k(...): Com原创 2021-08-08 12:48:03 · 1584 阅读 · 0 评论 -
tensorflow笔记(二十二)—— Hooks
什么是Hooks?中文直译为“钩子”,在tensorflow中概念:Hooks are tools that run in the process of training/evaluation of the model.*Hooks是模型训练/测试过程中的工具,这些工具用于在训练/评估过程中执行特定任务。例如:控制训练EarlyStopping改变学习率打印一些中间日志保存checkpoint…这些hooks可以在以下几个地方生效,:when a session starts bei原创 2021-08-07 18:04:36 · 1619 阅读 · 0 评论 -
tensorflow笔记(二十)——estimator.evaluate源码走读
1.概述评估tensorflow.python.training.source code: https://github.com/tensorflow/tensorflow/blob/r1.15/tensorflow/python/training/evaluation.py原创 2021-08-05 11:09:22 · 1601 阅读 · 1 评论 -
tensorflow笔记(十九)——错误集锦
错误1,训练正常,预测和评估的时候报OOM:减少预测和训练的batchsize,或者减少网络参数。参考:ResourceExhaustedError (see above for traceback): OOM when allocating tensor of shape [7744,512] #3393原创 2021-08-03 16:37:25 · 1161 阅读 · 0 评论 -
Tensorflow笔记(八)——Estimator
知乎-TensorFlow之estimator详解原创 2021-07-23 21:54:22 · 1306 阅读 · 0 评论 -
tensorflow笔记(三)——损失函数
一、概述机器学习主要面对两类问题:回归和分类。不过一个问题属于分类还是回归的界定却并不清晰。比如点击率预估输入样本的Label是0-曝光和1-点击,输出的是用户点击的概率,是一个连续值,你说点击率是回归问题还是分类问题?从目标来看输出一个率值而非类别应该算回归,但从输入来看是标签离散的,应该算是分类。本质上这两类问题是一体两面的,分类模型可将回归模型的输出离散化,回归模型也可将分类模型的输出连续化,主要看任务目标是什么。分类和回归最大的不同可能在于对于损失函数的选择上。主要区别在于:损失函数的一般表示原创 2021-07-23 14:24:43 · 1374 阅读 · 0 评论 -
Tensorflow笔记(一)——Varibale和Scope
Variable两个函数Variable和get_variable函数都是获取变量,具体用哪个?tf.Variable(initial_value=None, trainable=True, collections=None, validate_shape=True, caching_device=None, name=None, variable_def=None, dtype=None, expected_shape=None, import_scope=None, constraint=None,原创 2021-07-17 23:46:00 · 147 阅读 · 0 评论 -
tensorflow各个版本的CUDA以及Cudnn版本对应关系
原文:https://blog.csdn.net/qq_27825451/article/details/89082978————————————————版权声明:本文为CSDN博主「LoveMIss-Y」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。原文链接:https://blog.csdn.net/qq_27825451/article/deta...转载 2019-11-11 12:35:42 · 1566 阅读 · 0 评论 -
How to compile Tensorflow with SSE4.2 and AVX instructions?
This is the message received from running a script to check if Tensorflow is working:Warning: The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machi原创 2017-08-11 23:19:48 · 1606 阅读 · 0 评论 -
Python PIP Install throws TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'
从source安装tensorflow时,安装到pip package命令 sudo pip install /tmp/tensorflow_pkg/tensorflow-1.2.1-py2-none-any.whl 报错: TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'...原创 2017-08-11 22:08:00 · 12428 阅读 · 0 评论 -
pycharm加入import路径
系统版本:unbantu16.0.4pycharm版本:pycharm-community-2017.2目标:导入cifar10step1: 下载tensorflows Models库,以便使用CIFAR-10数据的类。 git clone https://github.com/tensorflow/models.git 执行完成后,用户路径/home/star下可...原创 2017-08-11 13:27:15 · 37003 阅读 · 2 评论 -
The 'build' command is only supported from within a workspace-SOLVED
I install tensorflow by python-pip. it works but when i run my project, the IDE warns me that :"The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your mach原创 2017-08-09 22:27:28 · 8967 阅读 · 0 评论 -
tensorflow通过pip安装和手写数字检测
一、安装tensorflow安装 TensorFlow方法有很多:通过 Pip, Docker, Virtualenv, Anaconda 或 源码编译的方法。具体安装哪一种,看具体需求,比如操作系统是windows还是linux,是否需要单独编译等等。作为学习入门者,主要精力应该是尽快开启搭模型的阶段,而不是把大把时间花在各种坑爹的安装上。我在windows系统下用virtu原创 2017-08-02 19:33:58 · 466 阅读 · 0 评论 -
tensorflow写一个简单的CNN
# coding=utf-8from tensorflow.examples.tutorials.mnist import input_dataimport tensorflow as tfmnist = input_data.read_data_sets('/home/star/MNIST_data', one_hot=True)sess = tf.InteractiveSession...原创 2017-08-09 17:56:16 · 501 阅读 · 0 评论 -
Mutiple-layer_perceptron(MLP)
# coding=utf-8from tensorflow.examples.tutorials.mnist import input_dataimport tensorflow as tfmnist = input_data.read_data_sets('/home/star/MNIST_data/', one_hot= True)sess = tf.InteractiveSessi原创 2017-08-09 10:18:02 · 468 阅读 · 0 评论 -
SoftmaxRegression
import tensorflow as tffrom tensorflow.examples.tutorials.mnist import input_datamnist = input_data.read_data_sets('/home/star/MNIST_data/', one_hot=True)sess = tf.InteractiveSession()x = tf.plac原创 2017-08-07 22:00:16 · 238 阅读 · 0 评论 -
autoencoder
import numpy as npimport sklearn.preprocessing as prepimport tensorflow as tffrom tensorflow.examples.tutorials.mnist import input_data#initialize parameter with xavier#Yoshua Bengio indecate th原创 2017-08-07 20:46:06 · 714 阅读 · 0 评论