MCPcopy Create free account
hub / github.com/easy-tensorflow/easy-tensorflow / reformat

Function reformat

6_Convolutional_Neural_Network/code/utils.py:35–45  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

33
34
35def 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
48def get_next_batch(x, y, start, end):

Callers 1

load_dataFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected