├── Example Code python └── README.md /Example Code python: -------------------------------------------------------------------------------- 1 | # Example of training a neural network for image classification with TensorFlow 2 | import tensorflow as tf 3 | from tensorflow.keras import datasets, layers, models 4 | 5 | # Load CIFAR-10 dataset 6 | (train_images, train_labels), (test_images, test_labels) = datasets.cifar10.load_data() 7 | 8 | # Normalize data 9 | train_images, test_images = train_images / 255.0, test_images / 255.0 10 | 11 | # Define CNN model 12 | model = models.Sequential([ 13 | layers.Conv2D(32, (3, 3), activation='relu', input_shape=(32, 32, 3)), 14 | layers.MaxPooling2D((2, 2)), 15 | layers.Conv2D(64, (3, 3), activation='relu'), 16 | layers.MaxPooling2D((2, 2)), 17 | layers.Conv2D(64, (3, 3), activation='relu'), 18 | layers.Flatten(), 19 | layers.Dense(64, activation='relu'), 20 | layers.Dense(10) 21 | ]) 22 | 23 | # Compile and train the model 24 | model.compile(optimizer='adam', 25 | loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True), 26 | metrics=['accuracy']) 27 | 28 | history = model.fit(train_images, train_labels, epochs=10, 29 | validation_data=(test_images, test_labels)) 30 | 31 | # Evaluate model accuracy 32 | test_loss, test_acc = model.evaluate(test_images, test_labels, verbose=2) 33 | print(f'Test accuracy: {test_acc}') 34 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Machine-Learning-Project-with-TensorFlow-in-Python 2 | This repository includes a machine learning project using TensorFlow for image classification 3 | --------------------------------------------------------------------------------