fashion dataset from https://www.tensorflow.org/tutorials/keras/basic_classification
has lots of wears of different categories
------------------
#pycharm
from tensorflow import keras
import numpy as np
import matplotlib.pyplot as plt
data = keras.datasets.fashion_mnist
(train_images, train_labels), (test_images, test_labels) = data.load_data()
print(train_labels)
--------------------------
#logs
[9 0 0 ... 3 0 5]
------------------------------
#pycharm
#classify categories
class_names = ['T-shirt/top', 'Trouser', 'Pullover', 'Dress', 'Coat', 'Sandal', 'Shirt', 'Sneaker', 'Bag', 'Ankle boot']
#print image data
print(train_images[7])
---------------------------------
#logs
#image is consist of 28 x 28 pixels
[[ 0 0 0 0 0 1 1 0 0 0 0 63 28 0 0 0 33 85
0 0 0 0 0 0 0 0 0 0]
[ 0 0 0 0 0 2 0 0 28 126 241 255 255 255 255 255 255 252
248 111 0 0 0 2 0 0 0 0]
[ 0 0 0 0 2 0 0 206 244 251 241 230 238 221 205 230 240 230
239 251 233 165 0 0 2 0 0 0]
[ 0 0 0 1 0 0 199 251 228 234 233 236 235 245 247 237 234 239
230 230 235 255 176 0 0 1 0 0]
[ 0 0 0 0 0 81 254 226 228 239 237 236 234 232 233 235 235 236
239 237 233 225 246 73 0 0 0 0]
[ 0 0 3 0 0 255 235 239 223 234 238 236 237 236 235 235 235 235
236 235 234 230 231 255 24 0 4 0]
[ 0 0 0 0 177 239 223 254 223 232 234 234 236 236 235 235 235 235
235 234 231 233 222 246 88 0 1 0]
[ 0 0 0 0 234 239 229 255 220 232 233 232 234 235 235 235 235 235
234 233 232 230 228 254 140 0 0 0]
[ 0 0 0 0 225 240 226 255 221 227 232 228 231 230 228 229 231 230
228 228 232 223 229 244 231 0 0 0]
[ 0 0 0 47 245 231 234 249 229 221 229 225 229 227 226 227 228 227
228 229 228 224 246 240 227 0 0 0]
[ 0 0 0 51 248 230 245 246 230 226 230 227 230 229 228 229 230 228
228 231 225 227 242 237 255 0 0 0]
[ 0 0 0 101 253 229 247 241 221 233 228 227 229 228 227 228 230 227
230 234 225 229 251 229 243 55 0 0]
[ 0 0 0 102 255 227 242 241 221 234 223 230 228 231 229 231 231 227
229 241 219 236 254 225 250 167 0 0]
[ 0 0 0 90 255 229 236 231 222 236 223 231 229 231 229 231 231 228
224 245 218 243 239 227 244 175 0 0]
[ 0 0 0 212 250 225 236 249 229 237 223 231 229 231 229 231 231 230
221 243 225 248 230 236 234 255 1 0]
[ 0 0 0 245 243 232 243 218 228 238 222 231 229 231 229 231 231 230
222 237 237 252 229 239 240 223 0 0]
[ 0 0 27 255 235 242 237 216 230 236 224 229 227 233 233 233 230 228
224 230 245 247 221 243 239 252 0 0]
[ 0 0 88 255 232 248 236 208 234 231 223 227 226 233 232 232 230 228
224 224 235 233 234 247 235 255 0 0]
[ 0 0 83 255 225 250 237 224 236 229 225 225 227 235 229 231 230 230
227 221 227 221 239 250 231 255 0 0]
[ 0 0 20 255 224 248 234 226 232 222 225 224 231 238 226 230 228 230
230 221 229 225 244 246 230 255 0 0]
[ 0 0 95 255 218 242 255 232 226 224 229 228 228 232 228 229 231 233
232 226 221 224 247 244 228 255 0 0]
[ 0 0 167 255 213 235 255 81 245 251 238 236 230 229 230 229 230 231
238 240 255 192 255 239 228 255 23 0]
[ 0 0 173 242 224 233 255 0 136 226 239 255 229 236 236 234 233 228
251 248 200 81 255 237 225 255 101 0]
[ 0 0 172 255 226 233 255 0 0 0 0 0 8 21 22 21 20 14
0 0 0 0 255 238 229 246 178 0]
[ 0 0 16 255 236 238 252 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 222 244 222 254 119 0]
[ 0 0 0 30 228 242 163 0 0 0 0 2 4 6 5 5 4 4
2 0 1 0 151 251 235 180 0 0]
[ 0 0 0 0 234 255 191 0 11 0 0 0 0 0 0 0 0 0
0 0 4 0 103 246 247 72 0 0]
[ 0 0 0 1 95 77 52 0 4 0 0 0 0 0 0 0 0 0
0 0 3 0 82 237 231 70 0 0]]
-------------------------------------------------------
#pycharm
#divide pixel array by max pixel intensity so that pixel range from 0 to 1
train_images = train_images/255.0
test_images = test_images/255.0
---------------------------------------
#pycharm
#show image
plt.imshow(train_images[7], cmap=plt.cm.binary)
plt.show()
------------------------------
#matplotlib
-----------------------------
reference
No comments:
Post a Comment