You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

layers.rst 14 kB

5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701
  1. API - Layers
  2. ============
  3. .. automodule:: tensorlayer.layers
  4. .. -----------------------------------------------------------
  5. .. Layer List
  6. .. -----------------------------------------------------------
  7. Layer list
  8. ----------
  9. .. autosummary::
  10. Layer
  11. Input
  12. OneHot
  13. Word2vecEmbedding
  14. Embedding
  15. AverageEmbedding
  16. Dense
  17. Dropout
  18. GaussianNoise
  19. DropconnectDense
  20. UpSampling2d
  21. DownSampling2d
  22. Conv1d
  23. Conv2d
  24. Conv3d
  25. DeConv2d
  26. DeConv3d
  27. DepthwiseConv2d
  28. SeparableConv1d
  29. SeparableConv2d
  30. DeformableConv2d
  31. GroupConv2d
  32. PadLayer
  33. PoolLayer
  34. ZeroPad1d
  35. ZeroPad2d
  36. ZeroPad3d
  37. MaxPool1d
  38. MeanPool1d
  39. MaxPool2d
  40. MeanPool2d
  41. MaxPool3d
  42. MeanPool3d
  43. GlobalMaxPool1d
  44. GlobalMeanPool1d
  45. GlobalMaxPool2d
  46. GlobalMeanPool2d
  47. GlobalMaxPool3d
  48. GlobalMeanPool3d
  49. CornerPool2d
  50. SubpixelConv1d
  51. SubpixelConv2d
  52. SpatialTransformer2dAffine
  53. transformer
  54. batch_transformer
  55. BatchNorm
  56. BatchNorm1d
  57. BatchNorm2d
  58. BatchNorm3d
  59. LocalResponseNorm
  60. InstanceNorm
  61. InstanceNorm1d
  62. InstanceNorm2d
  63. InstanceNorm3d
  64. LayerNorm
  65. GroupNorm
  66. SwitchNorm
  67. RNN
  68. SimpleRNN
  69. GRURNN
  70. LSTMRNN
  71. BiRNN
  72. retrieve_seq_length_op
  73. retrieve_seq_length_op2
  74. retrieve_seq_length_op3
  75. target_mask_op
  76. Flatten
  77. Reshape
  78. Transpose
  79. Shuffle
  80. Lambda
  81. Concat
  82. Elementwise
  83. ElementwiseLambda
  84. ExpandDims
  85. Tile
  86. Stack
  87. UnStack
  88. Sign
  89. Scale
  90. BinaryDense
  91. BinaryConv2d
  92. TernaryDense
  93. TernaryConv2d
  94. DorefaDense
  95. DorefaConv2d
  96. PRelu
  97. PRelu6
  98. PTRelu6
  99. flatten_reshape
  100. initialize_rnn_state
  101. list_remove_repeat
  102. .. -----------------------------------------------------------
  103. .. Basic Layers
  104. .. -----------------------------------------------------------
  105. Base Layer
  106. -----------
  107. .. autoclass:: Layer
  108. .. -----------------------------------------------------------
  109. .. Input Layer
  110. .. -----------------------------------------------------------
  111. Input Layers
  112. ---------------
  113. Input Layer
  114. ^^^^^^^^^^^^^^^^
  115. .. autofunction:: Input
  116. .. -----------------------------------------------------------
  117. .. Embedding Layers
  118. .. -----------------------------------------------------------
  119. One-hot Layer
  120. ^^^^^^^^^^^^^^^^^^^^
  121. .. autoclass:: OneHot
  122. Word2Vec Embedding Layer
  123. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  124. .. autoclass:: Word2vecEmbedding
  125. Embedding Layer
  126. ^^^^^^^^^^^^^^^^^^^^^^^
  127. .. autoclass:: Embedding
  128. Average Embedding Layer
  129. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  130. .. autoclass:: AverageEmbedding
  131. .. -----------------------------------------------------------
  132. .. Activation Layers
  133. .. -----------------------------------------------------------
  134. Activation Layers
  135. ---------------------------
  136. PReLU Layer
  137. ^^^^^^^^^^^^^^^^^
  138. .. autoclass:: PRelu
  139. PReLU6 Layer
  140. ^^^^^^^^^^^^^^^^^^
  141. .. autoclass:: PRelu6
  142. PTReLU6 Layer
  143. ^^^^^^^^^^^^^^^^^^^
  144. .. autoclass:: PTRelu6
  145. .. -----------------------------------------------------------
  146. .. Convolutional Layers
  147. .. -----------------------------------------------------------
  148. Convolutional Layers
  149. ---------------------
  150. Convolutions
  151. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  152. Conv1d
  153. """""""""""""""""""""
  154. .. autoclass:: Conv1d
  155. Conv2d
  156. """""""""""""""""""""
  157. .. autoclass:: Conv2d
  158. Conv3d
  159. """""""""""""""""""""
  160. .. autoclass:: Conv3d
  161. Deconvolutions
  162. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  163. DeConv2d
  164. """""""""""""""""""""
  165. .. autoclass:: DeConv2d
  166. DeConv3d
  167. """""""""""""""""""""
  168. .. autoclass:: DeConv3d
  169. Deformable Convolutions
  170. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  171. DeformableConv2d
  172. """""""""""""""""""""
  173. .. autoclass:: DeformableConv2d
  174. Depthwise Convolutions
  175. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  176. DepthwiseConv2d
  177. """""""""""""""""""""
  178. .. autoclass:: DepthwiseConv2d
  179. Group Convolutions
  180. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  181. GroupConv2d
  182. """""""""""""""""""""
  183. .. autoclass:: GroupConv2d
  184. Separable Convolutions
  185. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  186. SeparableConv1d
  187. """""""""""""""""""""
  188. .. autoclass:: SeparableConv1d
  189. SeparableConv2d
  190. """""""""""""""""""""
  191. .. autoclass:: SeparableConv2d
  192. SubPixel Convolutions
  193. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  194. SubpixelConv1d
  195. """""""""""""""""""""
  196. .. autoclass:: SubpixelConv1d
  197. SubpixelConv2d
  198. """""""""""""""""""""
  199. .. autoclass:: SubpixelConv2d
  200. .. -----------------------------------------------------------
  201. .. Dense Layers
  202. .. -----------------------------------------------------------
  203. Dense Layers
  204. -------------
  205. Dense Layer
  206. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  207. .. autoclass:: Dense
  208. Drop Connect Dense Layer
  209. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  210. .. autoclass:: DropconnectDense
  211. .. -----------------------------------------------------------
  212. .. Dropout Layer
  213. .. -----------------------------------------------------------
  214. Dropout Layers
  215. -------------------
  216. .. autoclass:: Dropout
  217. .. -----------------------------------------------------------
  218. .. Extend Layers
  219. .. -----------------------------------------------------------
  220. Extend Layers
  221. -------------------
  222. Expand Dims Layer
  223. ^^^^^^^^^^^^^^^^^^^^
  224. .. autoclass:: ExpandDims
  225. Tile layer
  226. ^^^^^^^^^^^^^^^^^^^^
  227. .. autoclass:: Tile
  228. .. -----------------------------------------------------------
  229. .. Image Resampling Layers
  230. .. -----------------------------------------------------------
  231. Image Resampling Layers
  232. -------------------------
  233. 2D UpSampling
  234. ^^^^^^^^^^^^^^^^^^^^^^^
  235. .. autoclass:: UpSampling2d
  236. 2D DownSampling
  237. ^^^^^^^^^^^^^^^^^^^^^^^
  238. .. autoclass:: DownSampling2d
  239. .. -----------------------------------------------------------
  240. .. Lambda Layer
  241. .. -----------------------------------------------------------
  242. Lambda Layers
  243. ---------------
  244. Lambda Layer
  245. ^^^^^^^^^^^^^^^^^^^
  246. .. autoclass:: Lambda
  247. ElementWise Lambda Layer
  248. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  249. .. autoclass:: ElementwiseLambda
  250. .. -----------------------------------------------------------
  251. .. Merge Layer
  252. .. -----------------------------------------------------------
  253. Merge Layers
  254. ---------------
  255. Concat Layer
  256. ^^^^^^^^^^^^^^^^^^^
  257. .. autoclass:: Concat
  258. ElementWise Layer
  259. ^^^^^^^^^^^^^^^^^^^
  260. .. autoclass:: Elementwise
  261. .. -----------------------------------------------------------
  262. .. Noise Layers
  263. .. -----------------------------------------------------------
  264. Noise Layer
  265. ---------------
  266. .. autoclass:: GaussianNoise
  267. .. -----------------------------------------------------------
  268. .. Normalization Layers
  269. .. -----------------------------------------------------------
  270. Normalization Layers
  271. --------------------
  272. Batch Normalization
  273. ^^^^^^^^^^^^^^^^^^^^^^
  274. .. autoclass:: BatchNorm
  275. Batch Normalization 1D
  276. ^^^^^^^^^^^^^^^^^^^^^^^^^
  277. .. autoclass:: BatchNorm1d
  278. Batch Normalization 2D
  279. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  280. .. autoclass:: BatchNorm2d
  281. Batch Normalization 3D
  282. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  283. .. autoclass:: BatchNorm3d
  284. Local Response Normalization
  285. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  286. .. autoclass:: LocalResponseNorm
  287. Instance Normalization
  288. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  289. .. autoclass:: InstanceNorm
  290. Instance Normalization 1D
  291. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  292. .. autoclass:: InstanceNorm1d
  293. Instance Normalization 2D
  294. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  295. .. autoclass:: InstanceNorm2d
  296. Instance Normalization 3D
  297. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  298. .. autoclass:: InstanceNorm3d
  299. Layer Normalization
  300. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  301. .. autoclass:: LayerNorm
  302. Group Normalization
  303. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  304. .. autoclass:: GroupNorm
  305. Switch Normalization
  306. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  307. .. autoclass:: SwitchNorm
  308. .. -----------------------------------------------------------
  309. .. Padding Layers
  310. .. -----------------------------------------------------------
  311. Padding Layers
  312. ------------------------
  313. Pad Layer (Expert API)
  314. ^^^^^^^^^^^^^^^^^^^^^^^^^
  315. Padding layer for any modes.
  316. .. autoclass:: PadLayer
  317. 1D Zero padding
  318. ^^^^^^^^^^^^^^^^^^^
  319. .. autoclass:: ZeroPad1d
  320. 2D Zero padding
  321. ^^^^^^^^^^^^^^^^^^^
  322. .. autoclass:: ZeroPad2d
  323. 3D Zero padding
  324. ^^^^^^^^^^^^^^^^^^^
  325. .. autoclass:: ZeroPad3d
  326. .. -----------------------------------------------------------
  327. .. Pooling Layers
  328. .. -----------------------------------------------------------
  329. Pooling Layers
  330. ------------------------
  331. Pool Layer (Expert API)
  332. ^^^^^^^^^^^^^^^^^^^^^^^^^
  333. Pooling layer for any dimensions and any pooling functions.
  334. .. autoclass:: PoolLayer
  335. 1D Max pooling
  336. ^^^^^^^^^^^^^^^^^^^
  337. .. autoclass:: MaxPool1d
  338. 1D Mean pooling
  339. ^^^^^^^^^^^^^^^^^^^
  340. .. autoclass:: MeanPool1d
  341. 2D Max pooling
  342. ^^^^^^^^^^^^^^^^^^^
  343. .. autoclass:: MaxPool2d
  344. 2D Mean pooling
  345. ^^^^^^^^^^^^^^^^^^^
  346. .. autoclass:: MeanPool2d
  347. 3D Max pooling
  348. ^^^^^^^^^^^^^^^^^^^
  349. .. autoclass:: MaxPool3d
  350. 3D Mean pooling
  351. ^^^^^^^^^^^^^^^^^^^
  352. .. autoclass:: MeanPool3d
  353. 1D Global Max pooling
  354. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  355. .. autoclass:: GlobalMaxPool1d
  356. 1D Global Mean pooling
  357. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  358. .. autoclass:: GlobalMeanPool1d
  359. 2D Global Max pooling
  360. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  361. .. autoclass:: GlobalMaxPool2d
  362. 2D Global Mean pooling
  363. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  364. .. autoclass:: GlobalMeanPool2d
  365. 3D Global Max pooling
  366. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  367. .. autoclass:: GlobalMaxPool3d
  368. 3D Global Mean pooling
  369. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  370. .. autoclass:: GlobalMeanPool3d
  371. 2D Corner pooling
  372. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  373. .. autoclass:: CornerPool2d
  374. .. -----------------------------------------------------------
  375. .. Quantized Layers
  376. .. -----------------------------------------------------------
  377. Quantized Nets
  378. ------------------
  379. This is an experimental API package for building Quantized Neural Networks. We are using matrix multiplication rather than add-minus and bit-count operation at the moment. Therefore, these APIs would not speed up the inferencing, for production, you can train model via TensorLayer and deploy the model into other customized C/C++ implementation (We probably provide users an extra C/C++ binary net framework that can load model from TensorLayer).
  380. Note that, these experimental APIs can be changed in the future.
  381. Sign
  382. ^^^^^^^^^^^^^^
  383. .. autoclass:: Sign
  384. Scale
  385. ^^^^^^^^^^^^^^
  386. .. autoclass:: Scale
  387. Binary Dense Layer
  388. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  389. .. autoclass:: BinaryDense
  390. Binary (De)Convolutions
  391. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  392. BinaryConv2d
  393. """""""""""""""""""""
  394. .. autoclass:: BinaryConv2d
  395. Ternary Dense Layer
  396. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  397. TernaryDense
  398. """""""""""""""""""""
  399. .. autoclass:: TernaryDense
  400. Ternary Convolutions
  401. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  402. TernaryConv2d
  403. """""""""""""""""""""
  404. .. autoclass:: TernaryConv2d
  405. DoReFa Convolutions
  406. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  407. DorefaConv2d
  408. """""""""""""""""""""
  409. .. autoclass:: DorefaConv2d
  410. DoReFa Convolutions
  411. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  412. DorefaConv2d
  413. """""""""""""""""""""
  414. .. autoclass:: DorefaConv2d
  415. .. -----------------------------------------------------------
  416. .. Recurrent Layers
  417. .. -----------------------------------------------------------
  418. Recurrent Layers
  419. ---------------------
  420. Common Recurrent layer
  421. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  422. All recurrent layers can implement any type of RNN cell by feeding different cell function (LSTM, GRU etc).
  423. RNN layer
  424. """"""""""""""""""""""""""
  425. .. autoclass:: RNN
  426. RNN layer with Simple RNN Cell
  427. """"""""""""""""""""""""""""""""""
  428. .. autoclass:: SimpleRNN
  429. RNN layer with GRU Cell
  430. """"""""""""""""""""""""""""""""""
  431. .. autoclass:: GRURNN
  432. RNN layer with LSTM Cell
  433. """"""""""""""""""""""""""""""""""
  434. .. autoclass:: LSTMRNN
  435. Bidirectional layer
  436. """""""""""""""""""""""""""""""""
  437. .. autoclass:: BiRNN
  438. Advanced Ops for Dynamic RNN
  439. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  440. These operations usually be used inside Dynamic RNN layer, they can
  441. compute the sequence lengths for different situation and get the last RNN outputs by indexing.
  442. Compute Sequence length 1
  443. """"""""""""""""""""""""""
  444. .. autofunction:: retrieve_seq_length_op
  445. Compute Sequence length 2
  446. """""""""""""""""""""""""""""
  447. .. autofunction:: retrieve_seq_length_op2
  448. Compute Sequence length 3
  449. """"""""""""""""""""""""""""
  450. .. autofunction:: retrieve_seq_length_op3
  451. Compute mask of the target sequence
  452. """""""""""""""""""""""""""""""""""""""
  453. .. autofunction:: target_mask_op
  454. .. -----------------------------------------------------------
  455. .. Shape Layers
  456. .. -----------------------------------------------------------
  457. Shape Layers
  458. ------------
  459. Flatten Layer
  460. ^^^^^^^^^^^^^^^
  461. .. autoclass:: Flatten
  462. Reshape Layer
  463. ^^^^^^^^^^^^^^^
  464. .. autoclass:: Reshape
  465. Transpose Layer
  466. ^^^^^^^^^^^^^^^^^
  467. .. autoclass:: Transpose
  468. Shuffle Layer
  469. ^^^^^^^^^^^^^^^^^
  470. .. autoclass:: Shuffle
  471. .. -----------------------------------------------------------
  472. .. Spatial Transformer Layers
  473. .. -----------------------------------------------------------
  474. Spatial Transformer
  475. -----------------------
  476. 2D Affine Transformation
  477. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  478. .. autoclass:: SpatialTransformer2dAffine
  479. 2D Affine Transformation function
  480. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  481. .. autofunction:: transformer
  482. Batch 2D Affine Transformation function
  483. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  484. .. autofunction:: batch_transformer
  485. .. -----------------------------------------------------------
  486. .. Stack Layers
  487. .. -----------------------------------------------------------
  488. Stack Layer
  489. -------------
  490. Stack Layer
  491. ^^^^^^^^^^^^^^
  492. .. autoclass:: Stack
  493. Unstack Layer
  494. ^^^^^^^^^^^^^^^
  495. .. autoclass:: UnStack
  496. .. -----------------------------------------------------------
  497. .. Helper Functions
  498. .. -----------------------------------------------------------
  499. Helper Functions
  500. ------------------------
  501. Flatten tensor
  502. ^^^^^^^^^^^^^^^^^
  503. .. autofunction:: flatten_reshape
  504. Initialize RNN state
  505. ^^^^^^^^^^^^^^^^^^^^^^^^^
  506. .. autofunction:: initialize_rnn_state
  507. Remove repeated items in a list
  508. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  509. .. autofunction:: list_remove_repeat

TensorLayer3.0 是一款兼容多种深度学习框架为计算后端的深度学习库。计划兼容TensorFlow, Pytorch, MindSpore, Paddle.