def test_OneDimensionalX_ReshapeAddBias(self): x1 = [1, 2, 3] x2 = np.array([[1, 1], [2, 1], [3, 1]]) x1p = np.vstack(batchX(x1)[0]) self.assertEquals(x2.shape, x1p.shape) self.assertTrue(np.allclose(x2, x1p))
def test_InputTextCSV_Loads(self): d = os.path.join(os.path.dirname(__file__), "../datasets/Unittest-Iris") fx1 = os.path.join(d, "iris_data.txt") fx2 = os.path.join(d, "iris_data_comma.txt") x1 = np.vstack(batchX(fx1)[0]) x2 = np.vstack(batchX(fx2, delimiter=",")[0]) self.assertTrue(np.allclose(x1, x2))
def test_SetBatch_CorrectChunkSize(self): x = np.random.rand(10) x1 = batchX(x, batch=7)[0] x2 = np.hstack((x.reshape(-1, 1), np.ones((10, 1)))) self.assertTrue(np.allclose(x2[:7], x1.next())) self.assertTrue(np.allclose(x2[7:], x1.next()))
def test_batchX_GetNumberOfInputs(self): x = [[1, 2], [3, 4], [5, 6]] _, inputs, _ = batchX(x) self.assertEqual(2, inputs)