TensorFlow函數(shù):tf.nn.conv1d

2020-07-30 09:49 更新

tf.nn.conv1d函數(shù)

tf.nn.conv1d(
    value,
    filters,
    stride,
    padding,
    use_cudnn_on_gpu=None,
    data_format=None,
    name=None
)

定義在:tensorflow/python/ops/nn_ops.py。

請參閱指南:神經(jīng)網(wǎng)絡(luò)>卷積運算

計算給定3-D輸入和濾波器張量的1-D卷積。(不推薦使用的參數(shù))

更新說明:NCHWfor data_format已棄用,請改用NCW

更新說明:NHWCfor data_format已棄用,請改用NWC

如果data_format是“NWC”,則給定一個形狀為[batch,in_width,in_channels]的輸入張量,或者如果data_format是“NCW”,并且過濾器/內(nèi)核張量的形狀為[filter_width,in_channels,out_channels],則[batch,in_channels,in_width],此運算重新計算參數(shù),將其傳遞給 conv2d 以執(zhí)行等效卷積操作。

在內(nèi)部,這個操作重塑輸入張量并調(diào)用tf.nn.conv2d。例如,如果data_format不以“NC”開頭,則將形狀為[batch,in_width,in_channels]的張量重新變?yōu)樾螤頪batch,1,in_width,in_channels],并將濾波器的形狀調(diào)整為[1,filter_width,in_channels,out_channels ]。然后將結(jié)果重新轉(zhuǎn)換回[batch,out_width,out_channels](其中out_width是步幅和填充的函數(shù),如conv2d中所示)并返回給調(diào)用方。

參數(shù):

  • value:在注釋中,value的格式為:[batch, in_width, in_channels],batch為樣本維,表示多少個樣本,in_width為寬度維,表示樣本的寬度,in_channels維通道維,表示樣本有多少個通道。
  • filters:filters:在注釋中,filters的格式為:[filter_width, in_channels, out_channels]。按照value的第二種看法,filter_width可以看作每次與value進(jìn)行卷積的行數(shù),in_channels表示value一共有多少列(與value中的in_channels相對應(yīng))。out_channels表示輸出通道,可以理解為一共有多少個卷積核,即卷積核的數(shù)目。
  • stride:一個整數(shù),表示步長,每次(向下)移動的距離。
  • padding:'SAME'或'VALID'
  • use_cudnn_on_gpu:可選的bool,默認(rèn)為True。
  • data_format:一個可選的string,可以是"NWC"和"NCW";默認(rèn)為"NWC",數(shù)據(jù)按[batch,in_width,in_channels]的順序存儲;"NCW"格式將數(shù)據(jù)存儲為[batch, in_channels, in_width]。
  • name:操作的名稱(可選)。

返回:

一Tensor,與輸入具有相同的類型。

可能引發(fā)的異常:

  • ValueError:如果data_format無效。


以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號