<jupyter_start><jupyter_text>Creating the CNN using the CC View<jupyter_code>annImageModel = tf.keras.models.Sequential()
#first argument = number of output in the layer 
#second argument = the filter/kernel size (tuple)
#input_shape = (batch_size, image size pixel, image size pixel, depth)
#in this case, 32 x 32 RGB picture with depth of 3
annImageModel.add(tf.keras.layers.Conv2D(64, (2, 2), activation='tanh', input_shape=(379, 366, 1), kernel_regularizer=tf.keras.regularizers.l2(0.01), bias_regularizer = tf.keras.regularizers.l2(0.01), activity_regularizer = tf.keras.regularizers.l2(0.01)))
#padding = 'valid' -> adds no padding
annImageModel.add(tf.keras.layers.MaxPooling2D((2, 2), padding = 'valid'))
annImageModel.add(tf.keras.layers.Conv2D(128, (2, 2), activation='tanh', kernel_regularizer=tf.keras.regularizers.l2(0.01), bias_regularizer = tf.keras.regularizers.l2(0.01), activity_regularizer = tf.keras.regularizers.l2(0.01)))
annImageModel.add(tf.keras.layers.MaxPooling2D((2, 2), padding = 'valid'))
annImageModel.add(tf.keras.layers.Conv2D(128, (2, 2), activation='relu', kernel_regularizer=tf.keras.regularizers.l2(0.01), bias_regularizer = tf.keras.regularizers.l2(0.01), activity_regularizer = tf.keras.regularizers.l2(0.01)))
#changing the model from 3D to 1D (where the input of dense has to be 1D)
annImageModel.add(tf.keras.layers.Flatten())
annImageModel.add(tf.keras.layers.Dense(64, activation = 'tanh'))
#annImageModel.add(tf.keras.layers.Dense(28, activation = 'tanh'))
#annImageModel.add(tf.keras.layers.Dense(8, activation = 'tanh'))
annImageModel.add(tf.keras.layers.Dense(1, activation = 'sigmoid'))
optimizer = tf.optimizers.Adam(lr = 0.000001)
annImageModel.compile(optimizer, loss = 'binary_crossentropy', metrics =['accuracy'])
annImageModel.summary()
#train the model
annImageModel.fit(XCCTrain, yMoBTrain, batch_size = 10, epochs = 100)<jupyter_output>Model: "sequential"
_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
conv2d (Conv2D)              (None, 378, 365, 64)      320       
_________________________________________________________________
max_pooling2d (MaxPooling2D) (None, 189, 182, 64)      0         
_________________________________________________________________
conv2d_1 (Conv2D)            (None, 188, 181, 128)     32896     
_________________________________________________________________
max_pooling2d_1 (MaxPooling2 (None, 94, 90, 128)       0         
_________________________________________________________________
conv2d_2 (Conv2D)            (None, 93, 89, 128)       65664     
_________________________________________________________________
flatten (Flatten)            (None, 1059456)           0         
________________________________________________________[...]<jupyter_text>Testing the Model<jupyter_code>XCCTest = XTest[:,0:138714]
#print(XCCTest.shape)
XCCTest = XCCTest.reshape(XTest.shape[0], 379, 366, 1)
#print(XCCTrain.shape)
annImageModel.evaluate(XCCTest, yMoBTest)<jupyter_output>146/146 [==============================] - 7s 49ms/sample - loss: 78978.4403 - accuracy: 0.6986<jupyter_text>CNN Using the MLO View<jupyter_code>XMLOTrain = XTrain[:,138714:]
print(XMLOTrain.shape)
XMLOTrain = XMLOTrain.reshape(XTrain.shape[0], 377, 364, 1)
print(XMLOTrain.shape)
annImageModel = tf.keras.models.Sequential()
#first argument = number of output in the layer 
#second argument = the filter/kernel size (tuple)
#input_shape = (batch_size, image size pixel, image size pixel, depth)
#in this case, 32 x 32 RGB picture with depth of 3
annImageModel.add(tf.keras.layers.Conv2D(64, (2, 2), activation='tanh', input_shape=(377, 364, 1), kernel_regularizer=tf.keras.regularizers.l2(0.01), bias_regularizer = tf.keras.regularizers.l2(0.01), activity_regularizer = tf.keras.regularizers.l2(0.01)))
#padding = 'valid' -> adds no padding
annImageModel.add(tf.keras.layers.MaxPooling2D((2, 2), padding = 'valid'))
annImageModel.add(tf.keras.layers.Conv2D(128, (2, 2), activation='tanh', kernel_regularizer=tf.keras.regularizers.l2(0.01), bias_regularizer = tf.keras.regularizers.l2(0.01), activity_regularizer = tf.keras.regularizers.l2(0.01)))
annImageModel.add(tf.keras.layers.MaxPooling2D((2, 2), padding = 'valid'))
annImageModel.add(tf.keras.layers.Conv2D(128, (2, 2), activation='relu', kernel_regularizer=tf.keras.regularizers.l2(0.01), bias_regularizer = tf.keras.regularizers.l2(0.01), activity_regularizer = tf.keras.regularizers.l2(0.01)))
#changing the model from 3D to 1D (where the input of dense has to be 1D)
annImageModel.add(tf.keras.layers.Flatten())
annImageModel.add(tf.keras.layers.Dense(64, activation = 'tanh'))
#annImageModel.add(tf.keras.layers.Dense(28, activation = 'tanh'))
#annImageModel.add(tf.keras.layers.Dense(8, activation = 'tanh'))
annImageModel.add(tf.keras.layers.Dense(1, activation = 'sigmoid'))
optimizer = tf.optimizers.Adam(lr = 0.000001)
annImageModel.compile(optimizer, loss = 'binary_crossentropy', metrics =['accuracy'])
annImageModel.summary()
annImageModel.fit(XMLOTrain, yMoBTrain, batch_size = 10, epochs = 100)

XMLOTest = XTest[:,138714:]
#print(XCCTest.shape)
XMLOTest = XMLOTest.reshape(XTest.shape[0], 377, 364, 1)
#print(XCCTrain.shape)
annImageModel.evaluate(XMLOTest, yMoBTest)<jupyter_output>146/146 [==============================] - 6s 43ms/sample - loss: 69321.6714 - accuracy: 0.6370
{'fraction_non_alphanumeric': 0.15474452554744525, 'fraction_numerical': 0.06350364963503649, 'mean_word_length': 5.982165605095541, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '149059', 'license': 'MIT', 'n_tokens_mistral': 2080, 'n_tokens_neox': 1822, 'n_words': 351, 'path': 'CNN.ipynb', 'repo_name': 'alvionna/breast-cancer-classification', 'size': '5480'}