def suite(): test_modules = [ "tests.test_datasaver", "tests.test_nas", ] if is_torch_available(): test_modules.extend([ "tests.test_torch_data", "tests.test_torch_model", "tests.test_torch_optimizer", ]) if is_tf_available(): test_modules.extend([ "tests.test_tf_data", "tests.test_tf_model", "tests.test_tf_optimizer", ]) alltests = unittest.TestSuite() for name in test_modules: # Unexpectedly, the following code doesn't seem to work anymore # in python 3 # exec('from %s import suite as test_suite' % name) __import__(name) test_suite = sys.modules[name].suite alltests.addTest(test_suite()) return alltests
def _check_data_numpytype(self): """ Check data which is numpy array type """ if not isinstance(self._datas, dict): raise TypeError("datas shoud be dict type.", self.__call__.__doc__) bzs = 0 for name, array in self._datas.items(): self._check_attr_name(name=name) if is_tf_available() and not isinstance(array, np.ndarray): array = array.numpy() if is_torch_available() and not isinstance(array, np.ndarray): array = array.numpy() assert isinstance(array, np.ndarray), "array type is not `numpy.ndarray`" if bzs: if bzs != array.shape[0]: raise ValueError( "each datas array batch sizes are not same.") else: bzs = array.shape[0] # This resape is made into a (B, *) shape. # Shape is lowered to two contiguous dimensions, enabling IO operations to operate very quickly. # https://www.slideshare.net/HDFEOS/caching-and-buffering-in-hdf5#25 if len(array.shape) == 1: # this array is ground truth array = array.reshape(-1, 1) self._datas[name] = array.reshape( -1, reduce(lambda x, y: x * y, array.shape[1:]))