Reformats the data to the format acceptable for convolutional layers :param x: input array :param y: corresponding labels :return: reshaped input and labels
(x, y)
| 33 | |
| 34 | |
| 35 | def reformat(x, y): |
| 36 | """ |
| 37 | Reformats the data to the format acceptable for convolutional layers |
| 38 | :param x: input array |
| 39 | :param y: corresponding labels |
| 40 | :return: reshaped input and labels |
| 41 | """ |
| 42 | img_size, num_ch, num_class = int(np.sqrt(x.shape[-1])), 1, len(np.unique(np.argmax(y, 1))) |
| 43 | dataset = x.reshape((-1, img_size, img_size, num_ch)).astype(np.float32) |
| 44 | labels = (np.arange(num_class) == y[:, None]).astype(np.float32) |
| 45 | return dataset, labels |
| 46 | |
| 47 | |
| 48 | def get_next_batch(x, y, start, end): |