nealjean / predicting-poverty

Combining satellite imagery and machine learning to predict poverty
http://sustain.stanford.edu/predicting-poverty
MIT License
454 stars 233 forks source link

How to create the trained CNN model? #23

Closed ratihng closed 6 years ago

ratihng commented 6 years ago

Hi Neal, I tried to replicate this work for predicting poverty in another country. However, in this work, you have already provided the trained CNN (predicting_poverty_trained.caffemodel) to extract 4096 image features corresponding to each cluster (extract_features.py). Since I want to build a model for another country using the training images from this country, I would like to know how you built the trained CNN model.

  1. Do we train the model to perform a classification task since I noticed you used SOFTMAX in the last layer? what is the label for each image (I don't think we have the labels or the classes for images)?
  2. Is there any reason why you use the features in the layer conv7?

Thank you so much for your help. Looking forward to hearing from you.

nealjean commented 6 years ago
  1. We trained the network on nighttime lights labels that we split into three classes, {low, medium, high}. This data is publicly available and you can find more details in the paper. We used nighttime lights data from several years ago so there's probably more recent data that you can match with recent daytime satellite images.

  2. We felt that high-level satellite features would probably capture more information relevant to poverty than low-level features.

ratihng commented 6 years ago

Thanks Neal for the fast response. Yes, I am using the recent NOAA data which is in 2013. Thank you for the information since I don't find it in your paper. My nightlight intensity data ranges from 0-63, I think I need to divide the values into three classes. Great work, Neal!

nealjean commented 6 years ago

No problem - here's the supplement to the paper, might be useful

SM.pdf

ratihng commented 6 years ago

Hi Neal,

I have built my own trained CNN model by finetuning your caffe model using the training images from another country. Somehow when I performed a classification task in my test set, the accuracy is really low (0.2), all the predicted class = high. I am not sure what the problem is.

Does the performance of the CNN model in the classification task will affect the result of the regression model to predict poverty using the 4096 extracted features from the CNN model?

nealjean commented 6 years ago

How is your training accuracy? I haven't worked with caffe for a while so I won't be much help troubleshooting there, but in general think about some sanity checks of whether your code is working the way you expect

Performance on the classification task should be a rough indicator of the quality of the learned features so downstream performance will probably suffer

ratihng commented 6 years ago

I tried to change the configuration of the network, but the last accuracy I got is only 0.34. Could you perhaps provide the train_val.prototxt and solver.prototxt? By the way, is there any particular reason why you use the VGG-F as the pre-trained model?

nealjean commented 6 years ago

At the time that we started this project, VGG was state-of-the-art in object recognition =D

I've attached example prototxt files here (as .txt so Github will accept them) - I haven't worked with Caffe for a long time but hopefully they will be helpful!

example_solver.txt example_train_val.txt

hans-ekbrand commented 4 years ago

At the time that we started this project, VGG was state-of-the-art in object recognition =D

I've attached example prototxt files here (as .txt so Github will accept them) - I haven't worked with Caffe for a long time but hopefully they will be helpful!

example_solver.txt example_train_val.txt

Thanks for these!

This might be a dumb question, but anyway, but these lines in example_train_val.txt refer to the training target, right?

data_param {
    source: "/data/train_data.lmdb"
    batch_size: 32
    backend: LMDB
  }

If I wanted to adjust the model to output a single float [0, 1] per image (to get rid of the ridge lasso step), then would it suffice to add a layer after layer 7 that would go from 4096 nodes to 1 node and create a train_data.lmdb with the correct floats for each training image?

sangmichaelxie commented 4 years ago

That sounds correct, as long as you also change the loss!

Best Michael

On Fri, Oct 23, 2020 at 3:20 AM Hans Ekbrand notifications@github.com wrote:

At the time that we started this project, VGG was state-of-the-art in object recognition =D

I've attached example prototxt files here (as .txt so Github will accept them) - I haven't worked with Caffe for a long time but hopefully they will be helpful!

example_solver.txt https://github.com/nealjean/predicting-poverty/files/2456754/example_solver.txt example_train_val.txt https://github.com/nealjean/predicting-poverty/files/2456755/example_train_val.txt

Thanks for these!

This might be a dump question, but anyway, but these lines in example_train_val.txt refer to the training target, right?

data_param { source: "/data/train_data.lmdb" batch_size: 32 backend: LMDB }

If I wanted to adjust the model to output a single float [0, 1] per image (to get rid of the ridge lasso step), then would it suffice to add a layer after layer 7 that would go from 4096 nodes to 1 node and create a train_data.lmdb with the correct floats for each training image?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/nealjean/predicting-poverty/issues/23#issuecomment-715250434, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB4J2SVJ5K366IQM7IB2EDDSMFKHXANCNFSM4FWWCQIQ .