Pythonda birçok kütüphaneyi kullanarak sağlayabilirsiniz.
Örnek kod ;
import numpy as np
import keras
from keras.datasets import cifar10
from keras.models import Sequential
from keras.layers import Dense, Dropout, Flatten, Conv2D, MaxPooling2D
from keras.optimizers import RMSprop
from keras.utils import to_categorical
# Step 1: Load the dataset
(x_train, y_train), (x_test, y_test) = cifar10.load_data()
# Step 2: Preprocess the data
x_train = x_train.astype('float32')
x_test = x_test.astype('float32')
x_train /= 255
x_test /= 255
y_train = to_categorical(y_train, 10)
y_test = to_categorical(y_test, 10)
# Step 3: Create the model
model = Sequential()
model.add(Conv2D(32, kernel_size=(3, 3), activation='relu', input_shape=(32, 32, 3)))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Flatten())
model.add(Dense(10, activation='softmax'))
# Step 4: Compile the model
model.compile(loss='categorical_crossentropy', optimizer=RMSprop(), metrics=['accuracy'])
# Step 5: Train the model
model.fit(x_train, y_train, batch_size=32, epochs=10, validation_data=(x_test, y_test))
# Step 6: Test the model on new data
new_image = ... # load new image
predictions = model.predict(new_image)
print(predictions)projenize göre düzenleyebilirsiniz.