# Path: dlearn/data/hidata.py
# class HierarData(object):
# 
#     def __init__(self, data, limit=None):
#         self._cpu_data = data
# 
#         if limit is None or limit > data.shape[0]:
#             limit = data.shape[0]
#         self._limit = limit
# 
#         self._gpu_data = create_shared(self._cpu_data[0:limit])
#         self._cur_irange = create_shared(np.asarray([0, limit]))
# 
#     def prepare(self, irange):
#         l, r = irange
#         cur_l, cur_r = self._cur_irange.get_value(borrow=True)
# 
#         if min(l, r - 1) < cur_l or max(l, r - 1) >= cur_r:
#             self._cur_irange.set_value(np.asarray([l, l + self._limit]))
#             self._gpu_data.set_value(
#                 self._cpu_data[l:l + self._limit], borrow=True)
# 
#     @property
#     def cur_irange(self):
#         return self._cur_irange
# 
#     @property
#     def cpu_data(self):
#         return self._cpu_data
# 
#     @property
#     def gpu_data(self):
#         return self._gpu_data
# 
# Path: dlearn/utils/math.py
# def create_shared(x):
# def create_empty(p):
# def dropout(x, ratio):


import numpy as np
from .hidata import HierarData
from ..utils.math import nprng

        if input is not None and target is not None:
            self._input = input
            self._target = target
        elif train is not None and valid is not None and test is not None:
            self._input = _combine(train.input, valid.input, test.input)
            self._target = _combine(train.target, valid.target, test.target)

            if isinstance(train.input, list):
                self._train.input = \
                    [HierarData(X, limit=self._limit) for X in train.input]
                self._valid.input = \
                    [HierarData(X, limit=self._limit) for X in valid.input]
                self._test.input = \
                    [HierarData(X, limit=self._limit) for X in test.input]
            else:
                self._train.input = HierarData(train.input, limit=self._limit)
                self._valid.input = HierarData(valid.input, limit=self._limit)
                self._test.input = HierarData(test.input, limit=self._limit)

            if isinstance(train.target, list):
                self._train.target = \
                    [HierarData(X, limit=self._limit) for X in train.target]
                self._valid.target = \
                    [HierarData(X, limit=self._limit) for X in valid.target]
                self._test.target = \
                    [HierarData(X, limit=self._limit) for X in test.target]
            else:
                self._train.target = HierarData(
                    train.target, limit=self._limit)

# Path: dlearn/data/hidata.py
# class HierarData(object):
# 
#     def __init__(self, data, limit=None):
#         self._cpu_data = data
# 
#         if limit is None or limit > data.shape[0]:
#             limit = data.shape[0]
#         self._limit = limit
# 
#         self._gpu_data = create_shared(self._cpu_data[0:limit])
#         self._cur_irange = create_shared(np.asarray([0, limit]))
# 
#     def prepare(self, irange):
#         l, r = irange
#         cur_l, cur_r = self._cur_irange.get_value(borrow=True)
# 
#         if min(l, r - 1) < cur_l or max(l, r - 1) >= cur_r:
#             self._cur_irange.set_value(np.asarray([l, l + self._limit]))
#             self._gpu_data.set_value(
#                 self._cpu_data[l:l + self._limit], borrow=True)
# 
#     @property
#     def cur_irange(self):
#         return self._cur_irange
# 
#     @property
#     def cpu_data(self):
#         return self._cpu_data
# 
#     @property
#     def gpu_data(self):
#         return self._gpu_data
# 
# Path: dlearn/utils/math.py
# def create_shared(x):
# def create_empty(p):
# def dropout(x, ratio):


# Path: dlearn/data/dataset.py
import numpy as np
from .hidata import HierarData
from ..utils.math import nprng


        if input is not None and target is not None:
            self._input = input
            self._target = target
        elif train is not None and valid is not None and test is not None:
            self._input = _combine(train.input, valid.input, test.input)
            self._target = _combine(train.target, valid.target, test.target)

            if isinstance(train.input, list):
                self._train.input = \
                    [HierarData(X, limit=self._limit) for X in train.input]
                self._valid.input = \
                    [HierarData(X, limit=self._limit) for X in valid.input]
                self._test.input = \
                    [HierarData(X, limit=self._limit) for X in test.input]
            else:
                self._train.input = HierarData(train.input, limit=self._limit)
                self._valid.input = HierarData(valid.input, limit=self._limit)
                self._test.input = HierarData(test.input, limit=self._limit)

            if isinstance(train.target, list):
                self._train.target = \
                    [HierarData(X, limit=self._limit) for X in train.target]
                self._valid.target = \
                    [HierarData(X, limit=self._limit) for X in valid.target]
                self._test.target = \
                    [HierarData(X, limit=self._limit) for X in test.target]
            else:
                self._train.target = HierarData(
                    train.target, limit=self._limit)

                self._valid.target = HierarData(