<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Introduction
You've seen how to build a model from scratch to identify handwritten digits.  You'll now build a model to identify different types of clothing.  To make models that train quickly, we'll work with very small (low-resolution) images. 
As an example, your model will take an images like this and identify it as a shoe
Step1:  1) Start the model
Create a Sequential model called fashion_model. Don't add layers yet.
Step2:  2) Add the first layer
Add the first Conv2D layer to fashion_model. It should have 12 filters, a kernel_size of 3 and the relu activation function. The first layer always requires that you specify the input_shape.  We have saved the number of rows and columns to the variables img_rows and img_cols respectively, so the input shape in this case is (img_rows, img_cols, 1).
Step3:  3) Add the remaining layers
Add 2 more convolutional (Conv2D layers) with 20 filters each, 'relu' activation, and a kernel size of 3. Follow that with a Flatten layer, and then a Dense layer with 100 neurons. 
Add your prediction layer to fashion_model.  This is a Dense layer.  We alrady have a variable called num_classes.  Use this variable when specifying the number of nodes in this layer. The activation should be softmax (or you will have problems later).
Step4:  4) Compile Your Model
Compile fashion_model with the compile method.  Specify the following arguments
Step5:  5) Fit The Model
Run the command fashion_model.fit. The arguments you will use are
1. The data used to fit the model. First comes the data holding the images, and second is the data with the class labels to be predicted. Look at the first code cell (which was supplied to you) where we called prep_data to find the variable names for these.
2. batch_size = 100
3. epochs = 4
4. validation_split = 0.2
When you run this command, you can watch your model start improving.  You will see validation accuracies after each epoch.
Step6:  6) Create A New Model
Create a new model called second_fashion_model in the cell below.  Make some changes so it is different than fashion_model that you've trained above. The change could be using a different number of layers, different number of convolutions in the layers, etc.
Define the model, compile it and fit it in the cell below.  See how its validation score compares to that of the original model.
<ASSISTANT_TASK:>
Python Code:
import numpy as np
from sklearn.model_selection import train_test_split
from tensorflow import keras
img_rows, img_cols = 28, 28
num_classes = 10
def prep_data(raw):
    y = raw[:, 0]
    out_y = keras.utils.to_categorical(y, num_classes)
    
    x = raw[:,1:]
    num_images = raw.shape[0]
    out_x = x.reshape(num_images, img_rows, img_cols, 1)
    out_x = out_x / 255
    return out_x, out_y
fashion_file = "../input/fashionmnist/fashion-mnist_train.csv"
fashion_data = np.loadtxt(fashion_file, skiprows=1, delimiter=',')
x, y = prep_data(fashion_data)
# Set up code checking
from learntools.core import binder
binder.bind(globals())
from learntools.deep_learning.exercise_7 import *
print("Setup Complete")
Explanation: Introduction
You've seen how to build a model from scratch to identify handwritten digits.  You'll now build a model to identify different types of clothing.  To make models that train quickly, we'll work with very small (low-resolution) images. 
As an example, your model will take an images like this and identify it as a shoe:
Data Preparation
This code is supplied, and you don't need to change it. Just run the cell below.
End of explanation
from tensorflow import keras
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Flatten, Conv2D
# Your Code Here
____
# Check your answer
q_1.check()
#_COMMENT_IF(PROD)_
q_1.solution()
Explanation: 1) Start the model
Create a Sequential model called fashion_model. Don't add layers yet.
End of explanation
# Your code here
____
# Check your answer
q_2.check()
# q_2.hint()
#_COMMENT_IF(PROD)_
q_2.solution()
Explanation: 2) Add the first layer
Add the first Conv2D layer to fashion_model. It should have 12 filters, a kernel_size of 3 and the relu activation function. The first layer always requires that you specify the input_shape.  We have saved the number of rows and columns to the variables img_rows and img_cols respectively, so the input shape in this case is (img_rows, img_cols, 1).
End of explanation
# Your code here
____
# Check your answer
q_3.check()
# q_3.solution()
Explanation: 3) Add the remaining layers
Add 2 more convolutional (Conv2D layers) with 20 filters each, 'relu' activation, and a kernel size of 3. Follow that with a Flatten layer, and then a Dense layer with 100 neurons. 
Add your prediction layer to fashion_model.  This is a Dense layer.  We alrady have a variable called num_classes.  Use this variable when specifying the number of nodes in this layer. The activation should be softmax (or you will have problems later).
End of explanation
# Your code to compile the model in this cell
____
# Check your answer
q_4.check()
# q_4.solution()
Explanation: 4) Compile Your Model
Compile fashion_model with the compile method.  Specify the following arguments:
1. loss = "categorical_crossentropy"
2. optimizer = 'adam'
3. metrics = ['accuracy']
End of explanation
# Your code to fit the model here
____
# Check your answer
q_5.check()
#_COMMENT_IF(PROD)_
q_5.solution()
Explanation: 5) Fit The Model
Run the command fashion_model.fit. The arguments you will use are
1. The data used to fit the model. First comes the data holding the images, and second is the data with the class labels to be predicted. Look at the first code cell (which was supplied to you) where we called prep_data to find the variable names for these.
2. batch_size = 100
3. epochs = 4
4. validation_split = 0.2
When you run this command, you can watch your model start improving.  You will see validation accuracies after each epoch.
End of explanation
# Your code below
____
# Don't remove this line (ensures comptibility with tensorflow 2.0)
second_fashion_model.history.history['val_acc'] = second_fashion_model.history.history['val_accuracy']
# Check your answer
q_6.check()
#_COMMENT_IF(PROD)_
q_6.solution()
#%%RM_IF(PROD)%%
from tensorflow import keras
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Flatten, Conv2D
fashion_model = Sequential()
q_1.assert_check_passed()
fashion_model.add(Conv2D(12,
                         activation='relu',
                         kernel_size=3,
                         input_shape = (img_rows, img_cols, 1)))
q_2.assert_check_passed()
fashion_model.add(Conv2D(20, activation='relu', kernel_size=3))
fashion_model.add(Conv2D(20, activation='relu', kernel_size=3))
fashion_model.add(Flatten())
fashion_model.add(Dense(100, activation='relu'))
fashion_model.add(Dense(10, activation='softmax'))
q_3.assert_check_passed()
fashion_model.compile(loss='categorical_crossentropy',
                      optimizer='adam',
                      metrics=['accuracy'])
q_4.assert_check_passed()
# 1 epoch and high val_split to speed up testing
fashion_model.fit(x, y, batch_size=100, epochs=1, validation_split=0.5)
q_5.assert_check_passed()
second_fashion_model = Sequential()
second_fashion_model.add(Conv2D(12,
                         activation='relu',
                         kernel_size=3,
                         input_shape = (img_rows, img_cols, 1)))
# Changed kernel sizes to be 2
second_fashion_model.add(Conv2D(20, activation='relu', kernel_size=2))
second_fashion_model.add(Conv2D(20, activation='relu', kernel_size=2))
# added an addition Conv2D layer
second_fashion_model.add(Conv2D(20, activation='relu', kernel_size=2))
second_fashion_model.add(Flatten())
second_fashion_model.add(Dense(100, activation='relu'))
# It is important not to change the last layer. First argument matches number of classes. Softmax guarantees we get reasonable probabilities
second_fashion_model.add(Dense(10, activation='softmax'))
second_fashion_model.compile(loss='categorical_crossentropy',
                             optimizer='adam',
                             metrics=['accuracy'])
# 1 epoch to speed up testing
second_fashion_model.fit(x, y, batch_size=100, epochs=1, validation_split=0.2)
q_6.assert_check_passed()
Explanation: 6) Create A New Model
Create a new model called second_fashion_model in the cell below.  Make some changes so it is different than fashion_model that you've trained above. The change could be using a different number of layers, different number of convolutions in the layers, etc.
Define the model, compile it and fit it in the cell below.  See how its validation score compares to that of the original model.
End of explanation
<END_TASK>