tensorflow常用API

tf.nn.conv2d


conv2d(
    input,
    filter,
    strides,
    padding,
    use_cudnn_on_gpu=True,
    data_format='NHWC',
    name=None
)

tf.nn.relu


relu(
    features,
    name=None
)

tf.nn.max_pool


max_pool(
    value,
    ksize,
    strides,
    padding,
    data_format='NHWC',
    name=None
)

tf.nn.dropout

dropout(
    x,
    keep_prob,
    noise_shape=None,
    seed=None,
    name=None
)

tf.nn.sigmoid_cross_entropy_with_logits


功能说明:
先对 logits 通过 sigmoid 计算,再计算交叉熵

sigmoid_cross_entropy_with_logits(
    _sentinel=None,
    labels=None,
    logits=None,
    name=None
)

tf.truncated_normal


产生截断正态分布随机数,取值范围为 [ mean - 2 * stddev, mean + 2 * stddev ]。

truncated_normal(
    shape,
    mean=0.0,
    stddev=1.0,
    dtype=tf.float32,
    seed=None,
    name=None
)

import tensorflow as tf
initial = tf.truncated_normal(shape=[3,3], mean=0, stddev=1)
print(tf.Session().run(initial))

执行结果:
将得到一个取值范围 [ -2, 2 ] 的 3 * 3 矩阵.

tf.constant


功能说明:
根据 value 的值生成一个 shape 维度的常量张量

constant(
    value,
    dtype=None,
    shape=None,
    name='Const',
    verify_shape=False
)

tf.placeholder


功能说明:
是一种占位符,在执行时候需要为其提供数据

placeholder(
    dtype,
    shape=None,
    name=None
)

阅读更多:   tensorflow
添加新评论

icon_redface.gificon_idea.gificon_cool.gif2016kuk.gificon_mrgreen.gif2016shuai.gif2016tp.gif2016db.gif2016ch.gificon_razz.gif2016zj.gificon_sad.gificon_cry.gif2016zhh.gificon_question.gif2016jk.gif2016bs.gificon_lol.gif2016qiao.gificon_surprised.gif2016fendou.gif2016ll.gif