2020. 3. 6. 14:28ㆍ인공지능
인터넷에 찾아보니 예제들이 있어 그대로 하니 잘 안되어서
1. 설치 버전
1) Python : 3.7.6
2) Tensorflow : 2.1.0
3) Keras : 2.3.1
2. 소스
from keras.datasets import mnist
from autokeras import ImageClassifier
(x_train, y_train), (x_test, y_test) = mnist.load_data()
x_train = x_train.reshape(x_train.shape + (1,)) # (1,) denotes the channles which is 1 in this case
x_test = x_test.reshape(x_test.shape + (1,)) # (1,) denotes the channles which is 1 in this case
clf = ImageClassifier()
clf.fit(x_train, y_train)
(x_train, y_train), (x_test, y_test) = mnist.load_data()
3. 결과
Train for 1500 steps, validate for 375 steps
Epoch 1/1000
1500/1500 [==============================] - 52s 35ms/step - loss: 0.1715 - accuracy: 0.9475 - val_loss: 0.0710 - val_accuracy: 0.9792
Epoch 2/1000
................................
1500/1500 [==============================] - 51s 34ms/step - loss: 0.0204 - accuracy: 0.9927 - val_loss: 0.0414 - val_accuracy: 0.9900
Epoch 20/1000
1500/1500 [==============================] - 51s 34ms/step - loss: 0.0217 - accuracy: 0.9927 - val_loss: 0.0417 - val_accuracy: 0.9893
[Trial complete]
[Trial summary]
|-Trial ID: e9fea079a980756cf5cb43345c2e712e
|-Score: 0.038674127771691325
|-Best step: 0
> Hyperparameters:
|-classification_head_1/dropout_rate: 0.5
|-classification_head_1/spatial_reduction_1/reduction_type: flatten
|-dense_block_1/dropout_rate: 0
|-dense_block_1/num_layers: 1
|-dense_block_1/units_0: 128
|-dense_block_1/use_batchnorm: False
|-image_block_1/augment: False
|-image_block_1/block_type: vanilla
|-image_block_1/conv_block_1/dropout_rate: 0.25
|-image_block_1/conv_block_1/filters_0_0: 32
|-image_block_1/conv_block_1/filters_0_1: 64
|-image_block_1/conv_block_1/kernel_size: 3
|-image_block_1/conv_block_1/max_pooling: True
|-image_block_1/conv_block_1/num_blocks: 1
|-image_block_1/conv_block_1/num_layers: 2
|-image_block_1/conv_block_1/separable: False
|-image_block_1/normalize: True
|-optimizer: adam
Train for 1500 steps, validate for 375 steps
Epoch 1/1000
1500/1500 [==============================] - 1521s 1s/step - loss: 0.2227 - accuracy: 0.9381 - val_loss: 0.1432 - val_accuracy: 0.9625
Epoch 2/1000
1500/1500 [==============================] - 1633s 1s/step - loss: 0.1563 - accuracy: 0.9605 - val_loss: 0.0721 - val_accuracy: 0.9795
................................................
1500/1500 [==============================] - 1509s 1s/step - loss: 0.0060 - accuracy: 0.9982 - val_loss: 0.0629 - val_accuracy: 0.9877
Epoch 36/1000
1500/1500 [==============================] - 1518s 1s/step - loss: 0.0046 - accuracy: 0.9989 - val_loss: 0.0470 - val_accuracy: 0.9912
[Trial complete]
[Trial summary]
|-Trial ID: 7fd78984640e35c2dbe0c037d38a266b
|-Score: 0.039056800348457425
|-Best step: 0
> Hyperparameters:
|-classification_head_1/dropout_rate: 0
|-dense_block_1/dropout_rate: 0
|-dense_block_1/num_layers: 2
|-dense_block_1/units_0: 32
|-dense_block_1/units_1: 32
|-dense_block_1/use_batchnorm: False
|-image_block_1/augment: True
|-image_block_1/block_type: resnet
|-image_block_1/normalize: True
|-image_block_1/res_net_block_1/conv3_depth: 4
|-image_block_1/res_net_block_1/conv4_depth: 6
|-image_block_1/res_net_block_1/pooling: avg
|-image_block_1/res_net_block_1/version: v2
|-optimizer: adam
Train for 1500 steps, validate for 375 steps
Epoch 1/1000
1500/1500 [==============================] - 53s 35ms/step - loss: 0.1769 - accuracy: 0.9466 - val_loss: 0.0677 - val_accuracy: 0.9808
Epoch 2/1000
1500/1500 [==============================] - 52s 35ms/step - loss: 0.0826 - accuracy: 0.9742 - val_loss: 0.0527 - val_accuracy: 0.9848
................................................
1500/1500 [==============================] - 52s 35ms/step - loss: 0.0199 - accuracy: 0.9934 - val_loss: 0.0477 - val_accuracy: 0.9903
Epoch 27/1000
1500/1500 [==============================] - 51s 34ms/step - loss: 0.0163 - accuracy: 0.9944 - val_loss: 0.0447 - val_accuracy: 0.9910
[Trial complete]
[Trial summary]
|-Trial ID: 50634a5647ede3546f77215692e42491
|-Score: 0.039515967257394854
|-Best step: 0
> Hyperparameters:
|-classification_head_1/dropout_rate: 0.5
|-classification_head_1/spatial_reduction_1/reduction_type: flatten
|-dense_block_1/dropout_rate: 0
|-dense_block_1/num_layers: 1
|-dense_block_1/units_0: 128
|-dense_block_1/use_batchnorm: False
|-image_block_1/augment: False
|-image_block_1/block_type: vanilla
|-image_block_1/conv_block_1/dropout_rate: 0.25
|-image_block_1/conv_block_1/filters_0_0: 32
|-image_block_1/conv_block_1/filters_0_1: 64
|-image_block_1/conv_block_1/kernel_size: 3
|-image_block_1/conv_block_1/max_pooling: True
|-image_block_1/conv_block_1/num_blocks: 1
|-image_block_1/conv_block_1/num_layers: 2
|-image_block_1/conv_block_1/separable: False
|-image_block_1/normalize: True
|-optimizer: adam
INFO:tensorflow:Oracle triggered exit
Train for 1875 steps, validate for 375 steps
Epoch 1/1000
1875/1875 [==============================] - 65s 35ms/step - loss: 0.1580 - accuracy: 0.9514 - val_loss: 0.0500 - val_accuracy: 0.9843
Epoch 2/1000
1875/1875 [==============================] - 65s 35ms/step - loss: 0.0742 - accuracy: 0.9773 - val_loss: 0.0258 - val_accuracy: 0.9927
................................................
Epoch 41/1000
1875/1875 [==============================] - 64s 34ms/step - loss: 0.0151 - accuracy: 0.9955 - val_loss: 0.0019 - val_accuracy: 0.9996
Epoch 42/1000
1875/1875 [==============================] - 64s 34ms/step - loss: 0.0153 - accuracy: 0.9952 - val_loss: 0.0018 - val_accuracy: 0.9993
'인공지능' 카테고리의 다른 글
tensorflow 1.15를 사용하여 Mask Rcnn 테스트(1) (0) | 2022.02.07 |
---|---|
Jetson Xavier NX 에서 Object Detection TensorRT 학습하기 (0) | 2021.03.31 |
jetson-nano, jetson-xavier ssd-mobilenet-v2 realtime inference (0) | 2021.03.24 |
'딥다 딥러닝' 다시 시작하자 (케라스 설치부터) (0) | 2020.01.11 |