0
  1. I am trying for classification of MSTAR data set with 10 classes
  2. I have used the modal that contains DCNN and BILSTM with 15 time steps

My questions are:

  1. How to overcome the error
  2. How to get the good classification results.

My code is:

inputs=Input(shape=(15,60,60,3))
model = Sequential()
# 1st Convolutional Layer
model.add(TimeDistributed(Conv2D(filters=16 ,kernel_size=(5,5), padding='valid'),input_shape=(15,60,60,3)))
model.add(TimeDistributed(Activation('relu')))
# Batch Normalisation
model.add(TimeDistributed(BatchNormalization()))
# Pooling 
model.add(TimeDistributed(MaxPooling2D(pool_size=(2,2), strides=(2,2), padding='valid')))

# 2nd Convolutional Layer
model.add(TimeDistributed(Conv2D(filters=32, kernel_size=(5,5), padding='valid')))
model.add(TimeDistributed(Activation('relu')))
# Batch Normalisation
model.add(TimeDistributed(BatchNormalization()))
# Pooling
model.add(TimeDistributed(MaxPooling2D(pool_size=(2,2), strides=(2,2), padding='valid')))

# 3rd Convolutional Layer
model.add(TimeDistributed(Conv2D(filters=64, kernel_size=(5,5), padding='valid')))
model.add(Activation('relu'))
# Batch Normalisation
model.add(TimeDistributed(BatchNormalization()))
# Pooling
model.add(TimeDistributed(MaxPooling2D(pool_size=(2,2), strides=(2,2), padding='valid')))

# 4th Convolutional Layer
model.add(TimeDistributed(Conv2D(filters=128, kernel_size=(4,4), padding='valid')))
model.add(TimeDistributed(Activation('relu')))
# Batch Normalisation
model.add(TimeDistributed(BatchNormalization()))
model.add(TimeDistributed(Flatten()))
#add dropout
model.add(Dropout(0.0))
#bidirectional lstm
model.add(Bidirectional(LSTM(1024,activation='tanh',return_sequences=True)))
#2 nd bidirectional layer
model.add(Bidirectional(LSTM(1024,activation='tanh',return_sequences=False)))
# Output Layer
model.add(Dense(10))
model.add(Activation('softmax'))

# (4) Compile 
model.compile(loss='categorical_crossentropy', optimizer='adam',\
 metrics=['accuracy'])
model.summary()
Sairam
  • 1
  • 1
  • hi, can you share where are you getting the error, the complete error stack, and an example input so that we can try it out ourselves? – ibarrond Jun 10 '21 at 07:57
  • 1.this is my input: train= ImageDataGenerator(rescale=1./255) test= ImageDataGenerator(rescale=1./255) train_dataset=train.flow_from_directory('/content/drive/MyDrive/Colab Notebooks/MSTAR-10/train',target_size=(60,60),batch_size=15,class_mode='categorical') test_dataset=test.flow_from_directory('/content/drive/MyDrive/Colab Notebooks/MSTAR-10/test',target_size=(60,60),batch_size=15,class_mode='categorical') 2.I got the error here: classifier=model.fit_generator(train_dataset,steps_per_epoch=15,epochs=10,validation_data=test_dataset,validation_steps=15) – Sairam Jun 14 '21 at 08:05
  • Where did you get your model from? I would say you don't need the `TimeDistributed` in the `model.add(TimeDistributed(Flatten()))` layer, since the input data is flattened. Can you try with `model.add(Flatten())` instead? – ibarrond Jun 14 '21 at 15:22
  • Thank you,but Bilstm needs 3 dimensional as input but here flatten gives 2 dimensional output and Bilstm needs (samples,timesteps,features) as input.can you please give the suggestion how i could get the 3d input shape with(none,15,128).Here my time steps are 15,here none denotes number of samples – Sairam Jun 14 '21 at 16:35
  • Ok, forget what I said. Can you share with us some code (including mock input generation) to reproduce the error on our side? – ibarrond Jun 14 '21 at 18:23
  • thank you, the below link provides the code : https://colab.research.google.com/drive/1duNxA4EhMQChFit2vOOuSMNTl6ChJL8t?usp=sharing – Sairam Jun 14 '21 at 18:56
  • can you give any sugession about this code – Sairam Jun 15 '21 at 11:11

0 Answers0