# Path: dlearn/utils/math.py
# def create_shared(x):
#     return theano.shared(np.asarray(x), borrow=True)
# 
# Path: dlearn/utils/serialize.py
# def load_data(fpath):
#     with open(fpath, 'rb') as f:
#         data = cPickle.load(f)
#     return data


from glob import glob
from os.path import join as pj
from ..utils.math import create_shared
from ..utils.serialize import load_data
        
    def prepare(self, index):
        input, target = load_data(self._batch_files[index])
        if self._pfunc is not None:
            input, target = self._pfunc(input, target)

        if self._input is None:
            self._input = [create_shared(X) for X in input]
            self._target = [create_shared(X) for X in target]
        else:
            for i, X in enumerate(input):
                self._input[i].set_value(X, borrow=True)
            for i, X in enumerate(target):
                self._target[i].set_value(X, borrow=True)

    @property
    def n_batches(self):
        return len(self._batch_files)

    @property
    def input(self):
        return self._input

    @property
    def target(self):
        return self._target

class DataProvider(object):
    def __init__(self, homepath, train_range, valid_range, test_range,
                 pfunc=None):

# Path: dlearn/utils/math.py
# def create_shared(x):
#     return theano.shared(np.asarray(x), borrow=True)
# 
# Path: dlearn/utils/serialize.py
# def load_data(fpath):
#     with open(fpath, 'rb') as f:
#         data = cPickle.load(f)
#     return data


# Path: dlearn/data/data_provider.py
from glob import glob
from os.path import join as pj
from ..utils.math import create_shared
from ..utils.serialize import load_data

        
    def prepare(self, index):
        input, target = load_data(self._batch_files[index])
        if self._pfunc is not None:
            input, target = self._pfunc(input, target)

        if self._input is None:
            self._input = [create_shared(X) for X in input]
            self._target = [create_shared(X) for X in target]
        else:
            for i, X in enumerate(input):
                self._input[i].set_value(X, borrow=True)
            for i, X in enumerate(target):
                self._target[i].set_value(X, borrow=True)

    @property
    def n_batches(self):
        return len(self._batch_files)

    @property
    def input(self):
        return self._input

    @property
    def target(self):
        return self._target

class DataProvider(object):
    def __init__(self, homepath, train_range, valid_range, test_range,
                 pfunc=None):

        super(DataProvider, self).__init__()