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 13 kB

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

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