Exemple #1
0
  def Convert(self, image):
    """
    Arguments:
    ---------
    image: an Image instance

    Returns:
    -------
    an instance of Input

    Description:
    -----------
    The *image* arguments has 2 attributes: *label* which indicates
    the digit represented by the image, and *pixels* a matrix 14 x 14
    represented by a list (first list is the first row, second list the
    second row, ... ), containing numbers whose values are comprised
    between 0 and 256.0. The function transforms this into a unique list
    of 14 x 14 items, with normalized values (that is, the maximum possible
    value should be 1).
    
    """
    out = Input()

    for lst in image.pixels:
      for pixel in lst:
        out.values.append(pixel / 256.0)

    return out
Exemple #2
0
    def Convert(self, image):
        """
    Arguments:
    ---------
    image: an Image instance

    Returns:
    -------
    an instance of Input

    Description:
    -----------
    The *image* arguments has 2 attributes: *label* which indicates
    the digit represented by the image, and *pixels* a matrix 14 x 14
    represented by a list (first list is the first row, second list the
    second row, ... ), containing numbers whose values are comprised
    between 0 and 256.0. The function transforms this into a unique list
    of 14 x 14 items, with normalized values (that is, the maximum possible
    value should be 1).
    "
    new_pixels = [None for i in range(196)]
	
    for i in range(14):
	    for j in range(14):
		    new_pixels[i*14+j] = image.pixels[i][j] / 256.0
    """

        input = Input()
        input.values = image.pixels
        return input
Exemple #3
0
 def Convert(self, image):
     outer = []
     for i in image.pixels:
         for j in i:
             outer.append(j / 256.0)
     inp = Input()
     inp.values = outer
     return inp