<jupyter_start><jupyter_text>Classification with CIFAR-10 Dataset and VGG-style networkThis script sets up a VGG-style network to classify two classes from the CIFAR-10 dataset.<jupyter_code>import keras
from keras.datasets import mnist
from keras.models import Sequential
from keras.layers import Input, Conv2D, Dense, Flatten, MaxPooling2D
from keras.optimizers import SGD
from matplotlib import pyplot as plt
import numpy as np
from utils import *
(x_train, y_train), (x_test, y_test) = get_cifar10_data(vectorize=False)<jupyter_output><empty_output><jupyter_text>Build the model.<jupyter_code>model = Sequential()
model.add(Conv2D(64,3,padding='same',activation='relu',input_shape=(32,32,3)))
model.add(Conv2D(64,3,padding='same',activation='relu'))
model.add(Conv2D(64,3,padding='same',activation='relu'))
model.add(MaxPooling2D(2,2))
model.add(Conv2D(128,3,padding='same',activation='relu'))
model.add(Conv2D(128,3,padding='same',activation='relu'))
model.add(MaxPooling2D(2,2))
model.add(Conv2D(256,3,padding='same',activation='relu'))
model.add(Flatten())
model.add(Dense(200,activation='relu'))
model.add(Dense(1,activation='sigmoid'))
model.summary()<jupyter_output>_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
conv2d_1 (Conv2D)            (None, 32, 32, 64)        1792      
_________________________________________________________________
conv2d_2 (Conv2D)            (None, 32, 32, 64)        36928     
_________________________________________________________________
conv2d_3 (Conv2D)            (None, 32, 32, 64)        36928     
_________________________________________________________________
max_pooling2d_1 (MaxPooling2 (None, 16, 16, 64)        0         
_________________________________________________________________
conv2d_4 (Conv2D)            (None, 16, 16, 128)       73856     
_________________________________________________________________
conv2d_5 (Conv2D)            (None, 16, 16, 128)       147584    
_________________________________________________________________
max_poolin[...]<jupyter_text>Set up the model to optimize the binary crossentropy loss using stochastic gradient descent.<jupyter_code>model.compile(loss='binary_crossentropy',
              optimizer='adam',
              metrics=['accuracy'])<jupyter_output><empty_output><jupyter_text>Optimize the model over the training data.<jupyter_code>history = model.fit(x_train, y_train,
                    batch_size=100,
                    epochs=50,
                    verbose=1,
                    validation_data=(x_test, y_test))
plot_history(history)
evaluate_test_accuracy(model,x_test,y_test)<jupyter_output>2000/2000 [==============================] - 0s 191us/step
Test accuracy: 97.35%
{'fraction_non_alphanumeric': 0.13247116392869626, 'fraction_numerical': 0.053827333100314574, 'mean_word_length': 5.037974683544304, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '651100', 'license': 'MIT', 'n_tokens_mistral': 927, 'n_tokens_neox': 816, 'n_words': 158, 'path': 'cifar10/vgg_cifar10.ipynb', 'repo_name': 'jonathanventura/nncookbook', 'size': '2861'}