original_docstring: Convert the data from MNIST format to Collagen internal format.
  
      MNIST format:
  
      - uint8 numpy arrays
      - domain between 0 and 255
      - 0 represents white (background), 255 represents black (foreground)
      - the first dimension corresponding to the height
      - the second dimension to the width
      
      Collagen internal format:
      
      - floating point 32bits numpy arrays 
      - domain between 0.0 and 1.0
      - 0.0 represents black; 1.0 corresponds to white
      - the first dimension corresponding to the height
      - the second dimension to the width
      
docstring: Convert the data from MNIST format to Collagen internal format.
  MNIST format.
  
  uint8 numpy arrays
  domain between 0 and 255
  0 represents white (background), 255 represents black (foreground)
  the first dimension corresponding to the height
  the second dimension to the width
  
  Collagen internal format.
  
  floating point 32bits numpy arrays
  domain between 0.0 and 1.0
  0.0 represents black; 1.0 corresponds to white
  the first dimension corresponding to the height
  the second dimension to the width
docstring_tokens: Convert the data from MNIST format to Collagen internal format . MNIST format . uint8 numpy arrays domain between 0 and 255 0 represents white ( background ) 255 represents black ( foreground ) the first dimension corresponding to the height the second dimension to the width Collagen internal format . floating point 32bits numpy arrays domain between 0 . 0 and 1 . 0 0 . 0 represents black ; 1 . 0 corresponds to white the first dimension corresponding to the height the second dimension to the width
code: def convert_mnist2collagen(data, debug=False):
      """Convert the data from MNIST format to Collagen internal format.
  
      MNIST format:
  
      - uint8 numpy arrays
      - domain between 0 and 255
      - 0 represents white (background), 255 represents black (foreground)
      - the first dimension corresponding to the height
      - the second dimension to the width
      
      Collagen internal format:
      
      - floating point 32bits numpy arrays 
      - domain between 0.0 and 1.0
      - 0.0 represents black; 1.0 corresponds to white
      - the first dimension corresponding to the height
      - the second dimension to the width
      """
  
      # DEBUG
      if debug:
          print(">>> Before conversion (mnist format):")
          print("data:", data)
          print("type(data):", type(data))
          print("data.dtype:", data.dtype)
          print("data.shape:", data.shape)
      
      # Convert 255-0 to 0-255
      data = 255 - data
  
      # Convert 0-255 to 0-1
      data = data / 255.0
  
      # Convert to float32
      data = data.astype(np.float32)
          
      # DEBUG
      if debug:
          print(">>> After conversion (collagen format):")
          print("data:", data)
          print("type(data):", type(data))
          print("data.dtype:", data.dtype)
          print("data.shape:", data.shape)
      
      return data
code_tokens: def convert_mnist2collagen ( data , debug = False ) : if debug : print ( ">>> Before conversion (mnist format):" ) print ( "data:" , data ) print ( "type(data):" , type ( data ) ) print ( "data.dtype:" , data . dtype ) print ( "data.shape:" , data . shape ) data = 255 - data data = data / 255.0 data = data . astype ( np . float32 ) if debug : print ( ">>> After conversion (collagen format):" ) print ( "data:" , data ) print ( "type(data):" , type ( data ) ) print ( "data.dtype:" , data . dtype ) print ( "data.shape:" , data . shape ) return data
short_docstring: Convert the data from MNIST format to Collagen internal format.
short_docstring_tokens: Convert the data from MNIST format to Collagen internal format .
comment: """Convert the data from MNIST format to Collagen internal format.
  
      MNIST format:
  
      - uint8 numpy arrays
      - domain between 0 and 255
      - 0 represents white (background), 255 represents black (foreground)
      - the first dimension corresponding to the height
      - the second dimension to the width
      
      Collagen internal format:
      
      - floating point 32bits numpy arrays 
      - domain between 0.0 and 1.0
      - 0.0 represents black; 1.0 corresponds to white
      - the first dimension corresponding to the height
      - the second dimension to the width
      """$SEP$# DEBUG$SEP$# Convert 255-0 to 0-255$SEP$# Convert 0-255 to 0-1$SEP$# Convert to float32$SEP$# DEBUG