1.np.asarray()
array 和 asarray 都可将结构数据转换为 ndarray 类型.
举例: data1=[[1,1,1],[1,1,1],[1,1,1]] arr2=np.array(data1) arr3=np.asarray(data1)
输出: arr2: [[1 1 1] [1 1 1] [1 1 1]] arr3: [[1 1 1] [1 1 1] [1 1 1]]
2.shape()
shape 函数是 numpy.core.fromnumeric 中的函数, 它的功能是读取矩阵的长度, 比如 shape[0]就是读取矩阵第一维度的长度.
- 3.tf.placeholder()
- tf.placeholder( dtype, shape=None, name=None)
dtype: 数据类型. 常用的是 tf.float32,tf.float64 等数值类型
shape: 数据形状. 默认是 None, 就是一维值, 也可以是多维 (比如[2,3], [None, 3] 表示列是 3, 行不定)
name: 名称
4.tf.Variable()
tf.Variable(initializer,name), 参数 initializer 是初始化参数, name 是可自定义的变量名称
5.np.random.randn()
当函数括号内没有参数时, 则返回一个浮点数;
当函数括号内有一个参数时, 则返回秩为 1 的数组, 不能表示向量和矩阵;
当函数括号内有两个及以上参数时, 则返回对应维度的数组, 能表示向量或矩阵;
np.random.standard_normal()函数与 np.random.randn()类似, 但是 np.random.standard_normal()的输入参数为元组(tuple).
np.random.randn()的输入通常为整数, 但是如果为浮点数, 则会自动直接截断转换为整数.
6.tf.pow()
幂值计算函数
- x = tf.constant([[2, 2], [3, 3]])
- y = tf.constant([[8, 16], [2, 3]])
- tf.pow(x, y) # [[256, 65536], [9, 27]]
来源: http://www.bubuko.com/infodetail-3489121.html