tensorflow的函数

来源:互联网 发布:java技术文档怎么写 编辑:程序博客网 时间:2024/05/16 11:14

tf.reshape(tensor, shape, name=None) 
函数的作用是将tensor变换为参数shape的形式。 
其中shape为一个列表形式,特殊的一点是列表中可以存在-1。-1代表的含义是不用我们自己指定这一维的大小,函数会自动计算,但列表中只能存在一个-1。(当然如果存在多个-1,就是一个存在多解的方程了)

例子:





1 tf.truncated_normal():

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


Outputs random values from a truncated normal distribution.

从一个正态分布片段中输出随机数值

The generated values follow a normal distribution with specified mean and standard deviation, except that values whose magnitude is more than 2 standard deviations from the mean are dropped and re-picked.

生成的值会遵循一个指定了平均值和标准差的正态分布,只保留两个标准差以内的值,超出的值会被弃掉重新生成。

Args:
shape: A 1-D integer Tensor or Python array. The shape of the output tensor.
mean: A 0-D Tensor or Python value of typedtype. The mean of the truncated normal distribution.
stddev: A 0-D Tensor or Python value of typedtype. The standard deviation of the truncated normal distribution.
dtype: The type of the output.
seed: A Python integer. Used to create a random seed for the distribution. Seeset_random_seedfor behavior.
name: A name for the operation (optional).

参数:
shape: 一个一维整数张量 或 一个Python数组。 这个值决定输出张量的形状。
mean: 一个零维张量或 类型属于dtype的Python值. 这个值决定正态分布片段的平均值
stddev: 一个零维张量或 类型属于dtype的Python值. 这个值决定正态分布片段的标准差。
dtype: 输出的类型.
seed: 一个Python整数. 被用来为正态分布创建一个随机种子. 详情可见set_random_seedfor behavior.
name: 操作的名字 (可选参数).

Returns:
A tensor of the specified shape filled with random truncated normal values.

一个指定形状并用正态分布片段的随机值填充的张量





原创粉丝点击