tensorflow学习笔记2

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]]
 
 
原文地址:https://www.cnblogs.com/ljm-zsy/p/12622876.html