国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > Python > 正文

對(duì)tensorflow中tf.nn.conv1d和layers.conv1d的區(qū)別詳解

2020-02-15 21:16:11
字體:
供稿:網(wǎng)友

在用tensorflow做一維的卷積神經(jīng)網(wǎng)絡(luò)的時(shí)候會(huì)遇到tf.nn.conv1d和layers.conv1d這兩個(gè)函數(shù),但是這兩個(gè)函數(shù)有什么區(qū)別呢,通過計(jì)算得到一些規(guī)律。

1.關(guān)于tf.nn.conv1d的解釋,以下是Tensor Flow中關(guān)于tf.nn.conv1d的API注解:

Computes a 1-D convolution given 3-D input and filter tensors.

Given an input tensor of shape [batch, in_width, in_channels] if data_format is "NHWC", or [batch, in_channels, in_width] if data_format is "NCHW", and a filter / kernel tensor of shape [filter_width, in_channels, out_channels], this op reshapes the arguments to pass them to conv2d to perform the equivalent convolution operation.

Internally, this op reshapes the input tensors and invokes `tf.nn.conv2d`. For example, if `data_format` does not start with "NC", a tensor of shape [batch, in_width, in_channels] is reshaped to [batch, 1, in_width, in_channels], and the filter is reshaped to [1, filter_width, in_channels, out_channels]. The result is then reshaped back to [batch, out_width, out_channels] whereoutwidthisafunctionofthestrideandpaddingasinconv2dwhereoutwidthisafunctionofthestrideandpaddingasinconv2d and returned to the caller.

Args: value: A 3D `Tensor`. Must be of type `float32` or `float64`. filters: A 3D `Tensor`. Must have the same type as `input`. stride: An `integer`. The number of entries by which the filter is moved right at each step. padding: 'SAME' or 'VALID' use_cudnn_on_gpu: An optional `bool`. Defaults to `True`. data_format: An optional `string` from `"NHWC", "NCHW"`. Defaults to `"NHWC"`, the data is stored in the order of [batch, in_width, in_channels]. The `"NCHW"` format stores data as [batch, in_channels, in_width]. name: A name for the operation (optional).

Returns:

A `Tensor`. Has the same type as input.

Raises:

ValueError: if `data_format` is invalid.

什么意思呢?就是說conv1d的參數(shù)含義:(以NHWC格式為例,即,通道維在最后)

1、value:在注釋中,value的格式為:[batch, in_width, in_channels],batch為樣本維,表示多少個(gè)樣本,in_width為寬度維,表示樣本的寬度,in_channels維通道維,表示樣本有多少個(gè)通道。 事實(shí)上,也可以把格式看作如下:[batch, 行數(shù), 列數(shù)],把每一個(gè)樣本看作一個(gè)平鋪開的二維數(shù)組。這樣的話可以方便理解。

2、filters:在注釋中,filters的格式為:[filter_width, in_channels, out_channels]。按照value的第二種看法,filter_width可以看作每次與value進(jìn)行卷積的行數(shù),in_channels表示value一共有多少列(與value中的in_channels相對(duì)應(yīng))。out_channels表示輸出通道,可以理解為一共有多少個(gè)卷積核,即卷積核的數(shù)目。

3、stride:一個(gè)整數(shù),表示步長(zhǎng),每次(向下)移動(dòng)的距離(TensorFlow中解釋是向右移動(dòng)的距離,這里可以看作向下移動(dòng)的距離)。

4、padding:同conv2d,value是否需要在下方填補(bǔ)0。

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 梅州市| 古田县| 石城县| 左贡县| SHOW| 康保县| 山东| 铜陵市| 邓州市| 边坝县| 舒城县| 寻乌县| 昆明市| 迁安市| 古蔺县| 三门县| 星座| 漠河县| 泰宁县| 吉木乃县| 新田县| 定远县| 泽库县| 长武县| 马鞍山市| 临澧县| 仁怀市| 安泽县| 五家渠市| 八宿县| 安丘市| 信阳市| 三河市| 甘谷县| 长丰县| 新建县| 内黄县| 光泽县| 东莞市| 石门县| 神农架林区|