application_vnd.jupyter.stderr_output_2.png text_plain_output_1.png
from keras.layers import Convolution2D,MaxPooling2D,Flatten,Dense,Dropout

from keras.models import Sequential

from keras.optimizers import Adam

from tensorflow.keras.preprocessing.image import ImageDataGenerator

import keras

TRAINING_DIR = '/kaggle/input/tomato/New Plant Diseases Dataset(Augmented)/train/'
VALIDATION_DIR = '/kaggle/input/tomato/New Plant Diseases Dataset(Augmented)/valid/'
train_gen = ImageDataGenerator(rescale=1.0 / 255, rotation_range=0, width_shift_range=0.2, height_shift_range=0.2, shear_range=0.2, zoom_range=0.2, horizontal_flip=True, fill_mode='nearest')
valid_gen = ImageDataGenerator(rescale=1.0 / 255)
train_data = train_gen.flow_from_directory(TRAINING_DIR, target_size=(227, 227), class_mode='categorical', color_mode='rgb', batch_size=64)
valid_data = valid_gen.flow_from_directory(VALIDATION_DIR, target_size=(227, 227), class_mode='categorical', color_mode='rgb')

model = Sequential()
model.add(Convolution2D(96, 11, strides=(4, 4), padding='valid', input_shape=(227, 227, 3), activation='relu'))
model.add(MaxPooling2D(pool_size=(3, 3), strides=(2, 2), padding='valid'))
model.add(Convolution2D(256, 5, strides=(1, 1), padding='same', activation='relu'))
model.add(MaxPooling2D(pool_size=(3, 3), strides=(2, 2), padding='valid'))
model.add(Convolution2D(384, 3, strides=(1, 1), padding='same', activation='relu'))
model.add(Convolution2D(384, 3, strides=(1, 1), padding='same', activation='relu'))
model.add(Convolution2D(256, 3, strides=(1, 1), padding='same', activation='relu'))
model.add(MaxPooling2D(pool_size=(3, 3), strides=(2, 2), padding='valid'))
model.add(Flatten())
model.add(Dense(units=4096, activation='relu'))
model.add(Dense(units=4096, activation='relu'))
model.add(Dense(units=10, activation='softmax'))
model.summary()

from keras.optimizers import Adam
import keras
opt = Adam(lr=0.001)
model.compile(optimizer=opt, loss=keras.losses.categorical_crossentropy, metrics=['accuracy'])

train_num = train_data.n
valid_num = valid_data.n
train_batch_size = train_data.batch_size
valid_batch_size = valid_data.batch_size
STEP_SIZE_TRAIN = train_num // train_batch_size
STEP_SIZE_VALID = valid_num // valid_batch_size
history = model.fit_generator(generator=train_data, steps_per_epoch=STEP_SIZE_TRAIN, validation_data=valid_data, validation_steps=STEP_SIZE_VALID, epochs=25)