(self, y, num_classes)
| 335 | class TestPythonModule(unittest.TestCase): |
| 336 | |
| 337 | def to_categorical(self, y, num_classes): |
| 338 | y = np.array(y, dtype="int") |
| 339 | n = y.shape[0] |
| 340 | categorical = np.zeros((n, num_classes)) |
| 341 | categorical[np.arange(n), y] = 1 |
| 342 | return categorical |
| 343 | |
| 344 | def generate_data(self, dev, num=400): |
| 345 | f = lambda x: (5 * x + 1) |