code: def create_transformation_matrix():
      # 1. Create required affine transformation matrices
      ## fixed
      # M_rotate = tl.prepro.affine_rotation_matrix(angle=20)
      # M_flip = tl.prepro.affine_horizontal_flip_matrix(prob=1)
      # M_shift = tl.prepro.affine_shift_matrix(wrg=0.1, hrg=0, h=h, w=w)
      # M_shear = tl.prepro.affine_shear_matrix(x_shear=0.2, y_shear=0)
      # M_zoom = tl.prepro.affine_zoom_matrix(zoom_range=0.8)
      ## random
      M_rotate = tl.prepro.affine_rotation_matrix(angle=(-20, 20))
      M_flip = tl.prepro.affine_horizontal_flip_matrix(prob=0.5)
      M_shift = tl.prepro.affine_shift_matrix(
          wrg=(-0.1, 0.1), hrg=(-0.1, 0.1), h=h, w=w
      )
      M_shear = tl.prepro.affine_shear_matrix(
          x_shear=(-0.2, 0.2), y_shear=(-0.2, 0.2)
      )
      M_zoom = tl.prepro.affine_zoom_matrix(zoom_range=(0.8, 1.2))
  
      # 2. Combine matrices
      # NOTE: operations are applied in a reversed order (i.e., rotation is performed first)
      M_combined = (
          M_shift.dot(M_zoom).dot(M_shear).dot(M_flip).dot(M_rotate)
      )
  
      # 3. Convert the matrix from Cartesian coordinates (the origin in the middle of image)
      # to image coordinates (the origin on the top-left of image)
      transform_matrix = tl.prepro.transform_matrix_offset_center(
          M_combined, x=w, y=h
      )
      return transform_matrix
  
file_path: TensorLayer/examples/data_process/tutorial_fast_affine_transform.py
imports: import multiprocessing
  import time
  import numpy
  import cv2
  import tensorflow
  import tensorlayer
label_desc: Use image node_id 1 for calling a global function with example usage: create_transformation_matrix() and returns: transform_matrix