def minibatch_map(fn, batch_size, input_data, output_data=None, output_width=None):
 if (output_width is None):
  if (output_data is None):
   raise ValueError('output_data or output_width should be provided')
  output_width = output_data.shape[1]
 output_length = input_data.shape[0]
 if (output_data is None):
  output_data = numpy.empty((output_length, output_width))
 else:
  assert (output_data.shape[0] == input_data.shape[0]), ('output_data should have the same length as input_data', output_data.shape[0], input_data.shape[0])
 for i in xrange(0, output_length, batch_size):
  output_data[i:(i + batch_size)] = fn(input_data[i:(i + batch_size)])
 return output_data

def minibatch_map ( fn , batch_size , input_data , output_data = None , output_width = None ) : if ( output_width is None ) : if ( output_data is None ) : raise ValueError ( 'output_data or output_width should be provided' ) output_width = output_data . shape [ 1 ] output_length = input_data . shape [ 0 ] if ( output_data is None ) : output_data = numpy . empty ( ( output_length , output_width ) ) else : assert ( output_data . shape [ 0 ] == input_data . shape [ 0 ] ) , ( 'output_data should have the same length as input_data' , output_data . shape [ 0 ] , input_data . shape [ 0 ] ) for i in xrange ( 0 , output_length , batch_size ) : output_data [ i : ( i + batch_size ) ] = fn ( input_data [ i : ( i + batch_size ) ] ) return output_data
apply a function on input_data .