flyyufelix / cnn_finetune

Fine-tune CNN in Keras
https://flyyufelix.github.io/2016/10/08/fine-tuning-in-keras-part2.html
MIT License
937 stars 413 forks source link

load_data() module #43

Open Auth0rM0rgan opened 6 years ago

Auth0rM0rgan commented 6 years ago

Hey, Thanks for gathering all the CNN model + ImageNet Pretrained Models in a repo. I am curious about load_data() module. It would be nice if you can explain more or add some code how to write load_data() module. For example, there are two folders which one for training images and one for test images. How am I going to write load_data() module?

Thanks.

HwaiHo-0552 commented 6 years ago

I also want to get the load_data() module....... Thanks.

GreatNewHope commented 6 years ago

This code might serve as an example:

def load_data():
    # load the dataset (it's a normal numpy array, samples x features (features = channel x width x height))
    dataset = np.load("dataset.npy") 
    # load the targets (they must be one hot encoded; np.array([1,0]) rather than 1
    targets = np.load("targets.npy")
    # select training and validation / test
    x_train = src_dataset[:-1, :, :]
    y_train = targets[:-1, :, :]

    x_test = src_dataset[-1:, :, :]
    y_test = targets[-1:, : , :]

    y_train = np.reshape(y_train, (len(y_train), 1))
    y_test = np.reshape(y_test, (len(y_test), 1))

    return (x_train, y_train), (x_test, y_test)

Please correct me if something is wrong or it could lead to any errors

HwaiHo-0552 commented 6 years ago

@margaro95 Could you share the source code that load my own dataset ? I am a fresher. Thank you very much.