def ImageLayerFromInputArray(input_, backend): """Create the initial image layer from some input. :param input_: Input data. If array, values should lie in the range [0, 1]. :type input_: PIL.Image or 2D ndarray of float :returns: Image layer data. :rtype: 2D ndarray of float """ if isinstance(input_, Image.Image): input_ = input_.convert('L') input_ = ImageToArray(input_, transpose = True) input_ = input_.astype(np.float) # Map from [0, 255] to [0, 1] input_ /= 255 # Note: we could have scaled pixels to [-1, 1]. This would result in a # doubling of the dynamic range of the S1 response, since each S1 activation # is of the form: # y = XW # where X and W are the input and weight vector, respectively. The rescaled # version of X (call it X') is given by: # X' = 2X - 1 # so the activation is given by # y' = X'W = (2X - 1)W = 2XW - \sum w_i = 2XW # since W is a mean-zero Gabor filter. (This ignores retinal processing, and # nonlinearities caused by normalization). The scaling of S1 response seems # unlikely to cause a significant change in the network output. return backend.PrepareArray(input_)
def ImageLayerFromInputArray(input_, backend): """Create the initial image layer from some input. :param input_: Input data. If array, values should lie in the range [0, 1]. :type input_: PIL.Image or 2D ndarray of float :returns: Image layer data. :rtype: 2D ndarray of float """ if isinstance(input_, Image.Image): input_ = input_.convert('L') input_ = ImageToArray(input_, transpose=True) input_ = input_.astype(np.float) # Map from [0, 255] to [0, 1] input_ /= 255 # Note: we could have scaled pixels to [-1, 1]. This would result in a # doubling of the dynamic range of the S1 response, since each S1 activation # is of the form: # y = XW # where X and W are the input and weight vector, respectively. The rescaled # version of X (call it X') is given by: # X' = 2X - 1 # so the activation is given by # y' = X'W = (2X - 1)W = 2XW - \sum w_i = 2XW # since W is a mean-zero Gabor filter. (This ignores retinal processing, and # nonlinearities caused by normalization). The scaling of S1 response seems # unlikely to cause a significant change in the network output. return backend.PrepareArray(input_)
def ImageLayerFromInputArray(input_, backend): """Create the initial image layer from some input. input_ -- Image or (2-D) array of input data. If array, values should lie in the range [0, 1]. RETURNS (2-D) array containing image layer data """ if isinstance(input_, Image.Image): input_ = input_.convert('L') input_ = ImageToArray(input_, transpose = True) input_ = input_.astype(np.float) # Map from [0, 255] to [0, 1] input_ /= 255 return backend.PrepareArray(input_)
def ImageLayerFromInputArray(input_, backend): """Create the initial image layer from some input. :param input_: Input data. If array, values should lie in the range [0, 1]. :type input_: PIL.Image or 2D ndarray of float :returns: Image layer data. :rtype: 2D ndarray of float """ if isinstance(input_, Image.Image): input_ = input_.convert('L') input_ = ImageToArray(input_, transpose=True) input_ = input_.astype(np.float) # Map from [0, 255] to [0, 1] input_ /= 255 return backend.PrepareArray(input_)
def ImageLayerFromInputArray(input_, backend): """Create the initial image layer from some input. :param input_: Input data. If array, values should lie in the range [0, 1]. :type input_: PIL.Image or 2D ndarray of float :returns: Image layer data. :rtype: 2D ndarray of float """ if isinstance(input_, Image.Image): input_ = input_.convert('L') input_ = ImageToArray(input_, transpose = True) input_ = input_.astype(np.float) # Map from [0, 255] to [0, 1] input_ /= 255 return backend.PrepareArray(input_)