🚓Praktikum 2
Klasifikasi Multi-label dengan Data CIFAT
Deskripsi
Langkah 1 - Load Library
import tensorflow as tf
from tensorflow.keras import datasets, layers, models
import matplotlib.pyplot as pltLangkah 2 - Unduh Dataset CIFAR
(train_images, train_labels), (test_images, test_labels) = datasets.cifar10.load_data()
# Normalize pixel values to be between 0 and 1
train_images, test_images = train_images / 255.0, test_images / 255.0Langkah 3 - Verifikasi Data
class_names = ['airplane', 'automobile', 'bird', 'cat', 'deer',
'dog', 'frog', 'horse', 'ship', 'truck']
plt.figure(figsize=(10,10))
for i in range(25):
plt.subplot(5,5,i+1)
plt.xticks([])
plt.yticks([])
plt.grid(False)
plt.imshow(train_images[i])
# The CIFAR labels happen to be arrays,
# which is why you need the extra index
plt.xlabel(class_names[train_labels[i][0]])
plt.show()Langkah 4 - Buat Model CNN
Langkah 4.1. - Buat Layer Konvolusi
Langkah 4.2. - Cek Arsitektur Konvolusi
Langkah 4.3. - Tambahkan Layer Fully Connected
Langkah 4.4. - Cek Arsitektur Model CNN
Langkah 4.5. - Compile Model CNN
Langkah 5 - Fit Model
Langkah 6 - Evaluasi Model

Langkah 7 - Cetak Hasil Akurasi
Last updated
Was this helpful?