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

7、tf.gathertf.gather_nd

 

  根据索引,得到新的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]
  • 如果你的 tagets 是 数字编码 ,用 sparse_categorical_crossentropy
    •   数字编码:2, 0, 1

 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]):
2     c = ....
3     d = ...

 17、tf.GraphKeys.UPDATE_OPS

      tensorflow的计算图中内置的一个集合,其中会保存一些需要在训练操作之前完成的操作,并配合tf.control_dependencies函数使用。

       这偏博客举了一个bn的例子   https://blog.csdn.net/huitailangyz/article/details/85015611

原文地址:https://www.cnblogs.com/573177885qq/p/10691987.html