Tensorflow | Constants |常用函数介绍
2017-03-05 16:58
363 查看
根据官网的帮助文档,介绍Constants类型的函数,方便自己学习和查看。若是有幸帮到别的朋友,深感荣幸。
产生元素0
格式:tf.zeros(shape, dtype=tf.float32, name=None)
shape表示维数,dtype定义类型,name定义名称
例子:
tf.zeros_like
产生类似与tensor的全0张量
格式:tf.zeros_like(tensor, dtype=None, name=None)
tensor是一个张量,dtype定义类型,name定义名称
例子:
tf.ones
产生全是1的张量
格式:tf.ones(shape, dtype=tf.float32, name=None)
shape定义维度,dtype定义类型,name定义名称
例子:
tf.ones_like
产生类似与张量tensor的全1张量
格式:tf.ones_like(tensor, dtype=None, name=None)
tensor是一个张量,dtype定义类型,name定义名称
例子:
tf.fill
填充,用value来填充shape=dims的张量
格式:tf.fill(dims,value,name=None)
dims定义维度,value给定数值,name定义名称
例子:
tf.constant
定义常数张量
格式:tf.constant(value,dtype=None,shape=None,name=’Const’)
value给定的值,dtype定义类型,shape定义维度,name定义名称
例子:
常值张量
tf.zeros产生元素0
格式:tf.zeros(shape, dtype=tf.float32, name=None)
shape表示维数,dtype定义类型,name定义名称
例子:
tf.zeros(shape=[3, 4], dtype=int32) ==> [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
tf.zeros_like
产生类似与tensor的全0张量
格式:tf.zeros_like(tensor, dtype=None, name=None)
tensor是一个张量,dtype定义类型,name定义名称
例子:
# 'tensor' is [[1, 2, 3], [4, 5, 6]] tf.zeros_like(tensor) ==> [[0, 0, 0], [0, 0, 0]]
tf.ones
产生全是1的张量
格式:tf.ones(shape, dtype=tf.float32, name=None)
shape定义维度,dtype定义类型,name定义名称
例子:
tf.ones(shape=[2, 3], dtype=int32) ==> [[1, 1, 1], [1, 1, 1]]
tf.ones_like
产生类似与张量tensor的全1张量
格式:tf.ones_like(tensor, dtype=None, name=None)
tensor是一个张量,dtype定义类型,name定义名称
例子:
# 'tensor' is [[1, 2, 3], [4, 5, 6]] tf.ones_like(tensor) ==> [[1, 1, 1], [1, 1, 1]]
tf.fill
填充,用value来填充shape=dims的张量
格式:tf.fill(dims,value,name=None)
dims定义维度,value给定数值,name定义名称
例子:
# output tensor shape needs to be [2, 3] # so 'dims' is [2, 3] tf.fill(dims, 9) ==> [[9, 9, 9] [9, 9, 9]]
tf.constant
定义常数张量
格式:tf.constant(value,dtype=None,shape=None,name=’Const’)
value给定的值,dtype定义类型,shape定义维度,name定义名称
例子:
# Constant 1-D Tensor populated with value list. tensor = tf.constant(value=[1, 2, 3, 4, 5, 6, 7]) => [1 2 3 4 5 6 7] # Constant 2-D tensor populated with scalar value -1. tensor = tf.constant(value=-1.0, shape=[2, 3]) => [[-1. -1. -1.] [-1. -1. -1.]]
相关文章推荐
- Tensorflow | Random |常用函数介绍
- tensorflow的一些代码分析(四) tensorflow常用函数介绍
- tensorflow常用函数介绍
- tensorflow常用函数介绍
- Tensorflow | Sequences | 常用函数介绍
- OCI 常用函数介绍[摘抄]
- EXCEL常用函数介绍
- MFC中常用类,宏,函数介绍
- MFC中常用类,宏,函数介绍
- Asp.Net常用函数介绍
- DOM常用功能及常用函数介绍
- 第二十课:常用函数介绍--字符串操作函数
- ORACLE常用数值函数、转换函数、字符串函数介绍
- ORACLE常用数值函数、转换函数、字符串函数介绍
- sybase常用函数介绍
- MFC中常用类、宏、函数介绍
- STL知识点(常用算法函数介绍 、容器、类属算法、迭代器、函数对象、适配器、分配器
- MFC中常用类,宏,函数介绍
- ASP常用函数介绍
- SD--相关的函数列表的介绍系列篇和常用的BAPI(1)