I am unable to find a pretrained model for alexnet on tensor flow , can someone help me out with this ?
Hi @Sai_Parayan, As per my knowledge, there isn’t any official pre trained model for alexnet using tensorflow. Thank You.
sir thank you for informing , i have changed my architecture to resnet and am trying to classify some images but its unable to classify them . my validation accuracy never increases always remains constant. speckle patterns are the types of images i am trying to classify (using 1250 for each class , 1000 for training set and 250 for validation) , what might i be doing wrong
@Sai_Parayan Please provide with details on your model so that people can help you out. Thank you.
Hi @Sai_Parayan, If possible could you please add more images for training, else try to increase the images by performing data augmentation and let us know if there is any increase in accuracy. Thank You.
sir thank you for informing , i have changed my architecture to vgg16 and am trying to classify some images but its unable to classify them . my validation and training accuracy never increases always remains constant.i am also using a pretrained model, i am trying to classify laguerre gaussian mode images (using 1250for each class , 1000 for training set and 250 for validation) , what might i be doing wrong. i am unable to post the image data since it is a post
this is the paper i am using as a reference to classify images sir
Identifying Laguerre-Gaussian Modes using Convolutional Neural Network (nsf.gov)https://par.nsf.gov/servlets/purl/10225108
import tensorflow as tf
from tensorflow.keras.applications import VGG16
from tensorflow.keras import layers, Model
from tensorflow.keras.preprocessing.image import ImageDataGenerator
Load the pre-trained VGG16 model without the top classification layers
base_model = VGG16(weights=‘imagenet’, include_top=False, input_shape=(224, 224, 3))
Freeze the weights of the pre-trained layers
for layer in base_model.layers:
layer.trainable = False
Add custom classification layers with convolution and max-pooling layers
x = base_model.output
x = layers.Conv2D(256, (3, 3), activation=‘relu’)(x)
x = layers.MaxPooling2D((2, 2))(x)
x = layers.Flatten()(x)
x = layers.Dense(256, activation=‘relu’)(x)
x = layers.Dense(128, activation=‘relu’)(x)
outputs = layers.Dense(8, activation=‘softmax’)(x) # Adjust the number of classes as needed
Create the new model
model = Model(inputs=base_model.input, outputs=outputs)
Compile the model with custom optimizer and loss
custom_optimizer = tf.keras.optimizers.SGD(learning_rate=0.0001, momentum=0.9)
model.compile(optimizer=custom_optimizer, loss=‘categorical_crossentropy’, metrics=[‘accuracy’])
Define data augmentation parameters
datagen = ImageDataGenerator(
rescale=1.0/255,
rotation_range=20,
width_shift_range=0.2,
height_shift_range=0.2,
shear_range=0.2,
zoom_range=0.2,
horizontal_flip=True,
fill_mode=‘nearest’
)
Load and preprocess your dataset using data generators
Replace these paths with the paths to your dataset
train_data = datagen.flow_from_directory(
‘/path/to/train_data’,
target_size=(224, 224),
batch_size=32,
class_mode=‘categorical’,
shuffle=True
)
val_data = datagen.flow_from_directory(
‘/path/to/val_data’,
target_size=(224, 224),
batch_size=32,
class_mode=‘categorical’,
shuffle=False
)
Fine-tune the model on your dataset
epochs = 10 # Adjust the number of epochs
model.fit(train_data, validation_data=val_data, epochs=epochs)
Save the fine-tuned model if needed
model.save(‘fine_tuned_vgg16_model.keras’)
this is my model sir , but no matter what i do my training acc doesnt increase.
This is the model summary
Model: “model_7”
Layer (type) Output Shape Param #
input_8 (InputLayer) [(None, 224, 224, 3)] 0
block1_conv1 (Conv2D) (None, 224, 224, 64) 1792
block1_conv2 (Conv2D) (None, 224, 224, 64) 36928
block1_pool (MaxPooling2D) (None, 112, 112, 64) 0
block2_conv1 (Conv2D) (None, 112, 112, 128) 73856
block2_conv2 (Conv2D) (None, 112, 112, 128) 147584
block2_pool (MaxPooling2D) (None, 56, 56, 128) 0
block3_conv1 (Conv2D) (None, 56, 56, 256) 295168
block3_conv2 (Conv2D) (None, 56, 56, 256) 590080
block3_conv3 (Conv2D) (None, 56, 56, 256) 590080
block3_pool (MaxPooling2D) (None, 28, 28, 256) 0
block4_conv1 (Conv2D) (None, 28, 28, 512) 1180160
block4_conv2 (Conv2D) (None, 28, 28, 512) 2359808
block4_conv3 (Conv2D) (None, 28, 28, 512) 2359808
block4_pool (MaxPooling2D) (None, 14, 14, 512) 0
block5_conv1 (Conv2D) (None, 14, 14, 512) 2359808
block5_conv2 (Conv2D) (None, 14, 14, 512) 2359808
block5_conv3 (Conv2D) (None, 14, 14, 512) 2359808
block5_pool (MaxPooling2D) (None, 7, 7, 512) 0
conv2d_7 (Conv2D) (None, 5, 5, 256) 1179904
max_pooling2d_5 (MaxPoolin (None, 2, 2, 256) 0
g2D)
flatten_3 (Flatten) (None, 1024) 0
dense_21 (Dense) (None, 256) 262400
dense_22 (Dense) (None, 128) 32896
dense_23 (Dense) (None, 8) 1032
=================================================================
Total params: 16190920 (61.76 MB)
Trainable params: 1476232 (5.63 MB)
Non-trainable params: 14714688 (56.13 MB)