神經網路學習(二):嘗試只利用NN訓練CIFAR10來達到90%以上acc

目前最高50%且無法複製

多數逼近50約莫45

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import tensorflow as tf
from tensorflow.keras import layers,models
import matplotlib.pyplot as plt

#載入cifar10
cifar10 = tf.keras.datasets.cifar10
(train_images,train_labels),(test_images,test_labels) = cifar10.load_data()

#數據預處理
train_images = train_images.astype('float32')/255
test_images = test_images.astype('float32')/255

#NN
train_images_nn = train_images.reshape((50000,32*32*3))
test_images_nn = test_images.reshape((10000,32*32*3))

model_nn = models.Sequential([
layers.Dense(4096,activation='relu',input_shape=(32*32*3,)),
#layers.Flatten(),
#'leaky_relu'
layers.Dense(2048,activation='relu'),
layers.Dense(1024,activation='relu'),
layers.Dense(512,activation='relu'),
layers.Dense(256,activation='relu'),
layers.Dense(128,activation='relu'),
layers.Dense(64,activation='relu'),
layers.Dense(10,activation='softmax'),
])

model_nn.compile(
optimizer='adam',
loss='sparse_categorical_crossentropy',
metrics=['accuracy']
)

history_nn = model_nn.fit(train_images_nn,train_labels,epochs=15,validation_data=(test_images_nn,test_labels))
1
2
Epoch 15/15
1563/1563 [==============================] - 11s 7ms/step - loss: 1.3659 - accuracy: 0.5124 - val_loss: 1.4874 - val_accuracy: 0.4744

神經網路學習(二):嘗試只利用NN訓練CIFAR10來達到90%以上acc
http://example.com/2023/04/29/神經網路學習-二-:/
作者
發布於
2023年4月29日
許可協議