SadmanSakib93 / Stratified-k-fold-cross-validation-Image-classification-keras

This python program demonstrates image classification with stratified k-fold cross validation technique.
33 stars 15 forks source link

Question about the code #2

Closed zaimpower closed 3 years ago

zaimpower commented 3 years ago

Hi, thank you for the code. But I am encountering a problem using this code. I am using 4 classes as your code is only for 3 class. So I've done a little tweak on your code but it comes an error. I hope that you could help me with the error. Here are your code that i have tweak a little.

ds.txt

The error that I am encountering shows this

ValueError: A target array with shape (64, 4) was passed for an output of shape (None, 3) while using as loss binary_crossentropy. This loss expects targets to have the same shape as the output.

I hope that you could really really help me

SadmanSakib93 commented 3 years ago

As you have four output classes you need to provide 4 nodes in the last dense layers, modify the code as follows: model.add(Dense(4, activation='softmax')) or to make it more dynamic, you could write: model.add(Dense(len(classLabels), activation='softmax'))

zaimpower commented 3 years ago

Hi, may i know how to change the learning rate in example 0.1, 0.01, 0.001?

SadmanSakib93 commented 3 years ago

Hi, may i know how to change the learning rate in example 0.1, 0.01, 0.001?

In Keras you could use the Learning rate scheduler (check here)

zaimpower commented 3 years ago

Hi, may i know how to change the learning rate in example 0.1, 0.01, 0.001?

In Keras you could use the Learning rate scheduler (check here)

Oh is that mean that i cant set a specific learning rate?

SadmanSakib93 commented 3 years ago

Hi, may i know how to change the learning rate in example 0.1, 0.01, 0.001?

In Keras you could use the Learning rate scheduler (check here)

Oh is that mean that i cant set a specific learning rate?

Yes, you can definitely set a specific learning rate. (Check this)

ghost commented 3 years ago

Hi, thank you for the code. But I am encountering a problem using this code. I am using 9 classes as your code is only for 3 class. So I've done a little tweak on your code but it comes and also I'm trying to replace the model with pretrained model and there is an error when I'm trying to move the data from train to validation . I hope that you could help me with the error.

SadmanSakib93 commented 3 years ago

Hi, thank you for the code. But I am encountering a problem using this code. I am using 9 classes as your code is only for 3 class. So I've done a little tweak on your code but it comes and also I'm trying to replace the model with pretrained model and there is an error when I'm trying to move the data from train to validation . I hope that you could help me with the error.

Sure, I can help you. Please share more details (i.e., code) so that I can get a clearer idea about the issue!

ghost commented 3 years ago

Hi, thank you for the code. But I am encountering a problem using this code. I am using 9 classes as your code is only for 3 class. So I've done a little tweak on your code but it comes and also I'm trying to replace the model with pretrained model and there is an error when I'm trying to move the data from train to validation . I hope that you could help me with the error.

Sure, I can help you. Please share more details (i.e., code) so that I can get a clearer idea about the issue!

Hi, here is the code skfcv.txt

SadmanSakib93 commented 3 years ago

Hi, thank you for the code. But I am encountering a problem using this code. I am using 9 classes as your code is only for 3 class. So I've done a little tweak on your code but it comes and also I'm trying to replace the model with pretrained model and there is an error when I'm trying to move the data from train to validation . I hope that you could help me with the error.

Sure, I can help you. Please share more details (i.e., code) so that I can get a clearer idea about the issue!

Hi, here is the code skfcv.txt

I checked your code, seems good to me although I could not run/debug as I don't have the dataset. However, have you created three folders inside the "plantvillage" folder?

ghost commented 3 years ago

Hi, thank you for the code. But I am encountering a problem using this code. I am using 9 classes as your code is only for 3 class. So I've done a little tweak on your code but it comes and also I'm trying to replace the model with pretrained model and there is an error when I'm trying to move the data from train to validation . I hope that you could help me with the error.

Sure, I can help you. Please share more details (i.e., code) so that I can get a clearer idea about the issue!

Hi, here is the code skfcv.txt

I checked your code, seems good to me although I could not run/debug as I don't have the dataset. However, have you created three folders inside the "plantvillage" folder?

  • The plantvillage should have three folders named: train, validation, test.
  • Each of the three folders should have 10 folders according to 10 class labels.

Hi, thanks for the reply, i think i know where is my error... Thank you very much