## tf.nn. - conv2d ``` conv2d( input, shape[batch, in_height, in_width, in_channels] filter, shape[filter_height, filter_width, in_channels, out_channels] strides, padding, use_cudnn_on_gpu=True, data_format='NHWC', dilations=[1, 1, 1, 1], name=None ) ``` ``` Computes a 2-D convolution given 4-D input and filter tensors. Given an input tensor of shape [batch, in_height, in_width, in_channels] and a filter / kernel tensor of shape[filter_height, filter_width, in_channels, out_channels], this op performs the following: 1.Flattens the filter to a 2-D matrix with shape [filter_height * filter_width * in_channels, output_channels]. 2.Extracts image patches from the input tensor to form a virtual tensor of shape [batch, out_height, out_width, filter_height * filter_width * in_channels]. 3.For each patch, right-multiplies the filter matrix and the image patch vector. In detail, with the default NHWC format, output[b, i, j, k] = sum_{di, dj, q} input[b, strides[1] * i + di, strides[2] * j + dj, q] * filter[di, dj, q, k] Must have strides[0] = strides[3] = 1. For the most common case of the same horizontal and vertices strides, strides = [1, stride, stride, 1]. ``` - moments ``` Calculate the mean and variance of x ``` - batch_normalization ``` Normalizes a tensor by mean and variance, and applies (optionally) a scale γ to it, as well as an offset β: ``` - max_pool - embedding_lookup - l2_loss - bias_add - relu - dropout - xw_plus_b - softmax_cross_entropy_with_logits_v2 ## tf - random_uniform ``` Returns: A tensor of the specified shape filled with random uniform values. ``` - expand_dims ``` Inserts a dimension of 1 into a tensor's shape. name_scope ``` - truncated_normal ``` tf.truncated_normal(shape, mean, stddev) :shape表示生成张量的维度,mean是均值,stddev是标准差。这个函数产生正太分布,均值和标准差自己设定。这是一个截断的产生正太分布的函数,就是说产生正太分布的值如果与均值的差值大于两倍的标准差,那就重新生成。和一般的正太分布的产生随机数据比起来,这个函数产生的随机数与均值的差距不会超过两倍的标准差,但是一般的别的函数是可能的。 ``` - constant ``` value参数可以是一个常量值,或者一个dtype类型的值列表。如果value为一个列表,那么这个列表的长度必须小于或等于shape参数所指定的大小(如果设置shape的话)。当列表长度小于shape参数所指定的大小时,缺少的列表项会被填充为列表的最后一个参数。 shape参数是可选的。如果存在该参数,它会指明生成的张量的维度。如果不存在,则使用value的shape。 ``` - argmax ``` Returns the index with the largest value across axes of a tensor. (deprecated arguments) ``` - Variable - concat - reshape - placeholder ``` Inserts a placeholder for a tensor that will be always fed. Important: This tensor will produce an error if evaluated. Its value must be fed using the feed_dict optional argument to Session.run(), Tensor.eval(), or Operation.run(). For example: x = tf.placeholder(tf.float32, shape=(1024, 1024)) y = tf.matmul(x, x) with tf.Session() as sess: print(sess.run(y)) # ERROR: will fail because x was not fed. rand_array = np.random.rand(1024, 1024) print(sess.run(y, feed_dict={x: rand_array})) # Will succeed. ``` - equal ``` Returns the truth value of (x == y) element-wise. ``` - reduce_mean ``` x = tf.constant([[1, 1, 1], [1, 1, 1]]) tf.reduce_sum(x) # 6 tf.reduce_sum(x, 0) # [2, 2, 2] tf.reduce_sum(x, 1) # [3, 3] tf.reduce_sum(x, 1, keepdims=True) # [[3], [3]] tf.reduce_sum(x, [0, 1]) # 6 ``` - cast ``` 转换类型 ```