Image Modeling with Keras
Ariel Rokem
Senior Data Scientist, University of Washington
labels = ["shoe", "dress", "shoe", "t-shirt",
"shoe", "t-shirt", "shoe", "dress"]
array([[0., 0., 1.], <= shoe
[0., 1., 0.], <= dress
[0., 0., 1.], <= shoe
[1., 0., 0.], <= t-shirt
[0., 0., 1.], <= shoe
[1., 0., 0.], <= t-shirt
[0., 0., 1.], <= shoe
[0., 1., 0.]]) <= dress
categories = np.array(["t-shirt", "dress", "shoe"])
n_categories = 3 ohe_labels = np.zeros((len(labels), n_categories))
for ii in range(len(labels)):
jj = np.where(categories == labels[ii])
ohe_labels[ii, jj] = 1
test
array([[0., 0., 1.],
[0., 1., 0.],
[0., 0., 1.],
[0., 1., 0.],
[0., 0., 1.],
[0., 0., 1.],
[0., 0., 1.],
[0., 1., 0.]])
(test * prediction).sum()
6.0
prediction
array([[0., 0., 1.],
[0., 1., 0.],
[0., 0., 1.],
[1., 0., 0.], <= incorrect
[0., 0., 1.],
[1., 0., 0.], <= incorrect
[0., 0., 1.],
[0., 1., 0.]])
Image Modeling with Keras