I would like to classify 3 types of images using Python.
200 images were prepared and padded (18 images from one image data) to create a total data set of 10800 images.
This is ("./photo-min.npz").
We prepared 200 images for each image and created a total of 600 datasets without padding.
This is ("./photo-test.npz").
The results of machine learning are shown in the graph below.
I would like to know why the accuracy and loss in test are not ideal graphs like train.Applicable source code
from keras.models import Sequential from keras.layers import Activation, Dense, Flatten import numpy as np from keras.preprocessing.image import ImageDataGenerator classes = 3 data_size = 75 * 75 * 3 def main (): data = np.load ("./ photo-min.npz") # 10800 data sets x = data ["x"] y = data ["y"] data = np.load ("./ photo-test.npz") # 600 data sets x_test = data ["x"] y_test = data ["y"] x = np.reshape (x, (-1, data_size)) x_test = np.reshape (x_test, (-1, data_size)) model = train (x, y) model_eval (model, x_test, y_test) def train (x, y): model = Sequential () model.add (Dense (units = 128, input_dim = (data_size))) model.add (Activation ('relu')) model.add (Dense (units = classes)) model.add (Activation ('softmax')) model.compile (loss = 'sparse_categorical_crossentropy', optimizer = 'sgd', metrics = ['accuracy']) model.fit (x, y, epochs = 30) json_string = model.model.to_json () open ('./ men_predict.json', 'w'). write (json_string) hdf5_file = "./men_predict.hdf5" model.model.save_weights (hdf5_file) return model def model_eval (model, x, y): score = model.evaluate (x, y) print ('loss =', score ) print ('accuracy =', score ) if __name__ == "__main__": main ()
The number of units was trial and error, but the accuracy of the test did not increase.
Answer # 1
If you simply flatten an image of
75 * 75 * 3and identify it with a simple multilayer perceptron that is not a CNN, I think that's the case. I wonder if the model does not capture the features well.
- python - machine learning training/verification data, test data accuracy rate and adjustment
- python - in machine learning learning, the accuracy is 100% and the value of the loss function is almost 0 from the beginning an
- python - [machine learning] if the score changes significantly depending on how you divide it, are you overfitting?
- how to apply machine learning (svm) when a list is included in a python explanatory variable (parameter)
- python - about gpu of notebook pc to run machine learning system
- python - inconsistency in sample size of cnn machine learning with keras
- python - about the ratio of machine learning training data, validation data, and test data
- python - machine learning feature extraction of time series data
- machine learning - what happens if you break the tensor type data in pytorch?
- machine learning - whether to use probability distributions as labels or binary labels in deep learning
- machine learning - i don't understand the content of the error (keras, conv2d)
- python - error when learning keras neural network
- python - questions about learning with neural network models
- machine learning - about scraping image data
- python - calculation result changes for each machine in pytorch
- machine learning - when competing for image classification in kaggle, do the top prize winners create their own models?
- machine learning - is the gpu working properly?
- python - transfer learning with tensorflow object detection api is not possible
- html - the display of the verification tool and the display of the actual machine are significantly different
- what is the significance of the loss function in machine learning?
- introductory to o'reilly japan publishing in the text of python3 (3, 7 larger data structures), "lists, dictionaries, sets
- python - modelpredict() cannot be executed in tensorflow
- python - raspai ad conversion program
- python - about tensor generation
- cuda - runtimeerror occurs around pytorch
- python - about the value acquired by for sentence
- python - how can i make the tic-tac-toe that i made easier?
- python - i want to use the stack to reverse the strings, but an error occurs, so please give me a solution
- multidimensional array - i would like to know another method to predict the result of one data from multidimensional vector feat
- python - is it possible to perform weighting based on the difference in the amount of training data in a simple deep learning cl