Home>
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 codefrom 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 [0])
print ('accuracy =', score [1])
if __name__ == "__main__":
main ()
The number of units was trial and error, but the accuracy of the test did not increase.
-
Answer # 1
Related articles
- python - machine learning training/verification data, test data accuracy rate and adjustment
- python - inconsistency in sample size of cnn machine learning with keras
- python - abnormal termination in machine learning using jupyter notebook
- how to apply machine learning (svm) when a list is included in a python explanatory variable (parameter)
- machine learning in python, breast cancer diagnosis
- python - machine learning feature extraction of time series data
- python - about the ratio of machine learning training data, validation data, and test data
- python machine learning
- is machine learning really a black box?
- machine learning - error when learning yolo format original data set in googlecolab/yolov3/darknet environment
- (beginner among machine learning beginners) please tell me how to actually test with tensorflow
- only part of the data is recognized when learning python
- machine learning - how to determine the threshold of the k-nearest neighbor method for time series data, etc
- i tried to collect by google_images_download to collect machine learning data, but i can not download even one
- python - about errors in deep learning
- machine learning - image discrimination method for a large number of leaflet images
- python - a code that automatically selects the features used in machine learning
- machine learning - image file cannot be written by etcher in jetson setup
- python 3x - python keras about the shape of learning data
- python - about learning mnist data with keras
Related questions
- python 3x - about the calculation of cross entropy in pytorch
- python 3x - i want to display the importance extracted by evaluating with random forest as a column graph
- i'm trying to create a scientific calculator with jupyter's python, but i want to add exponentiation, factorial, function, log,
- python 3x - i get a runtimeerror: size mismatch, in the image classification of pytorch what should i do?
- python - attributeerror: module'chainerfunction' has no attribute'max_pooling_2d'
- python 3x - inflating table data using gan
- python - about "could not retrieve index file" error
- python 3x - cnn-what is the average pooling process?
- python - pedestrian age group discrimination using opencv
- python3 string type'b'is attached
If you simply flatten an image of
75 * 75 * 3
and 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.