Building and training an AlexNet-like model using the CIFAR-10 dataset in TensorFlow/Keras: Program to build the model: import tensorflow as tf from tensorflow.keras.layers import Conv2D, MaxPooling2D, Flatten, Dense, Dropout from tensorflow.keras.datasets import cifar10 from tensorflow.keras.utils import to_categorical from sklearn.model_selection import train_test_split # Load and preprocess CIFAR-10 dataset (x_train, y_train), (x_test, y_test) = cifar10.load_data() x_train = x_train.astype( 'float32' ) / 255.0 x_test = x_test.astype( 'float32' ) / 255.0 y_train = to_categorical(y_train, num_classes= 10 ) y_test = to_categorical(y_test, num_classes= 10 ) # Split into training and validation sets x_train, x_val, y_train, y_val = train_test_split(x_train, y_train, test_size= 0.1 , random_state= 42 ) # Define the model architecture '''model = tf.keras.Sequential([ Conv2D(96, (11, 11), strides=(4, 4), activation='relu', input_shape=(32...
Comments
Post a Comment