Tensorflow常用接口整理

一、变量相关。tf.get_variable() 和 tf.Variable()是tensorflow中创建变量的两种方式。每调用一次这两个函数,实际上创建的就是一组变量集(节点集)

        1)tf.get_variable()和tf.variable_scope()配合,可以用作变量复用,也可以起到变量区分(作用域分割)

        2)tf.Variable(<variable_name>) 会自动检测命名冲突并自行处理,但tf.get_variable(<variable_name>)则遇到重名的变量创建且变量名没有设置为共享变量时,则会报错。

        3)tf.get_variable():主要用于管理一个图里面的各种op,返回的是一个以scope_name命名的context manager

        4)tf.variable_scope():一般与tf.name_scope()配合使用,用于管理一个graph中变量的名字,避免变量之间的命名冲突。

二、tensorflow相关的方法

        1)tf.nn.embedding_lookup(tensor, index),查找张量tensor中索引为index的元素。

        2)tf.contrib.rnn.LSTMCell ()创建lstmcell,必传参数为cell_num。创建基本的rnncell

        3)tf.contrib.rnn.DropoutWrapper(), 接受参数为RNNCell。

        4)tf.contrib.rnn.MultiRNNCell() ,接受参数为基本rnncell序列。RNN cell composed sequentially of multiple simple cells

        5)tf.train.AdagradOptimizer(learning_rate), Optimizer that implements the Adagrad algorithm

        6)tf.train.GradientDescentOptimizer(learning_rate)

        7)tf.gradients(ys, xs) 计算梯度

        8)tf.clip_by_global_norm(t_list, clip_norm, use_norm=None, name=None)

        9)tf.train.Saver

        10)tf.sparse_softmax_cross_entropy_with_logits . Returns:
      A `Tensor` of the same shape as `labels` and of the same type as `logits`

      with the softmax cross entropy loss.

        11)tf.transpose

        12)tf.nn.softmax

        13)tf.contrib.rnn.static_rnn 创建一个循环神经网络

        14)tf.nn.conv2d Computes a 2-D convolution given 4-D `input` and `filter` tensors










  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值