|
|
|
@ -1,21 +1,15 @@
|
|
|
|
|
import tensorflow as tf
|
|
|
|
|
from tensorflow import keras
|
|
|
|
|
config = tf.compat.v1.ConfigProto(gpu_options=tf.compat.v1.GPUOptions(allow_growth=True))
|
|
|
|
|
sess = tf.compat.v1.Session(config=config)
|
|
|
|
|
from tensorflow import keras
|
|
|
|
|
fashion_mnist = keras.datasets.fashion_mnist
|
|
|
|
|
(train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data()
|
|
|
|
|
|
|
|
|
|
print(train_images.shape)
|
|
|
|
|
|
|
|
|
|
import tensorflow as tf
|
|
|
|
|
from tensorflow import keras
|
|
|
|
|
num_mnist = keras.datasets.mnist
|
|
|
|
|
(train_images, train_labels), (test_images, test_labels) = num_mnist.load_data()
|
|
|
|
|
|
|
|
|
|
train_images = train_images[:1000]
|
|
|
|
|
train_labels = train_labels[:1000]
|
|
|
|
|
test_images = train_images[:1000]
|
|
|
|
|
test_labels = train_images[:1000]
|
|
|
|
|
print(train_images.shape)
|
|
|
|
|
print(train_labels.shape)
|
|
|
|
|
print(test_images.shape)
|
|
|
|
|
print(test_labels.shape)
|
|
|
|
|
|
|
|
|
|
model = keras.Sequential()
|
|
|
|
|
model.add(keras.layers.Conv2D(8, (3,3), activation = 'relu', input_shape = (28,28,1)))
|
|
|
|
@ -30,7 +24,8 @@ model.add(keras.layers.Dense(36, activation = tf.nn.softmax))
|
|
|
|
|
train_images_scaled = train_images/255
|
|
|
|
|
model.compile(optimizer = 'adam', loss = tf.losses.sparse_categorical_crossentropy, metrics = ['accuracy'])
|
|
|
|
|
|
|
|
|
|
history = model.fit(train_images_scaled.reshape(-1, 28, 28 ,1), train_labels, epochs = 10, batch_size=8)
|
|
|
|
|
history = model.fit(train_images_scaled.reshape(-1, 28, 28 ,1), train_labels, epochs = 8)
|
|
|
|
|
|
|
|
|
|
results = model.evaluate(test_images.reshape(-1, 28, 28 ,1), test_labels)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#test_images_scaled = test_images/255
|
|
|
|
|
#results = model.evaluate(test_images_scaled.reshape(-1, 28, 28 ,1), test_labels)
|
|
|
|
|