tf用法

------------恢复内容开始------------

tensorflow基础函数合辑

import tensorflow as tf

*tf.constant*

函数定义:tf.constant(data,shape=[])

参数说明:data--输入数据,shape--reshape后的形状。使用的reshape中的最低维度优先填充原则。

reshape可参考:http://chenjingjiu.cn/index.php/2019/07/04/numpy-reshape/

*tf.tile*

tf.tile:用来对张量(Tensor)进行扩展的, 其特点是对当前张量内的数据进行一定规则的复制。最终的输出张量维度不变。

函数定义:

tf.tile( input, multiples, name=None )

示例:

>>>tf.tile([1,2],[2])

[1,2,1,2]

*tf.nn.conv2d*

函数定义:

tf.nn.conv2d(
    input, filter, strides, padding, use_cudnn_on_gpu=True, data_format='NHWC', dilations=[1, 1, 1, 1], name=None ) Returns: A Tensor. 

参数说明:

input:
指需要做卷积的输入图像(tensor),
具有[batch,in_height,in_width,in_channels]这样的4维shape,
分别是图片数量、图片高度、图片宽度、图片通道数,数据类型为float32或float64。
filter:
相当于CNN中的卷积核,它是一个tensor,shape是[filter_height,filter_width,in_channels,out_channels]:滤波器高度、宽度、图像通道数、滤波器个数,数据类型和 input相同。
strides:
卷积在每一维的步长,一般为一个一维向量,长度为4,一般为[1,stride,stride,1]。
padding
定义元素边框和元素内容之间的空间,只能是‘SAME’(边缘填充)或者‘VALID’(边缘不填充)。

关于计算输出数据的维度可以参考这个:
 
 
 
 
 

------------恢复内容结束------------

猜你喜欢

转载自www.cnblogs.com/durui0558/p/12215540.html
今日推荐