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.

prepro.rst 18 kB

4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. API - Data Pre-Processing
  2. =========================
  3. .. automodule:: tensorlayer.prepro
  4. .. autosummary::
  5. affine_rotation_matrix
  6. affine_horizontal_flip_matrix
  7. affine_vertical_flip_matrix
  8. affine_shift_matrix
  9. affine_shear_matrix
  10. affine_zoom_matrix
  11. affine_respective_zoom_matrix
  12. transform_matrix_offset_center
  13. affine_transform
  14. affine_transform_cv2
  15. affine_transform_keypoints
  16. projective_transform_by_points
  17. rotation
  18. rotation_multi
  19. crop
  20. crop_multi
  21. flip_axis
  22. flip_axis_multi
  23. shift
  24. shift_multi
  25. shear
  26. shear_multi
  27. shear2
  28. shear_multi2
  29. swirl
  30. swirl_multi
  31. elastic_transform
  32. elastic_transform_multi
  33. zoom
  34. respective_zoom
  35. zoom_multi
  36. brightness
  37. brightness_multi
  38. illumination
  39. rgb_to_hsv
  40. hsv_to_rgb
  41. adjust_hue
  42. imresize
  43. pixel_value_scale
  44. samplewise_norm
  45. featurewise_norm
  46. channel_shift
  47. channel_shift_multi
  48. drop
  49. array_to_img
  50. find_contours
  51. pt2map
  52. binary_dilation
  53. dilation
  54. binary_erosion
  55. erosion
  56. obj_box_coord_rescale
  57. obj_box_coords_rescale
  58. obj_box_coord_scale_to_pixelunit
  59. obj_box_coord_centroid_to_upleft_butright
  60. obj_box_coord_upleft_butright_to_centroid
  61. obj_box_coord_centroid_to_upleft
  62. obj_box_coord_upleft_to_centroid
  63. parse_darknet_ann_str_to_list
  64. parse_darknet_ann_list_to_cls_box
  65. obj_box_horizontal_flip
  66. obj_box_imresize
  67. obj_box_crop
  68. obj_box_shift
  69. obj_box_zoom
  70. keypoint_random_crop
  71. keypoint_resize_random_crop
  72. keypoint_random_rotate
  73. keypoint_random_flip
  74. keypoint_random_resize
  75. keypoint_random_resize_shortestedge
  76. pad_sequences
  77. remove_pad_sequences
  78. process_sequences
  79. sequences_add_start_id
  80. sequences_add_end_id
  81. sequences_add_end_id_after_pad
  82. sequences_get_mask
  83. ..
  84. Threading
  85. ------------
  86. .. autofunction:: threading_data
  87. Affine Transform
  88. ----------------
  89. Python can be FAST
  90. ^^^^^^^^^^^^^^^^^^
  91. Image augmentation is a critical step in deep learning.
  92. Though TensorFlow has provided ``tf.image``,
  93. image augmentation often remains as a key bottleneck.
  94. ``tf.image`` has three limitations:
  95. - Real-world visual tasks such as object detection, segmentation, and pose estimation
  96. must cope with image meta-data (e.g., coordinates).
  97. These data are beyond ``tf.image``
  98. which processes images as tensors.
  99. - ``tf.image`` operators
  100. breaks the pure Python programing experience (i.e., users have to
  101. use ``tf.py_func`` in order to call image functions written in Python); however,
  102. frequent uses of ``tf.py_func`` slow down TensorFlow,
  103. making users hard to balance flexibility and performance.
  104. - ``tf.image`` API is inflexible. Image operations are
  105. performed in an order. They are hard to jointly optimize. More importantly,
  106. sequential image operations can significantly
  107. reduces the quality of images, thus affecting training accuracy.
  108. TensorLayer addresses these limitations by providing a
  109. high-performance image augmentation API in Python.
  110. This API bases on affine transformation and ``cv2.wrapAffine``.
  111. It allows you to combine multiple image processing functions into
  112. a single matrix operation. This combined operation
  113. is executed by the fast ``cv2`` library, offering 78x performance improvement (observed in
  114. `openpose-plus <https://github.com/tensorlayer/openpose-plus>`_ for example).
  115. The following example illustrates the rationale
  116. behind this tremendous speed up.
  117. Example
  118. ^^^^^^^
  119. The source code of complete examples can be found \
  120. `here <https://github.com/tensorlayer/tensorlayer/tree/master/examples/data_process/tutorial_fast_affine_transform.py>`__.
  121. The following is a typical Python program that applies rotation, shifting, flipping, zooming and shearing to an image,
  122. .. code-block:: python
  123. image = tl.vis.read_image('tiger.jpeg')
  124. xx = tl.prepro.rotation(image, rg=-20, is_random=False)
  125. xx = tl.prepro.flip_axis(xx, axis=1, is_random=False)
  126. xx = tl.prepro.shear2(xx, shear=(0., -0.2), is_random=False)
  127. xx = tl.prepro.zoom(xx, zoom_range=0.8)
  128. xx = tl.prepro.shift(xx, wrg=-0.1, hrg=0, is_random=False)
  129. tl.vis.save_image(xx, '_result_slow.png')
  130. However, by leveraging affine transformation, image operations can be combined into one:
  131. .. code-block:: python
  132. # 1. Create required affine transformation matrices
  133. M_rotate = tl.prepro.affine_rotation_matrix(angle=20)
  134. M_flip = tl.prepro.affine_horizontal_flip_matrix(prob=1)
  135. M_shift = tl.prepro.affine_shift_matrix(wrg=0.1, hrg=0, h=h, w=w)
  136. M_shear = tl.prepro.affine_shear_matrix(x_shear=0.2, y_shear=0)
  137. M_zoom = tl.prepro.affine_zoom_matrix(zoom_range=0.8)
  138. # 2. Combine matrices
  139. # NOTE: operations are applied in a reversed order (i.e., rotation is performed first)
  140. M_combined = M_shift.dot(M_zoom).dot(M_shear).dot(M_flip).dot(M_rotate)
  141. # 3. Convert the matrix from Cartesian coordinates (the origin in the middle of image)
  142. # to image coordinates (the origin on the top-left of image)
  143. transform_matrix = tl.prepro.transform_matrix_offset_center(M_combined, x=w, y=h)
  144. # 4. Transform the image using a single operation
  145. result = tl.prepro.affine_transform_cv2(image, transform_matrix) # 76 times faster
  146. tl.vis.save_image(result, '_result_fast.png')
  147. The following figure illustrates the rational behind combined affine transformation.
  148. .. image:: ../images/affine_transform_why.jpg
  149. :width: 100 %
  150. :align: center
  151. Using combined affine transformation has two key benefits. First, it allows \
  152. you to leverage a pure Python API to achieve orders of magnitudes of speed up in image augmentation,
  153. and thus prevent data pre-processing from becoming a bottleneck in training. \
  154. Second, performing sequential image transformation requires multiple image interpolations. \
  155. This produces low-quality input images. In contrast, a combined transformation performs the \
  156. interpolation only once, and thus
  157. preserve the content in an image. The following figure illustrates these two benefits:
  158. .. image:: ../images/affine_transform_comparison.jpg
  159. :width: 100 %
  160. :align: center
  161. The major reason for combined affine transformation being fast is because it has lower computational complexity.
  162. Assume we have ``k`` affine transformations ``T1, ..., Tk``, where ``Ti`` can be represented by 3x3 matrixes.
  163. The sequential transformation can be represented as ``y = Tk (... T1(x))``,
  164. and the time complexity is ``O(k N)`` where ``N`` is the cost of applying one transformation to image ``x``.
  165. ``N`` is linear to the size of ``x``.
  166. For the combined transformation ``y = (Tk ... T1) (x)``
  167. the time complexity is ``O(27(k - 1) + N) = max{O(27k), O(N)} = O(N)`` (assuming 27k << N) where 27 = 3^3 is the cost for combining two transformations.
  168. Get rotation matrix
  169. ^^^^^^^^^^^^^^^^^^^^^^^^^
  170. .. autofunction:: affine_rotation_matrix
  171. Get horizontal flipping matrix
  172. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  173. .. autofunction:: affine_horizontal_flip_matrix
  174. Get vertical flipping matrix
  175. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  176. .. autofunction:: affine_vertical_flip_matrix
  177. Get shifting matrix
  178. ^^^^^^^^^^^^^^^^^^^^^^^^^
  179. .. autofunction:: affine_shift_matrix
  180. Get shearing matrix
  181. ^^^^^^^^^^^^^^^^^^^^^^^^^
  182. .. autofunction:: affine_shear_matrix
  183. Get zooming matrix
  184. ^^^^^^^^^^^^^^^^^^^^^^^^^
  185. .. autofunction:: affine_zoom_matrix
  186. Get respective zooming matrix
  187. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  188. .. autofunction:: affine_respective_zoom_matrix
  189. Cartesian to image coordinates
  190. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  191. .. autofunction:: transform_matrix_offset_center
  192. ..
  193. Apply image transform
  194. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  195. .. autofunction:: affine_transform
  196. Apply image transform
  197. ^^^^^^^^^^^^^^^^^^^^^
  198. .. autofunction:: affine_transform_cv2
  199. Apply keypoint transform
  200. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  201. .. autofunction:: affine_transform_keypoints
  202. Images
  203. -----------
  204. Projective transform by points
  205. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  206. .. autofunction:: projective_transform_by_points
  207. Rotation
  208. ^^^^^^^^^
  209. .. autofunction:: rotation
  210. .. autofunction:: rotation_multi
  211. Crop
  212. ^^^^^^^^^
  213. .. autofunction:: crop
  214. .. autofunction:: crop_multi
  215. Flip
  216. ^^^^^^^^^
  217. .. autofunction:: flip_axis
  218. .. autofunction:: flip_axis_multi
  219. Shift
  220. ^^^^^^^^^
  221. .. autofunction:: shift
  222. .. autofunction:: shift_multi
  223. Shear
  224. ^^^^^^^^^
  225. .. autofunction:: shear
  226. .. autofunction:: shear_multi
  227. Shear V2
  228. ^^^^^^^^^^^
  229. .. autofunction:: shear2
  230. .. autofunction:: shear_multi2
  231. Swirl
  232. ^^^^^^^^^
  233. .. autofunction:: swirl
  234. .. autofunction:: swirl_multi
  235. Elastic transform
  236. ^^^^^^^^^^^^^^^^^^
  237. .. autofunction:: elastic_transform
  238. .. autofunction:: elastic_transform_multi
  239. Zoom
  240. ^^^^^^^^^
  241. .. autofunction:: zoom
  242. .. autofunction:: zoom_multi
  243. Respective Zoom
  244. ^^^^^^^^^^^^^^^^^
  245. .. autofunction:: respective_zoom
  246. Brightness
  247. ^^^^^^^^^^^^
  248. .. autofunction:: brightness
  249. .. autofunction:: brightness_multi
  250. Brightness, contrast and saturation
  251. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  252. .. autofunction:: illumination
  253. RGB to HSV
  254. ^^^^^^^^^^^^^^
  255. .. autofunction:: rgb_to_hsv
  256. HSV to RGB
  257. ^^^^^^^^^^^^^^
  258. .. autofunction:: hsv_to_rgb
  259. Adjust Hue
  260. ^^^^^^^^^^^^^^
  261. .. autofunction:: adjust_hue
  262. Resize
  263. ^^^^^^^^^^^^
  264. .. autofunction:: imresize
  265. Pixel value scale
  266. ^^^^^^^^^^^^^^^^^^^^
  267. .. autofunction:: pixel_value_scale
  268. Normalization
  269. ^^^^^^^^^^^^^^^
  270. .. autofunction:: samplewise_norm
  271. .. autofunction:: featurewise_norm
  272. Channel shift
  273. ^^^^^^^^^^^^^^
  274. .. autofunction:: channel_shift
  275. .. autofunction:: channel_shift_multi
  276. Noise
  277. ^^^^^^^^^^^^^^
  278. .. autofunction:: drop
  279. Numpy and PIL
  280. ^^^^^^^^^^^^^^
  281. .. autofunction:: array_to_img
  282. Find contours
  283. ^^^^^^^^^^^^^^
  284. .. autofunction:: find_contours
  285. Points to Image
  286. ^^^^^^^^^^^^^^^^^
  287. .. autofunction:: pt2map
  288. Binary dilation
  289. ^^^^^^^^^^^^^^^^^
  290. .. autofunction:: binary_dilation
  291. Greyscale dilation
  292. ^^^^^^^^^^^^^^^^^^^^
  293. .. autofunction:: dilation
  294. Binary erosion
  295. ^^^^^^^^^^^^^^^^^^^^
  296. .. autofunction:: binary_erosion
  297. Greyscale erosion
  298. ^^^^^^^^^^^^^^^^^^^^
  299. .. autofunction:: erosion
  300. Object detection
  301. -------------------
  302. Tutorial for Image Aug
  303. ^^^^^^^^^^^^^^^^^^^^^^^
  304. Hi, here is an example for image augmentation on VOC dataset.
  305. .. code-block:: python
  306. import tensorlayer as tl
  307. ## download VOC 2012 dataset
  308. imgs_file_list, _, _, _, classes, _, _,\
  309. _, objs_info_list, _ = tl.files.load_voc_dataset(dataset="2012")
  310. ## parse annotation and convert it into list format
  311. ann_list = []
  312. for info in objs_info_list:
  313. ann = tl.prepro.parse_darknet_ann_str_to_list(info)
  314. c, b = tl.prepro.parse_darknet_ann_list_to_cls_box(ann)
  315. ann_list.append([c, b])
  316. # read and save one image
  317. idx = 2 # you can select your own image
  318. image = tl.vis.read_image(imgs_file_list[idx])
  319. tl.vis.draw_boxes_and_labels_to_image(image, ann_list[idx][0],
  320. ann_list[idx][1], [], classes, True, save_name='_im_original.png')
  321. # left right flip
  322. im_flip, coords = tl.prepro.obj_box_horizontal_flip(image,
  323. ann_list[idx][1], is_rescale=True, is_center=True, is_random=False)
  324. tl.vis.draw_boxes_and_labels_to_image(im_flip, ann_list[idx][0],
  325. coords, [], classes, True, save_name='_im_flip.png')
  326. # resize
  327. im_resize, coords = tl.prepro.obj_box_imresize(image,
  328. coords=ann_list[idx][1], size=[300, 200], is_rescale=True)
  329. tl.vis.draw_boxes_and_labels_to_image(im_resize, ann_list[idx][0],
  330. coords, [], classes, True, save_name='_im_resize.png')
  331. # crop
  332. im_crop, clas, coords = tl.prepro.obj_box_crop(image, ann_list[idx][0],
  333. ann_list[idx][1], wrg=200, hrg=200,
  334. is_rescale=True, is_center=True, is_random=False)
  335. tl.vis.draw_boxes_and_labels_to_image(im_crop, clas, coords, [],
  336. classes, True, save_name='_im_crop.png')
  337. # shift
  338. im_shfit, clas, coords = tl.prepro.obj_box_shift(image, ann_list[idx][0],
  339. ann_list[idx][1], wrg=0.1, hrg=0.1,
  340. is_rescale=True, is_center=True, is_random=False)
  341. tl.vis.draw_boxes_and_labels_to_image(im_shfit, clas, coords, [],
  342. classes, True, save_name='_im_shift.png')
  343. # zoom
  344. im_zoom, clas, coords = tl.prepro.obj_box_zoom(image, ann_list[idx][0],
  345. ann_list[idx][1], zoom_range=(1.3, 0.7),
  346. is_rescale=True, is_center=True, is_random=False)
  347. tl.vis.draw_boxes_and_labels_to_image(im_zoom, clas, coords, [],
  348. classes, True, save_name='_im_zoom.png')
  349. In practice, you may want to use threading method to process a batch of images as follows.
  350. .. code-block:: python
  351. import tensorlayer as tl
  352. import random
  353. batch_size = 64
  354. im_size = [416, 416]
  355. n_data = len(imgs_file_list)
  356. jitter = 0.2
  357. def _data_pre_aug_fn(data):
  358. im, ann = data
  359. clas, coords = ann
  360. ## change image brightness, contrast and saturation randomly
  361. im = tl.prepro.illumination(im, gamma=(0.5, 1.5),
  362. contrast=(0.5, 1.5), saturation=(0.5, 1.5), is_random=True)
  363. ## flip randomly
  364. im, coords = tl.prepro.obj_box_horizontal_flip(im, coords,
  365. is_rescale=True, is_center=True, is_random=True)
  366. ## randomly resize and crop image, it can have same effect as random zoom
  367. tmp0 = random.randint(1, int(im_size[0]*jitter))
  368. tmp1 = random.randint(1, int(im_size[1]*jitter))
  369. im, coords = tl.prepro.obj_box_imresize(im, coords,
  370. [im_size[0]+tmp0, im_size[1]+tmp1], is_rescale=True,
  371. interp='bicubic')
  372. im, clas, coords = tl.prepro.obj_box_crop(im, clas, coords,
  373. wrg=im_size[1], hrg=im_size[0], is_rescale=True,
  374. is_center=True, is_random=True)
  375. ## rescale value from [0, 255] to [-1, 1] (optional)
  376. im = im / 127.5 - 1
  377. return im, [clas, coords]
  378. # randomly read a batch of image and the corresponding annotations
  379. idexs = tl.utils.get_random_int(min=0, max=n_data-1, number=batch_size)
  380. b_im_path = [imgs_file_list[i] for i in idexs]
  381. b_images = tl.prepro.threading_data(b_im_path, fn=tl.vis.read_image)
  382. b_ann = [ann_list[i] for i in idexs]
  383. # threading process
  384. data = tl.prepro.threading_data([_ for _ in zip(b_images, b_ann)],
  385. _data_pre_aug_fn)
  386. b_images2 = [d[0] for d in data]
  387. b_ann = [d[1] for d in data]
  388. # save all images
  389. for i in range(len(b_images)):
  390. tl.vis.draw_boxes_and_labels_to_image(b_images[i],
  391. ann_list[idexs[i]][0], ann_list[idexs[i]][1], [],
  392. classes, True, save_name='_bbox_vis_%d_original.png' % i)
  393. tl.vis.draw_boxes_and_labels_to_image((b_images2[i]+1)*127.5,
  394. b_ann[i][0], b_ann[i][1], [], classes, True,
  395. save_name='_bbox_vis_%d.png' % i)
  396. Image Aug with TF Dataset API
  397. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  398. - Example code for VOC `here <https://github.com/tensorlayer/tensorlayer/blob/master/example/tutorial_tf_dataset_voc.py>`__.
  399. Coordinate pixel unit to percentage
  400. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  401. .. autofunction:: obj_box_coord_rescale
  402. Coordinates pixel unit to percentage
  403. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  404. .. autofunction:: obj_box_coords_rescale
  405. Coordinate percentage to pixel unit
  406. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  407. .. autofunction:: obj_box_coord_scale_to_pixelunit
  408. Coordinate [x_center, x_center, w, h] to up-left button-right
  409. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  410. .. autofunction:: obj_box_coord_centroid_to_upleft_butright
  411. Coordinate up-left button-right to [x_center, x_center, w, h]
  412. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  413. .. autofunction:: obj_box_coord_upleft_butright_to_centroid
  414. Coordinate [x_center, x_center, w, h] to up-left-width-high
  415. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  416. .. autofunction:: obj_box_coord_centroid_to_upleft
  417. Coordinate up-left-width-high to [x_center, x_center, w, h]
  418. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  419. .. autofunction:: obj_box_coord_upleft_to_centroid
  420. Darknet format string to list
  421. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  422. .. autofunction:: parse_darknet_ann_str_to_list
  423. Darknet format split class and coordinate
  424. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  425. .. autofunction:: parse_darknet_ann_list_to_cls_box
  426. Image Aug - Flip
  427. ^^^^^^^^^^^^^^^^^^^^^^^^^
  428. .. autofunction:: obj_box_horizontal_flip
  429. Image Aug - Resize
  430. ^^^^^^^^^^^^^^^^^^^^^^^^^
  431. .. autofunction:: obj_box_imresize
  432. Image Aug - Crop
  433. ^^^^^^^^^^^^^^^^^^^^^^^^^
  434. .. autofunction:: obj_box_crop
  435. Image Aug - Shift
  436. ^^^^^^^^^^^^^^^^^^^^^^^^^
  437. .. autofunction:: obj_box_shift
  438. Image Aug - Zoom
  439. ^^^^^^^^^^^^^^^^^^^^^^^^^
  440. .. autofunction:: obj_box_zoom
  441. Keypoints
  442. ------------
  443. Image Aug - Crop
  444. ^^^^^^^^^^^^^^^^^^^^
  445. .. autofunction:: keypoint_random_crop
  446. Image Aug - Resize then Crop
  447. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  448. .. autofunction:: keypoint_resize_random_crop
  449. Image Aug - Rotate
  450. ^^^^^^^^^^^^^^^^^^^^
  451. .. autofunction:: keypoint_random_rotate
  452. Image Aug - Flip
  453. ^^^^^^^^^^^^^^^^^^^^
  454. .. autofunction:: keypoint_random_flip
  455. Image Aug - Resize
  456. ^^^^^^^^^^^^^^^^^^^^
  457. .. autofunction:: keypoint_random_resize
  458. Image Aug - Resize Shortest Edge
  459. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  460. .. autofunction:: keypoint_random_resize_shortestedge
  461. Sequence
  462. ---------
  463. More related functions can be found in ``tensorlayer.nlp``.
  464. Padding
  465. ^^^^^^^^^
  466. .. autofunction:: pad_sequences
  467. Remove Padding
  468. ^^^^^^^^^^^^^^^^^
  469. .. autofunction:: remove_pad_sequences
  470. Process
  471. ^^^^^^^^^
  472. .. autofunction:: process_sequences
  473. Add Start ID
  474. ^^^^^^^^^^^^^^^
  475. .. autofunction:: sequences_add_start_id
  476. Add End ID
  477. ^^^^^^^^^^^^^^^
  478. .. autofunction:: sequences_add_end_id
  479. Add End ID after pad
  480. ^^^^^^^^^^^^^^^^^^^^^^^
  481. .. autofunction:: sequences_add_end_id_after_pad
  482. Get Mask
  483. ^^^^^^^^^
  484. .. autofunction:: sequences_get_mask

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