base.py
1 """ 2 Pipeline module 3 """ 4 5 6 class Pipeline: 7 """ 8 Base class for all Pipelines. The only interface requirement is to define a __call___ method. 9 """ 10 11 def batch(self, data, size): 12 """ 13 Splits data into separate batch sizes specified by size. 14 15 Args: 16 data: data elements 17 size: batch size 18 19 Returns: 20 list of evenly sized batches with the last batch having the remaining elements 21 """ 22 23 return [data[x : x + size] for x in range(0, len(data), size)]