tf的一些基本用法
1、tf.where
https://blog.csdn.net/ustbbsy/article/details/79564828
2、tf.less
tf.less(x,y,name=None)
返回bool型tensor,返回逐元素x<y比较的结果
3、tf.gather
根据索引值,将对应tensor的元素提取出来,组成新的tensor
https://blog.csdn.net/Cyiano/article/details/76087747
4、tf.train.exponential_decay
tf.train.exponential_decay(
learning_rate,
global_step,
decay_steps,
decay_rate,
staircase=False,
name=None
)
decayed_learning_rate = learning_rate *
decay_rate ^ (global_step / decay_steps)
当staircase=True时,(
global_step / decay_steps)取整,即每decay_step次迭代时,lr*decay_rate
https://www.tensorflow.org/api_docs/python/tf/train/exponential_decay
5、name_scope和variable_scope
(1) tf.variable_scope`和`tf.get_variable`必须要搭配使用(全局scope除外),为share提供支持。
(2) tf.Variable`可以单独使用,也可以搭配`tf.name_scope`使用,给变量分类命名,模块化。
(3) tf.Variable`和`tf.variable_scope`搭配使用不伦不类,不是设计者的初衷。
https://www.zhihu.com/question/54513728
6、SAME和VALID
https://blog.csdn.net/wuzqchom/article/details/74785643
根据索引,得到新的tensor
https://blog.csdn.net/orangefly0214/article/details/81634310
https://blog.csdn.net/liyaoqing/article/details/54842384
8、Tensorflow中Graph和Session的关系
https://blog.csdn.net/xg123321123/article/details/78017997
9、TF的数据读取方式
https://zhuanlan.zhihu.com/p/30751039
10、tf.scatter_nd
gather_nd的反操作
https://www.w3cschool.cn/tensorflow_python/tensorflow_python-led42j40.html
11、categorical_crossentropy VS. sparse_categorical_crossentropy的区别
https://www.cnblogs.com/shizhh/p/9662545.html
- 如果你的 targets 是 one-hot 编码,用 categorical_crossentropy
- one-hot 编码:[0, 0, 1], [1, 0, 0], [0, 1, 0]
- 数字编码:2, 0, 1
如果你的 tagets 是 数字编码 ,用 sparse_categorical_crossentropy
12、tf.layers.conv2d_transpose 反卷积
反卷积的过程
Step 1 扩充: 将 inputs 进行填充扩大。扩大的倍数与strides有关。扩大的方式是在元素之间插strides - 1 个 0
Step 2 卷积: 对扩充变大的矩阵,用大小为kernel_size卷积核做卷积操作,这样的卷积核有filters个,并且这里的步长为1(与参数strides无关,一定是1)
https://blog.csdn.net/weiwei9363/article/details/78954063
13、Embedding层的作用
https://fuhailin.github.io/Embedding/
14、eager模式:以动态图的方式运行,无需sess.run就能出结果
import tensorflow.contrib.eager as tfe
tfe.enable_eager_execution()
15、这位网友踩过的一些坑,马克一下
https://zhuanlan.zhihu.com/p/66434370
16、tf.control_dependencies()
此函数指定某些操作执行的依赖关系, 在执行完 a,b 操作之后,才能执行 c,d 操作。意思就是 c,d 操作依赖 a,b 操作
https://blog.csdn.net/huitailangyz/article/details/85015611
- with tf.control_dependencies([a, b]):
- c = ....
- d = ...
17、tf.GraphKeys.UPDATE_OPS
tensorflow的计算图中内置的一个集合,其中会保存一些需要在训练操作之前完成的操作,并配合tf.control_dependencies
函数使用。
这偏博客举了一个bn的例子 https://blog.csdn.net/huitailangyz/article/details/85015611
tf的一些基本用法的更多相关文章
- 【TensorFlow】tf.nn.softmax_cross_entropy_with_logits的用法
在计算loss的时候,最常见的一句话就是 tf.nn.softmax_cross_entropy_with_logits ,那么它到底是怎么做的呢? 首先明确一点,loss是代价值,也就是我们要最小化 ...
- deep_learning_Function_tf.equal(tf.argmax(y, 1),tf.argmax(y_, 1))用法
[Tensorflow] tf.equal(tf.argmax(y, 1),tf.argmax(y_, 1))用法 作用:输出正确的预测结果利用tf.argmax()按行求出真实值y_.预测值y最大值 ...
- 【转载】 tf.split函数的用法
原文地址: https://blog.csdn.net/uestc_c2_403/article/details/73350457 由于tensorflow 版本更新问题 用法略有修改 ----- ...
- tf.nn.embedding_lookup()的用法
函数: tf.nn.embedding_lookup( params, ids, partition_strategy='mod', name=None, validate_indices=True, ...
- tensorflow 的tf.split函数的用法
将张量进行切分 tf.split( value, num_or_size_splits, axis=0, num=None, name='split' ) value: 待切分的张量 num_or_s ...
- tf.transpose函数的用法讲解
tf.transpose函数中文意思是转置,对于低维度的转置问题,很简单,不想讨论,直接转置就好(大家看下面文档,一看就懂). tf.transpose(a, perm=None, name='tra ...
- [TensorFlow] tf.nn.softmax_cross_entropy_with_logits的用法
在计算loss的时候,最常见的一句话就是tf.nn.softmax_cross_entropy_with_logits,那么它到底是怎么做的呢? 首先明确一点,loss是代价值,也就是我们要最小化的值 ...
- tf.nn.softmax_cross_entropy_with_logits的用法
http://blog.csdn.net/mao_xiao_feng/article/details/53382790 计算loss的时候,最常见的一句话就是tf.nn.softmax_cross_e ...
- tf.nn.in_top_k的用法
tf.nn.in_top_k组要是用于计算预测的结果和实际结果的是否相等,返回一个bool类型的张量,tf.nn.in_top_k(prediction, target, K):prediction就 ...
随机推荐
- git几个必知托管平台
程序员必须知道的几个Git代码托管平台 说到Git代码托管平台,首先推荐的是GitHub,好多好的开源项目都来自GitHub,但是GitHub只能新建公开的Git仓库,私有 仓库要收费,如果你做的 ...
- Linux服务器初步配置流程
一.root登录 首先使用root用户登录远程主机: ssh -p prot root@host 这时命令行会输出类似的信息: The authenticity of host '[23.105.21 ...
- Codeforces 1108E2 Array and Segments (Hard version)(差分+思维)
题目链接:Array and Segments (Hard version) 题意:给定一个长度为n的序列,m个区间,从m个区间内选择一些区间内的数都减一,使得整个序列的最大值减最小值最大. 题解:利 ...
- Nginx-反向代理实现
Nginx 反向代理操作案例 Nginx反向代理的组件模块 upstream模块介绍->点我< http_proxy_module模块介绍->点我< 环境准备 1)四台服务器都 ...
- functools模块中partial的使用
一.简介 functools.partial(func,* args,**关键字) 返回一个新的部分对象,当被调用时,其行为类似于使用位置参数args 和关键字参数关键字调用的func.如果为调用提供 ...
- 《Linux下cp XXX1 XXX2的功能》的实现
<Linux下cp XXX1 XXX2的功能>的实现 一.题目要求 编写MyCP.java 实现类似Linux下cp XXX1 XXX2的功能,要求MyCP支持两个参数: java MyC ...
- windows类似grep的命令——findstr
windows类似grep的命令——findstr 使用Chrome发现访问google总是向香港那边跳转,估计配置文件中google网站映射的地址是www.google.com.hk,便想着改配 ...
- SQL随记(五)——函数篇
1.SQL函数: (1)replace(String1,String2,String3):从String1字符串中找到String2,然后用String3替换String2 如:replace('ab ...
- 如何将Windows电脑桌面上软件图标下的文字去掉
如何将Windows电脑桌面上软件图标下的文字去掉 重命名的时候,点击鼠标右键.选择“插入Unicode控制字符” 效果
- python计算素数和
计算输入两个正整数x,y(x<=y,包括x,y)素数和.函数isPrime用以判断一个数是否素数,primeSum函数返回素数和 以下为源码 def isPrime(n) : for i ...